|
|
@ -43,7 +43,9 @@ pub fn Iter(comptime ctx: anytype) type { |
|
|
|
pub fn field(self: Self, comptime T: type, index: usize) []T { |
|
|
|
pub fn field(self: Self, comptime T: type, index: usize) []T { |
|
|
|
var raw_ptr = c.ecs_field_w_size(self.raw, @sizeOf(T), @intCast(index)); |
|
|
|
var raw_ptr = c.ecs_field_w_size(self.raw, @sizeOf(T), @intCast(index)); |
|
|
|
var typed_ptr: [*]T = @alignCast(@ptrCast(raw_ptr)); |
|
|
|
var typed_ptr: [*]T = @alignCast(@ptrCast(raw_ptr)); |
|
|
|
return typed_ptr[0..self.getCount()]; |
|
|
|
const is_self = c.ecs_field_is_self(self.raw, @intCast(index)); |
|
|
|
|
|
|
|
const count = if (is_self) self.getCount() else 1; |
|
|
|
|
|
|
|
return typed_ptr[0..count]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn fieldId(self: Self, index: usize) Id(ctx) { |
|
|
|
pub fn fieldId(self: Self, index: usize) Id(ctx) { |
|
|
|