Add World.tag to created Tag by type

main
copygirl 1 year ago
parent a372768702
commit 67a5c566a4
  1. 9
      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 }, .{});

Loading…
Cancel
Save