|
|
|
|
@ -371,9 +371,6 @@ export class GameEngine {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const newX = hero.position.x || 0;
|
|
|
|
|
const newY = hero.position.y || 0;
|
|
|
|
|
|
|
|
|
|
const activity = hero.serverActivityState?.toLowerCase();
|
|
|
|
|
const isDead = hero.hp <= 0 || activity === 'dead';
|
|
|
|
|
|
|
|
|
|
@ -405,16 +402,9 @@ export class GameEngine {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const tdx = newX - this._targetPositionX;
|
|
|
|
|
const tdy = newY - this._targetPositionY;
|
|
|
|
|
if (
|
|
|
|
|
tdx * tdx + tdy * tdy >
|
|
|
|
|
POSITION_DRIFT_SNAP_THRESHOLD * POSITION_DRIFT_SNAP_THRESHOLD
|
|
|
|
|
) {
|
|
|
|
|
this._snapHeroWorldPositionTo(newX, newY);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Display position: follow hero_move interpolation and applyPositionSync only.
|
|
|
|
|
// Do not snap here on hero_state vs last move — server position includes
|
|
|
|
|
// excursion/rest offsets and ordering with hero_move caused visible teleports.
|
|
|
|
|
|
|
|
|
|
this._notifyStateChange();
|
|
|
|
|
}
|
|
|
|
|
@ -923,24 +913,6 @@ export class GameEngine {
|
|
|
|
|
|
|
|
|
|
// ---- Private: Helpers ----
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Snap render/interpolation state and camera to a world position (teleport, town arrival, etc.).
|
|
|
|
|
*/
|
|
|
|
|
private _snapHeroWorldPositionTo(x: number, y: number): void {
|
|
|
|
|
this._heroDisplayX = x;
|
|
|
|
|
this._heroDisplayY = y;
|
|
|
|
|
this._prevPositionX = x;
|
|
|
|
|
this._prevPositionY = y;
|
|
|
|
|
this._targetPositionX = x;
|
|
|
|
|
this._targetPositionY = y;
|
|
|
|
|
this._moveTargetX = x;
|
|
|
|
|
this._moveTargetY = y;
|
|
|
|
|
this._lastMoveUpdateTime = performance.now();
|
|
|
|
|
const heroScreen = worldToScreen(x, y);
|
|
|
|
|
this.camera.setTarget(heroScreen.x, heroScreen.y);
|
|
|
|
|
this.camera.snapToTarget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _notifyStateChange(): void {
|
|
|
|
|
this._onStateChange?.(this._gameState);
|
|
|
|
|
}
|
|
|
|
|
|