From e6f54c36940f63c5a3ea9e2ae5a4e40e8ca02a44 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 29 Sep 2024 01:52:35 -0500 Subject: [PATCH] refactor: mergeDiff API --- app/ecs/ecs.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/ecs/ecs.js b/app/ecs/ecs.js index 7e8f84e..df242eb 100644 --- a/app/ecs/ecs.js +++ b/app/ecs/ecs.js @@ -397,14 +397,18 @@ export default class Ecs { } // Otherwise, merge. else { - for (const componentName in components) { - this.diff[entityId][componentName] = false === components[componentName] - ? false - : this.Components[componentName].mergeDiff( - this.diff[entityId][componentName] || {}, - components[componentName], - ); - } + this.mergeDiff(this.diff[entityId], components); + } + } + + mergeDiff(l, r) { + for (const componentName in r) { + l[componentName] = false === r[componentName] + ? false + : this.Components[componentName].mergeDiff( + l[componentName] || {}, + r[componentName], + ); } }