From e728e47136efec16c467ebd3a6525f6bfc6d8079 Mon Sep 17 00:00:00 2001 From: copygirl Date: Wed, 6 Mar 2024 12:15:01 +0100 Subject: [PATCH] Fix and rename lookupType --- src/world.zig | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/world.zig b/src/world.zig index b8f10a1..e209cb4 100644 --- a/src/world.zig +++ b/src/world.zig @@ -101,10 +101,11 @@ pub fn World(comptime ctx: anytype) type { return Entity.fromRaw(self, current); } - /// Returns the component `Entity` registered for the specified - /// type `T`, or an error if an association has not been made. - pub fn lookupByType(self: *Self, comptime T: type) !Entity { - return lookupAlive(self, Context.lookup(T).*); + /// Returns the component `Entity` registered for the specified type + /// `T`, or an error if an association has not been made, or the + /// entity is not alive. + pub fn lookupType(self: *Self, comptime T: type) !Entity { + return lookupAlive(self, Context.lookup(T)); } /// Creates or modifies an `Entity` in this `World`. @@ -157,7 +158,7 @@ pub fn World(comptime ctx: anytype) type { /// Returns `error.ComponentMissing` if the component is missing. /// Both of these may occur from not calling `singleton()` first. pub fn get(self: *Self, comptime T: type) !T { - const e = try self.lookupByType(T); + const e = try self.lookupType(T); return e.get(T) orelse error.ComponentMissing; } @@ -166,7 +167,7 @@ pub fn World(comptime ctx: anytype) type { /// Returns `error.IsNotAlive` if the entity is missing. /// This may occur from not calling `singleton()` first. pub fn set(self: *Self, comptime T: type, value: T) !void { - const e = try self.lookupByType(T); + const e = try self.lookupType(T); e.set(T, value); }