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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user