Allow move-to pathfinding into the static chunk ring.
Player click destinations outside the 3×3 entity view were clipped by VISIBLE_CHUNK_RADIUS bounds; use STATIC_CHUNK_RADIUS so long-vision map tiles remain walkable.
@@ -1,4 +1,4 @@
1
import { GAIT, VISIBLE_CHUNK_RADIUS, DEFAULT_WORLD_SETTINGS, NAV_STUCK_MS } from "../../../shared/protocol/constants.js";
1
import { GAIT, VISIBLE_CHUNK_RADIUS, STATIC_CHUNK_RADIUS, DEFAULT_WORLD_SETTINGS, NAV_STUCK_MS } from "../../../shared/protocol/constants.js";
2
2
import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";
3
3
import {
4
4
chunkKey,
@@ -979,7 +979,8 @@ export class WorkerWorld
979
979
let path = this.ecs.get(handle, Component.path);
980
980
if (!path)
981
981
{ path = this.ecs.add(handle, Component.path, { tiles: [] }); }
982
const bounds = chunkBoundsAround(position.tileX, position.tileY, VISIBLE_CHUNK_RADIUS);
982
// Match the static map ring (long vision): clicks outside the 3×3 entity view still path.
983
const bounds = chunkBoundsAround(position.tileX, position.tileY, STATIC_CHUNK_RADIUS);
983
984
path.tiles = findPath(
984
985
position.tileX,
985
986
position.tileY,
@@ -1661,8 +1662,13 @@ export class WorkerWorld
1661
1662
path.stuckSince = null;
1662
1663
return;
1663
1664
}
1664
const bounds = chunkBoundsAround(position.tileX, position.tileY, VISIBLE_CHUNK_RADIUS);
1665
1665
const stuckHandle = this.ecs.handleOf(entityId);
1666
const isCharacter = stuckHandle != null && this.ecs.has(stuckHandle, Component.character);
1667
const bounds = chunkBoundsAround(
1668
position.tileX,
1669
position.tileY,
1670
isCharacter ? STATIC_CHUNK_RADIUS : VISIBLE_CHUNK_RADIUS
1671
);
1666
1672
const inCombat = stuckHandle != null
1667
1673
&& this.ecs.get(stuckHandle, Component.combat)?.targetEntityId != null;
1668
1674
path.tiles = findPath(
@@ -1,4 +1,4 @@1
import { GAIT, VISIBLE_CHUNK_RADIUS, DEFAULT_WORLD_SETTINGS, NAV_STUCK_MS } from "../../../shared/protocol/constants.js";1
import { GAIT, VISIBLE_CHUNK_RADIUS, STATIC_CHUNK_RADIUS, DEFAULT_WORLD_SETTINGS, NAV_STUCK_MS } from "../../../shared/protocol/constants.js";2
import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";2
import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";3
import {3
import {4
chunkKey,4
chunkKey,@@ -979,7 +979,8 @@ export class WorkerWorld979
let path = this.ecs.get(handle, Component.path);979
let path = this.ecs.get(handle, Component.path);980
if (!path)980
if (!path)981
{ path = this.ecs.add(handle, Component.path, { tiles: [] }); }981
{ path = this.ecs.add(handle, Component.path, { tiles: [] }); }982
const bounds = chunkBoundsAround(position.tileX, position.tileY, VISIBLE_CHUNK_RADIUS);982
// Match the static map ring (long vision): clicks outside the 3×3 entity view still path.983
const bounds = chunkBoundsAround(position.tileX, position.tileY, STATIC_CHUNK_RADIUS);983
path.tiles = findPath(984
path.tiles = findPath(984
position.tileX,985
position.tileX,985
position.tileY,986
position.tileY,@@ -1661,8 +1662,13 @@ export class WorkerWorld1661
path.stuckSince = null;1662
path.stuckSince = null;1662
return;1663
return;1663
}1664
}1664
const bounds = chunkBoundsAround(position.tileX, position.tileY, VISIBLE_CHUNK_RADIUS);1665
const stuckHandle = this.ecs.handleOf(entityId);1665
const stuckHandle = this.ecs.handleOf(entityId);1666
const isCharacter = stuckHandle != null && this.ecs.has(stuckHandle, Component.character);1667
const bounds = chunkBoundsAround(1668
position.tileX,1669
position.tileY,1670
isCharacter ? STATIC_CHUNK_RADIUS : VISIBLE_CHUNK_RADIUS1671
);1666
const inCombat = stuckHandle != null1672
const inCombat = stuckHandle != null1667
&& this.ecs.get(stuckHandle, Component.combat)?.targetEntityId != null;1673
&& this.ecs.get(stuckHandle, Component.combat)?.targetEntityId != null;1668
path.tiles = findPath(1674
path.tiles = findPath(@@ -155,6 +155,31 @@ test("move-to clears follow", () =>
155
155
{ harness.close(); }
156
156
});
157
157
158
test("move-to paths into the static chunk ring outside the 3x3 entity view", () =>
159
{
160
const harness = makeSimulation({ workerCount: 1 });
161
try
162
{
163
// Player in chunk 0,0: VISIBLE bounds end at tile 31; STATIC at 47.
164
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });
165
const playerId = harness.simulation.spawnCharacter(1, character);
166
harness.simulation.enqueue(1, {
167
type: "move-to",
168
characterId: character.character_id,
169
tileX: 40,
170
tileY: 8
171
});
172
harness.simulation.step();
173
const path = componentsOf(harness.simulation, playerId).path?.tiles ?? [];
174
assert.ok(path.length > 0, "expected a path into the static map ring");
175
const goal = path[path.length - 1];
176
assert.equal(goal.x, 40);
177
assert.equal(goal.y, 8);
178
}
179
finally
180
{ harness.close(); }
181
});
182
158
183
test("follower reuses the target vacated trail and waits off their tile", () =>
159
184
{
160
185
const harness = makeSimulation({ workerCount: 1 });
@@ -155,6 +155,31 @@ test("move-to clears follow", () =>155
{ harness.close(); }155
{ harness.close(); }156
});156
});157
157
158
test("move-to paths into the static chunk ring outside the 3x3 entity view", () =>159
{160
const harness = makeSimulation({ workerCount: 1 });161
try162
{163
// Player in chunk 0,0: VISIBLE bounds end at tile 31; STATIC at 47.164
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });165
const playerId = harness.simulation.spawnCharacter(1, character);166
harness.simulation.enqueue(1, {167
type: "move-to",168
characterId: character.character_id,169
tileX: 40,170
tileY: 8171
});172
harness.simulation.step();173
const path = componentsOf(harness.simulation, playerId).path?.tiles ?? [];174
assert.ok(path.length > 0, "expected a path into the static map ring");175
const goal = path[path.length - 1];176
assert.equal(goal.x, 40);177
assert.equal(goal.y, 8);178
}179
finally180
{ harness.close(); }181
});182
158
test("follower reuses the target vacated trail and waits off their tile", () =>183
test("follower reuses the target vacated trail and waits off their tile", () =>159
{184
{160
const harness = makeSimulation({ workerCount: 1 });185
const harness = makeSimulation({ workerCount: 1 });