From 1a678d1f2f70aefa5c7f52a9d35631f9c01cf610 Mon Sep 17 00:00:00 2001 From: copygirl Date: Wed, 15 Nov 2023 08:36:21 +0100 Subject: [PATCH] Add entity.get_mut function --- src/entity.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/entity.zig b/src/entity.zig index 7d7f286..1e9b0d7 100644 --- a/src/entity.zig +++ b/src/entity.zig @@ -279,7 +279,14 @@ pub fn Entity(comptime ctx: anytype) type { pub fn get(self: Self, comptime T: type) ?*const T { const id = Lookup(ctx, T).id; - return @alignCast(@ptrCast(c.ecs_get_id(self.world.raw, self.raw, id))); + const ptr = c.ecs_get_id(self.world.raw, self.raw, id); + return @alignCast(@ptrCast(ptr)); + } + + pub fn get_mut(self: Self, comptime T: type) ?*T { + const id = Lookup(ctx, T).id; + const ptr = c.ecs_get_mut_id(self.world.raw, self.raw, id); + return @alignCast(@ptrCast(ptr)); } pub fn set(self: Self, comptime T: type, value: T) void {