use crate::{action::LocalActionEncoder, entity::EntityId};
pub use edict_proc::Relation;
pub use self::{
child_of::ChildOf,
query::{
FetchFilterRelatedBy, FetchRelatedRead, FetchRelatedWith, FetchRelatedWrite,
FetchRelatesExclusiveRead, FetchRelatesExclusiveWith, FetchRelatesExclusiveWrite,
FetchRelatesRead, FetchRelatesToRead, FetchRelatesToWrite, FetchRelatesWith,
FetchRelatesWrite, FilterFetchRelatesTo, FilterRelated, FilterRelatedBy, FilterRelates,
FilterRelatesTo, Related, Relates, RelatesExclusive, RelatesTo, RelationIter,
RelationReadIter, RelationWriteIter,
},
};
pub(crate) use self::components::{OriginComponent, TargetComponent};
mod child_of;
mod components;
mod query;
pub trait Relation: Copy + 'static {
const EXCLUSIVE: bool = false;
const SYMMETRIC: bool = false;
const OWNED: bool = false;
#[inline]
#[must_use]
fn name() -> &'static str {
core::any::type_name::<Self>()
}
#[inline]
fn on_replace(
old_value: &mut Self,
new_value: &Self,
origin: EntityId,
old_target: EntityId,
new_target: EntityId,
encoder: LocalActionEncoder,
) -> bool {
let _ = old_value;
let _ = new_value;
let _ = origin;
let _ = old_target;
let _ = new_target;
let _ = encoder;
true
}
#[inline]
fn on_drop(self, origin: EntityId, target: EntityId, encoder: LocalActionEncoder) {
let _ = origin;
let _ = target;
let _ = encoder;
}
#[inline]
fn on_origin_drop(origin: EntityId, targets: &[(EntityId, Self)], encoder: LocalActionEncoder) {
let _ = origin;
let _ = targets;
let _ = encoder;
}
#[inline]
fn on_target_drop(origins: &[(EntityId, Self)], target: EntityId, encoder: LocalActionEncoder) {
let _ = origins;
let _ = target;
let _ = encoder;
}
}
pub trait ExclusiveRelation: Relation {
#[doc(hidden)]
const ASSERT_EXCLUSIVE: () = assert!(Self::EXCLUSIVE);
}