const c = @import("./c.zig"); const Lookup = @import("./main.zig").Lookup; const World = @import("./world.zig").World; pub fn Entity(comptime ctx: anytype) type { return struct { world: *World(ctx), raw: c.ecs_entity_t, const Self = @This(); pub fn fromRaw(world: *World(ctx), raw: c.ecs_entity_t) Self { return .{ .world = world, .raw = raw }; } pub fn isValid(self: Self) bool { return c.ecs_is_valid(self.world.raw, self.raw); } pub fn isAlive(self: Self) bool { return c.ecs_is_alive(self.world.raw, self.raw); } pub fn get(self: Self, comptime T: type) ?*const T { const id = Lookup(ctx, T).id; return @alignCast(@ptrCast(c.ecs_get_id(self.world.raw, self.raw, id))); } pub fn set(self: Self, comptime T: type, value: T) void { const id = Lookup(ctx, T).id; _ = c.ecs_set_id(self.world.raw, self.raw, id, @sizeOf(T), &value); } }; }