Skip to content

Commit

Permalink
Update dom.ts prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonmorixe authored Oct 24, 2024
1 parent 7df312c commit aa646a2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ export class MouseForceSystem extends System {
this.damping = damping;
}

update(entities: Entity[]) {
prepare(entities: Entity[]) {
entities.forEach((entity) => {
const position = entity.getComponent(PositionComponent);
const velocity = entity.getComponent(VelocityComponent);
const force = entity.getComponent(ForceComponent);
const mouseDrag = entity.getComponent(MouseDragComponent);

// TODO: Move this to init. Make Engine/System call init on all systems
if (mouseDrag && !mouseDrag.dragHandler) {
mouseDrag.dragHandler = new DragHandler(entity);
}
});
}

update(entities: Entity[]) {
entities.forEach((entity) => {
const position = entity.getComponent(PositionComponent);
const velocity = entity.getComponent(VelocityComponent);
const force = entity.getComponent(ForceComponent);
const mouseDrag = entity.getComponent(MouseDragComponent);

if (
position &&
Expand Down

0 comments on commit aa646a2

Please sign in to comment.