summaryrefslogtreecommitdiff
path: root/ecs/src/uid.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/uid.rs')
-rw-r--r--ecs/src/uid.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/ecs/src/uid.rs b/ecs/src/uid.rs
index 6c97649..feed62c 100644
--- a/ecs/src/uid.rs
+++ b/ecs/src/uid.rs
@@ -54,8 +54,12 @@ impl Uid
}
}
+ /// Returns a new pair UID.
+ ///
+ /// # Panics
+ /// Will panic if either the given relation or target is a pair UID.
#[must_use]
- pub fn new_pair(params: PairParams) -> Self
+ pub fn new_pair(params: &PairParams) -> Self
{
assert_ne!(
params.relation.kind(),
@@ -102,6 +106,7 @@ impl Uid
///
/// # Panics
/// Will panic if this `Uid` is not a pair.
+ #[must_use]
pub fn relation_component(&self) -> Self
{
assert_eq!(self.kind(), Kind::Pair, "Uid is not a pair");
@@ -112,6 +117,7 @@ impl Uid
}
}
+ #[must_use]
pub fn has_same_relation_as(&self, other: Self) -> bool
{
self.relation() == other.relation()
@@ -121,6 +127,7 @@ impl Uid
///
/// # Panics
/// Will panic if this `Uid` is not a pair.
+ #[must_use]
pub fn relation_entity(&self) -> Self
{
assert_eq!(self.kind(), Kind::Pair, "Uid is not a pair");
@@ -135,6 +142,7 @@ impl Uid
///
/// # Panics
/// Will panic if this `Uid` is not a pair.
+ #[must_use]
pub fn target_component(&self) -> Self
{
assert_eq!(self.kind(), Kind::Pair, "Uid is not a pair");
@@ -149,6 +157,7 @@ impl Uid
///
/// # Panics
/// Will panic if this `Uid` is not a pair.
+ #[must_use]
pub fn target_entity(&self) -> Self
{
assert_eq!(self.kind(), Kind::Pair, "Uid is not a pair");
@@ -159,7 +168,7 @@ impl Uid
}
}
- fn relation(&self) -> u32
+ fn relation(self) -> u32
{
let Ok(relation) = u32::try_from(self.inner.field_get(RELATION_BITS)) else {
unreachable!("Uid relation does not fit in u32");