Compare commits

...

2 Commits

  1. 2
      src/entity.zig
  2. 8
      src/id.zig
  3. 6
      src/pair.zig

@ -198,7 +198,7 @@ pub fn Entity(comptime ctx: anytype) type {
}
pub fn asId(self: Self) Id(ctx) {
return @bitCast(self);
return .{ .world = self.world, .raw = self.raw };
}
pub fn getEntityId(self: Self) u32 {

@ -57,7 +57,7 @@ pub fn Id(comptime ctx: anytype) type {
/// Returns this `Id` as an `Entity`, or `null` otherwise.
/// This assumes the `Id` is valid, or an invalid result could be returned.
pub fn asEntityUnsafe(self: Self) ?Entity(ctx) {
return if (isEntity(self)) @bitCast(self) else null;
return if (isEntity(self)) .{ .world = self.world, .raw = self.raw } else null;
}
pub fn isPair(self: Self) bool {
@ -68,19 +68,19 @@ pub fn Id(comptime ctx: anytype) type {
/// a pair, or either of its elements are not valid or not alive in
/// the world.
pub fn asPairAlive(self: Self) !Pair(ctx) {
return @as(Pair(ctx), @bitCast(self)).ensureAlive();
return @as(Pair(ctx), .{ .world = self.world, .raw = self.raw }).ensureAlive();
}
/// Attempts to return this `Id` as a `Pair`, or an error if it's not
/// a pair, or either of its elements are not valid.
pub fn asPairValid(self: Self) !Pair(ctx) {
return @as(Pair(ctx), @bitCast(self)).ensureValid();
return @as(Pair(ctx), .{ .world = self.world, .raw = self.raw }).ensureValid();
}
/// Returns this `Id` as a `Pair`, or `null` otherwise.
/// This assumes the `Id` is valid, or an invalid result could be returned.
pub fn asPairUnsafe(self: Self) ?Pair(ctx) {
return if (isPair(self)) @bitCast(self) else null;
return if (isPair(self)) .{ .world = self.world, .raw = self.raw } else null;
}
pub fn isWildcard(self: Self) bool {

@ -57,15 +57,15 @@ pub fn Pair(comptime ctx: anytype) type {
}
pub fn asId(self: Self) Id(ctx) {
return @bitCast(self);
return .{ .world = self.world, .raw = self.raw };
}
pub fn getRelation(self: Self) Entity(ctx) {
return Entity(ctx).fromRaw(self.world.raw, c.ECS_PAIR_FIRST(self.raw));
return Entity(ctx).fromRaw(self.world, c.ECS_PAIR_FIRST(self.raw));
}
pub fn getTarget(self: Self) Entity(ctx) {
return Entity(ctx).fromRaw(self.world.raw, c.ECS_PAIR_SECOND(self.raw));
return Entity(ctx).fromRaw(self.world, c.ECS_PAIR_SECOND(self.raw));
}
// TODO: Decide whether to copy `Id` functions over?

Loading…
Cancel
Save