Add entity.get_mut function

main
copygirl 1 year ago
parent ceb1f4cd80
commit 1a678d1f2f
  1. 9
      src/entity.zig

@ -279,7 +279,14 @@ pub fn Entity(comptime ctx: anytype) type {
pub fn get(self: Self, comptime T: type) ?*const T { pub fn get(self: Self, comptime T: type) ?*const T {
const id = Lookup(ctx, T).id; 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 { pub fn set(self: Self, comptime T: type, value: T) void {

Loading…
Cancel
Save