From e5febd5c6de0c926bfa282e9ff4f6147e2f2338d Mon Sep 17 00:00:00 2001 From: Axy Date: Fri, 25 Sep 2026 14:27:52 +0200 Subject: [PATCH] Small optimizing of hooks --- src/pacman/ecs/hierarchy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pacman/ecs/hierarchy.py b/src/pacman/ecs/hierarchy.py index de8697a..a428a72 100644 --- a/src/pacman/ecs/hierarchy.py +++ b/src/pacman/ecs/hierarchy.py @@ -33,12 +33,15 @@ class ChildOf(Component): return self._parent -def parent_insert_hook(queue: CommandQueue) -> RawComponentHook[Children]: +def parent_insert_hook( + queue: CommandQueue, children: Query[ChildOf] +) -> RawComponentHook[Children]: def inner(itr: RawComponentArg[Children]) -> None: inserts = [ (child, ChildOf(ent)) for ent, inserted in itr for child in inserted.children + if (e := children.get(child)) is None or e.parent is not ent ] queue.queue(lambda world: world.insert_many(ChildOf, inserts)) @@ -67,7 +70,6 @@ def child_insert_hook( inserts[inserted.parent]._children.add(ent) else: parent._children.add(ent) - queue.queue(lambda world: world.insert_many(Children, inserts.items())) return inner -- 2.53.0