|
|
|
@ -31,11 +31,16 @@ pub fn Pair(comptime ctx: anytype) type { |
|
|
|
|
world: *World, |
|
|
|
|
raw: c.ecs_id_t, |
|
|
|
|
|
|
|
|
|
pub fn fromRaw(world: *World, relation_: c.ecs_entity_t, target_: c.ecs_entity_t) Self { |
|
|
|
|
return .{ .world = world, .raw = c.ecs_pair(relation_, target_) }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Build a pair from the specified `relation` and `target` entities. |
|
|
|
|
/// The specified entities must be alive in the world. |
|
|
|
|
/// Returns an error if either of the entities is not alive. |
|
|
|
|
pub fn init(relation_: Entity, target_: Entity) !Self { |
|
|
|
|
const raw = c.ecs_make_pair(relation_.ensureAlive().raw, target_.ensureAlive().raw); |
|
|
|
|
return .{ .world = relation_.world, .raw = raw }; |
|
|
|
|
try relation_.ensureAlive(); |
|
|
|
|
try target_.ensureAlive(); |
|
|
|
|
return fromRaw(relation_.world, relation_.raw, target_.raw); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Ensures this `Pair` is valid and its `relation` and `target` |
|
|
|
|