refactor: centralize system names, component types, entity types, and animation states into a new Constants module.
This commit is contained in:
parent
e9db84abd1
commit
3db2bb9160
20 changed files with 385 additions and 313 deletions
|
|
@ -1,17 +1,18 @@
|
|||
import { System } from '../core/System.js';
|
||||
import { SystemName, ComponentType } from '../core/Constants.js';
|
||||
|
||||
export class MovementSystem extends System {
|
||||
constructor() {
|
||||
super('MovementSystem');
|
||||
this.requiredComponents = ['Position', 'Velocity'];
|
||||
super(SystemName.MOVEMENT);
|
||||
this.requiredComponents = [ComponentType.POSITION, ComponentType.VELOCITY];
|
||||
this.priority = 10;
|
||||
}
|
||||
|
||||
process(deltaTime, entities) {
|
||||
entities.forEach(entity => {
|
||||
const position = entity.getComponent('Position');
|
||||
const velocity = entity.getComponent('Velocity');
|
||||
const health = entity.getComponent('Health');
|
||||
const position = entity.getComponent(ComponentType.POSITION);
|
||||
const velocity = entity.getComponent(ComponentType.VELOCITY);
|
||||
const health = entity.getComponent(ComponentType.HEALTH);
|
||||
|
||||
if (!position || !velocity) return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue