|
|
|
@ -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 { |
|
|
|
|