diff --git a/src/world.zig b/src/world.zig index 2e50de4..077335c 100644 --- a/src/world.zig +++ b/src/world.zig @@ -67,7 +67,16 @@ pub fn World(comptime ctx: anytype) type { return Entity(ctx).new(self, config, add); } + pub fn tag(self: *Self, comptime T: type) !Entity(ctx) { + if (@sizeOf(T) > 0) @compileError("'" ++ @typeName(T) ++ "' must be a zero-sized type"); + const name = util.simpleTypeName(T); + const result = try self.entity(.{ .name = name, .symbol = name }, .{}); + Lookup(ctx, T).id = result.raw; + return result; + } + pub fn component(self: *Self, comptime T: type) !Entity(ctx) { + if (@sizeOf(T) == 0) @compileError("'" ++ @typeName(T) ++ "' must not be a zero-sized type"); const name = util.simpleTypeName(T); const entity2 = try self.entity(.{ .name = name, .symbol = name, .use_low_id = true }, .{});