Have Entity.set return itself

main
copygirl 1 year ago
parent 82e2dbe2f2
commit 1ee748cbbf
  1. 3
      src/entity.zig
  2. 4
      test/world.zig

@ -104,9 +104,10 @@ pub fn Entity(comptime ctx: anytype) type {
return @alignCast(@ptrCast(c.ecs_get_id(self.world.raw, self.raw, id)));
}
pub fn set(self: Self, comptime T: type, value: T) void {
pub fn set(self: Self, comptime T: type, value: T) Self {
const id = Lookup(ctx, T).id;
_ = c.ecs_set_id(self.world.raw, self.raw, id, @sizeOf(T), &value);
return self;
}
};
}

@ -45,8 +45,8 @@ test "World_progress_w_0" {
var ctx = util.Probe.init();
c.ecs_set_context(world.raw, &ctx);
e1.set(Position, .{ .x = 0, .y = 0 });
e1.set(Velocity, .{ .x = 1, .y = 2 });
_ = e1.set(Position, .{ .x = 0, .y = 0 });
_ = e1.set(Velocity, .{ .x = 1, .y = 2 });
_ = world.progress(0);

Loading…
Cancel
Save