Remove some duplicate code

main
copygirl 1 year ago
parent 45b5fc20c4
commit e3627fda0c
  1. 13
      src/entity.zig

@ -68,19 +68,6 @@ pub fn Entity(comptime ctx: anytype) type {
inline for (add, 0..) |a, i| inline for (add, 0..) |a, i|
desc.add[i] = util.anyToId(ctx, a); desc.add[i] = util.anyToId(ctx, a);
switch (@typeInfo(@TypeOf(add))) {
.Struct => |s| {
if (s.is_tuple) {
if (s.fields.len > c.FLECS_ID_DESC_MAX)
@compileError("Adding more than FLECS_ID_DESC_MAX ids");
inline for (add, 0..) |a, i|
desc.add[i] = util.anyToId(ctx, a);
} else if (s.fields.len > 0)
@compileError("Expected tuple or empty struct, got '" ++ @typeName(@TypeOf(add)) ++ "'");
},
else => @compileError("Expected tuple or empty struct, got '" ++ @typeName(@TypeOf(add)) ++ "'"),
}
const result = c.ecs_entity_init(world.raw, &desc); const result = c.ecs_entity_init(world.raw, &desc);
return Self.fromRaw(world, result); return Self.fromRaw(world, result);
} }

Loading…
Cancel
Save