From 10ce815c2afd913417ac93f639b10fc4ee689bdd Mon Sep 17 00:00:00 2001 From: copygirl Date: Sun, 19 Nov 2023 19:02:59 +0100 Subject: [PATCH] Add Entity.getChildren --- src/entity.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/entity.zig b/src/entity.zig index e194814..d1ed9a4 100644 --- a/src/entity.zig +++ b/src/entity.zig @@ -22,6 +22,7 @@ pub const EntityError = error{ GenMismatch, /// Entity is not alive. IsNotAlive, + // TODO: Rename this to `EntityMissing` and similar, use it elsewhere in the code. }; /// An `Entity` is an `Id` which represents a "thing" within the world. This @@ -259,6 +260,11 @@ pub fn Entity(comptime ctx: anytype) type { return if (result != 0) fromRaw(self.world, result) else null; } + /// Returns an iterator that yields each of this `Entity`s children. + pub fn getChildren(self: Self) World(ctx).TermIterator { + return self.world.term(.{ c.EcsChildOf, self }); + } + /// Returns an iterator that yields each of the targets of the /// specified `relation` that this `Entity` has, if any. pub fn getTargets(self: Self, relation: anytype) TargetIterator {