|
|
|
@ -38,12 +38,20 @@ pub fn World(comptime ctx: anytype) type { |
|
|
|
|
return c.ecs_progress(self.raw, delta_time); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn lookup(self: *Self, comptime T: type) ?Entity(ctx) { |
|
|
|
|
const id = Lookup(ctx, T).id; |
|
|
|
|
const result = Entity(ctx).fromRaw(self, id); |
|
|
|
|
return if (result.isAlive()) result else null; |
|
|
|
|
/// Returns an `Entity` for the specified `ecs_entity_t` value, or an |
|
|
|
|
/// error if the entity is invalid or not alive in this `World`. |
|
|
|
|
pub fn lookupAlive(self: *Self, id: c.ecs_entity_t) !Entity(ctx) { |
|
|
|
|
return Entity(ctx).fromRaw(self, id).ensureAlive(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// 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(ctx) { |
|
|
|
|
return lookupAlive(self, Lookup(ctx, T).id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Replace these functions with an entity builder interface. |
|
|
|
|
|
|
|
|
|
pub fn entity( |
|
|
|
|
self: *Self, |
|
|
|
|
comptime add: []const type, |
|
|
|
|