mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-25 19:48:52 +00:00
make spawn glow follow the player's currently selected spawn tile
Plumb spawnTile through PlayerUpdate / PlayerState / applyStateUpdate so the WebGL spawn overlay can read it directly. The glow was reading nameData.x/y (territory centroid for label placement) which only recomputes every 2 ticks and only when largestClusterBoundingBox has been updated by PlayerExecution — both lag the player's actual spawn click. Using spawnTile updates the same tick setSpawnTile() fires. Also adds spawnTile to diffPlayerUpdate / applyStateUpdate so changes after the initial full snapshot actually propagate (the recent diff-only PlayerUpdate path silently dropped any field not enumerated in those helpers).
This commit is contained in:
@@ -91,7 +91,8 @@ export class WebGLFrameBuilder {
|
||||
const centers: SpawnCenter[] = [];
|
||||
for (const p of gameView.players()) {
|
||||
if (!p.isPlayer() || p.type() !== PlayerType.Human) continue;
|
||||
if (!p.hasSpawned()) continue;
|
||||
const spawnTile = p.state.spawnTile;
|
||||
if (spawnTile === undefined) continue;
|
||||
const isSelf = me !== null && p.smallID() === me.smallID();
|
||||
// myPlayer reads as plain white so the local-player ring is visually
|
||||
// distinct from any team color; everyone else uses their territory tint.
|
||||
@@ -99,8 +100,11 @@ export class WebGLFrameBuilder {
|
||||
? { r: 255, g: 255, b: 255 }
|
||||
: p.territoryColor().toRgb();
|
||||
centers.push({
|
||||
x: p.nameData?.x ?? 0,
|
||||
y: p.nameData?.y ?? 0,
|
||||
// spawnTile tracks the player's currently-selected spawn directly —
|
||||
// updates the same tick the player picks a new location (faster than
|
||||
// the nameData centroid which only refreshes every 2 ticks).
|
||||
x: gameView.x(spawnTile),
|
||||
y: gameView.y(spawnTile),
|
||||
r: c.r / 255,
|
||||
g: c.g / 255,
|
||||
b: c.b / 255,
|
||||
|
||||
Reference in New Issue
Block a user