From 4256d8770f2e9650b3ad284151470b10dc02c584 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 13 Jul 2024 00:33:50 -0500 Subject: [PATCH] refactor: less noise --- app/ecs-systems/interactions.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/ecs-systems/interactions.js b/app/ecs-systems/interactions.js index 0d62cdc..6a36a68 100644 --- a/app/ecs-systems/interactions.js +++ b/app/ecs-systems/interactions.js @@ -12,7 +12,7 @@ export default class Interactions extends System { tick() { for (const entity of this.select('default')) { const {Interacts} = entity; - Interacts.willInteractWith = 0 + let willInteract = false; const entities = Array.from(this.ecs.system('Colliders').within(Interacts.aabb())) .filter((other) => other !== entity) .sort(({Position: l}, {Position: r}) => { @@ -24,8 +24,12 @@ export default class Interactions extends System { } if (other.Interactive && other.Interactive.interacting) { Interacts.willInteractWith = other.id; + willInteract = true; } } + if (!willInteract) { + Interacts.willInteractWith = 0; + } } }