BlueGit

timfa questward

Right-click context menu includes mobs on their previous tile while moving.

Remember the departed tile during movement lerp so Attack/Follow still appear where the mob just stood.

timfa Tim Falken · pushed by timfa

Authored 2026-09-01 · 2 months ago

Hash
dcfbc48835e7b5e8af6ac9b533e55883eb70a558
Parent
bc9e7272
2 files changed +23 −3
client/src/play/main.js +1 −1
@@ -1149,7 +1149,7 @@ function handleRightClick (event, mouseX, mouseY)
1149 1149 }
1150 1150 });
1151 1151
1152 for (const entity of view.entitiesAtTile(tile.tileX, tile.tileY))
1152 for (const entity of view.entitiesAtTile(tile.tileX, tile.tileY, { includePrevious: true }))
1153 1153 {
1154 1154 if (entity.entityId === view.localEntityId)
1155 1155 { continue; }
@@ -1149,7 +1149,7 @@ function handleRightClick (event, mouseX, mouseY)
1149 }
1149 }
1150 });
1150 });
1151
1151
1152 for (const entity of view.entitiesAtTile(tile.tileX, tile.tileY))
1152 for (const entity of view.entitiesAtTile(tile.tileX, tile.tileY, { includePrevious: true }))
1153 {
1153 {
1154 if (entity.entityId === view.localEntityId)
1154 if (entity.entityId === view.localEntityId)
1155 { continue; }
1155 { continue; }
client/src/render/worldView.js +22 −2
@@ -767,6 +767,11 @@ export class WorldView
767 767 existing.fromY = existing.visualY;
768 768 existing.shadeFromTileX = existing.tileX;
769 769 existing.shadeFromTileY = existing.tileY;
770 if (existing.tileX !== payload.tileX || existing.tileY !== payload.tileY)
771 {
772 existing.previousTileX = existing.tileX;
773 existing.previousTileY = existing.tileY;
774 }
770 775 existing.tileX = payload.tileX;
771 776 existing.tileY = payload.tileY;
772 777 existing.gait = payload.gait;
@@ -1304,12 +1309,23 @@ export class WorldView
1304 1309 return items;
1305 1310 }
1306 1311
1307 entitiesAtTile (tileX, tileY)
1312 entitiesAtTile (tileX, tileY, options = {})
1308 1313 {
1314 const includePrevious = !!options.includePrevious;
1309 1315 const matches = [];
1310 1316 for (const entity of this.entities.values())
1311 1317 {
1312 1318 if (entity.tileX === tileX && entity.tileY === tileY)
1319 {
1320 matches.push(entity);
1321 continue;
1322 }
1323 if (
1324 includePrevious
1325 && entity.lerpStarted != null
1326 && entity.previousTileX === tileX
1327 && entity.previousTileY === tileY
1328 )
1313 1329 { matches.push(entity); }
1314 1330 }
1315 1331 matches.sort((a, b) => (b.object?.layer ?? 0) - (a.object?.layer ?? 0));
@@ -1424,7 +1440,11 @@ export class WorldView
1424 1440 entity.visualX = entity.fromX + (target.x - entity.fromX) * t;
1425 1441 entity.visualY = entity.fromY + (target.y - entity.fromY) * t;
1426 1442 if (t >= 1)
1427 { entity.lerpStarted = null; }
1443 {
1444 entity.lerpStarted = null;
1445 entity.previousTileX = null;
1446 entity.previousTileY = null;
1447 }
1428 1448 }
1429 1449 else
1430 1450 {
@@ -767,6 +767,11 @@ export class WorldView
767 existing.fromY = existing.visualY;
767 existing.fromY = existing.visualY;
768 existing.shadeFromTileX = existing.tileX;
768 existing.shadeFromTileX = existing.tileX;
769 existing.shadeFromTileY = existing.tileY;
769 existing.shadeFromTileY = existing.tileY;
770 if (existing.tileX !== payload.tileX || existing.tileY !== payload.tileY)
771 {
772 existing.previousTileX = existing.tileX;
773 existing.previousTileY = existing.tileY;
774 }
770 existing.tileX = payload.tileX;
775 existing.tileX = payload.tileX;
771 existing.tileY = payload.tileY;
776 existing.tileY = payload.tileY;
772 existing.gait = payload.gait;
777 existing.gait = payload.gait;
@@ -1304,12 +1309,23 @@ export class WorldView
1304 return items;
1309 return items;
1305 }
1310 }
1306
1311
1307 entitiesAtTile (tileX, tileY)
1312 entitiesAtTile (tileX, tileY, options = {})
1308 {
1313 {
1314 const includePrevious = !!options.includePrevious;
1309 const matches = [];
1315 const matches = [];
1310 for (const entity of this.entities.values())
1316 for (const entity of this.entities.values())
1311 {
1317 {
1312 if (entity.tileX === tileX && entity.tileY === tileY)
1318 if (entity.tileX === tileX && entity.tileY === tileY)
1319 {
1320 matches.push(entity);
1321 continue;
1322 }
1323 if (
1324 includePrevious
1325 && entity.lerpStarted != null
1326 && entity.previousTileX === tileX
1327 && entity.previousTileY === tileY
1328 )
1313 { matches.push(entity); }
1329 { matches.push(entity); }
1314 }
1330 }
1315 matches.sort((a, b) => (b.object?.layer ?? 0) - (a.object?.layer ?? 0));
1331 matches.sort((a, b) => (b.object?.layer ?? 0) - (a.object?.layer ?? 0));
@@ -1424,7 +1440,11 @@ export class WorldView
1424 entity.visualX = entity.fromX + (target.x - entity.fromX) * t;
1440 entity.visualX = entity.fromX + (target.x - entity.fromX) * t;
1425 entity.visualY = entity.fromY + (target.y - entity.fromY) * t;
1441 entity.visualY = entity.fromY + (target.y - entity.fromY) * t;
1426 if (t >= 1)
1442 if (t >= 1)
1427 { entity.lerpStarted = null; }
1443 {
1444 entity.lerpStarted = null;
1445 entity.previousTileX = null;
1446 entity.previousTileY = null;
1447 }
1428 }
1448 }
1429 else
1449 else
1430 {
1450 {