From 1ee748cbbf5670144d7b5d6625f15c0daf4da004 Mon Sep 17 00:00:00 2001 From: copygirl Date: Mon, 28 Aug 2023 00:33:13 +0200 Subject: [PATCH] Have Entity.set return itself --- src/entity.zig | 3 ++- test/world.zig | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/entity.zig b/src/entity.zig index 0ebfa95..575decb 100644 --- a/src/entity.zig +++ b/src/entity.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; } }; } diff --git a/test/world.zig b/test/world.zig index 0f46e6e..03578f9 100644 --- a/test/world.zig +++ b/test/world.zig @@ -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);