fix: instantiate MovementComponent as this.movement in Unit base class

Infantry/Tank call this.movement.shouldUpdate() but Unit stored movement
config as a plain object in this.components. Import MovementComponent and
expose it as this.movement so subclasses get the real instance with shouldUpdate().
This commit is contained in:
2026-05-30 03:19:27 +00:00
parent 8961cd701f
commit ec7fdd5f8d

View File

@@ -1,5 +1,6 @@
import Phaser from 'phaser';
import EntityStateMachine from 'Systems/EntityStateMachine';
import MovementComponent from 'Entities/components/MovementComponent';
/**
* Unit Entity - Component-based architecture
@@ -60,6 +61,9 @@ export default class Unit extends Phaser.Physics.Arcade.Sprite {
this.dead = false;
this.setInteractive({ pixelPerfect: true });
// Expose MovementComponent as this.movement (expected by subclasses)
this.movement = new MovementComponent(this, config.movement || {});
// Initialize state machine
this.stateMachine = null;
this._initStateMachine();