refactor: centralize system names, component types, entity types, and animation states into a new Constants module.

This commit is contained in:
Juan Sebastián Montoya 2026-01-06 18:58:12 -05:00
parent e9db84abd1
commit 3db2bb9160
20 changed files with 385 additions and 313 deletions

View file

@ -1,26 +1,27 @@
import { System } from '../core/System.js';
import { SystemName, ComponentType } from '../core/Constants.js';
export class PlayerControllerSystem extends System {
constructor() {
super('PlayerControllerSystem');
this.requiredComponents = ['Position', 'Velocity'];
super(SystemName.PLAYER_CONTROLLER);
this.requiredComponents = [ComponentType.POSITION, ComponentType.VELOCITY];
this.priority = 5;
this.playerEntity = null;
}
process(deltaTime, entities) {
// Find player entity (first entity with player tag or specific component)
// Find player entity (entity with Evolution component)
if (!this.playerEntity) {
this.playerEntity = entities.find(e => e.hasComponent('Evolution'));
this.playerEntity = entities.find(e => e.hasComponent(ComponentType.EVOLUTION));
}
if (!this.playerEntity) return;
const inputSystem = this.engine.systems.find(s => s.name === 'InputSystem');
const inputSystem = this.engine.systems.find(s => s.name === SystemName.INPUT);
if (!inputSystem) return;
const velocity = this.playerEntity.getComponent('Velocity');
const position = this.playerEntity.getComponent('Position');
const velocity = this.playerEntity.getComponent(ComponentType.VELOCITY);
const position = this.playerEntity.getComponent(ComponentType.POSITION);
if (!velocity || !position) return;
// Movement input