copygirl 1 year ago
parent 39bd61a66c
commit 13936d11bb
  1. 2
      src/entity.zig
  2. 8
      src/id.zig
  3. 2
      src/pair.zig

@ -198,7 +198,7 @@ pub fn Entity(comptime ctx: anytype) type {
} }
pub fn asId(self: Self) Id(ctx) { pub fn asId(self: Self) Id(ctx) {
return @bitCast(self); return .{ .world = self.world, .raw = self.raw };
} }
pub fn getEntityId(self: Self) u32 { 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. /// Returns this `Id` as an `Entity`, or `null` otherwise.
/// This assumes the `Id` is valid, or an invalid result could be returned. /// This assumes the `Id` is valid, or an invalid result could be returned.
pub fn asEntityUnsafe(self: Self) ?Entity(ctx) { 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 { 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 /// a pair, or either of its elements are not valid or not alive in
/// the world. /// the world.
pub fn asPairAlive(self: Self) !Pair(ctx) { 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 /// 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. /// a pair, or either of its elements are not valid.
pub fn asPairValid(self: Self) !Pair(ctx) { 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. /// Returns this `Id` as a `Pair`, or `null` otherwise.
/// This assumes the `Id` is valid, or an invalid result could be returned. /// This assumes the `Id` is valid, or an invalid result could be returned.
pub fn asPairUnsafe(self: Self) ?Pair(ctx) { 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 { pub fn isWildcard(self: Self) bool {

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

Loading…
Cancel
Save