summaryrefslogtreecommitdiff
path: root/engine-ecs/src
diff options
context:
space:
mode:
Diffstat (limited to 'engine-ecs/src')
-rw-r--r--engine-ecs/src/actions.rs25
-rw-r--r--engine-ecs/src/component.rs70
-rw-r--r--engine-ecs/src/entity.rs11
-rw-r--r--engine-ecs/src/lib.rs39
-rw-r--r--engine-ecs/src/pair.rs61
-rw-r--r--engine-ecs/src/phase.rs2
-rw-r--r--engine-ecs/src/query/term.rs113
-rw-r--r--engine-ecs/src/sole.rs39
-rw-r--r--engine-ecs/src/system.rs4
-rw-r--r--engine-ecs/src/system/stateful.rs4
-rw-r--r--engine-ecs/src/uid.rs45
11 files changed, 257 insertions, 156 deletions
diff --git a/engine-ecs/src/actions.rs b/engine-ecs/src/actions.rs
index 69605b3..bbc19c6 100644
--- a/engine-ecs/src/actions.rs
+++ b/engine-ecs/src/actions.rs
@@ -1,12 +1,18 @@
use std::borrow::Cow;
use crate::bundle::Bundle;
-use crate::component::{Component, IntoParts, Parts as ComponentParts};
+use crate::component::{
+ Component,
+ IntoParts,
+ Parts as ComponentParts,
+ RemovableTuple as RemovableComponentTuple,
+};
use crate::entity::Name as EntityName;
use crate::event::component::Removed;
use crate::pair::Pair;
+use crate::sole::Sole;
use crate::system::{Metadata as SystemMetadata, Param as SystemParam};
-use crate::uid::{Uid, WithUidTuple};
+use crate::uid::Uid;
use crate::{ActionQueue, World};
/// Used to to queue up actions for a [`World`] to perform.
@@ -174,9 +180,9 @@ impl Actions<'_>
}
/// Queues up removing component(s) from a entity at the end of the current tick.
- pub fn remove_comps<Ids: WithUidTuple>(&mut self, entity_uid: Uid)
+ pub fn remove_comps<Components: RemovableComponentTuple>(&mut self, entity_uid: Uid)
{
- self.remove_components(entity_uid, Ids::uids());
+ self.remove_components(entity_uid, Components::ids());
}
/// Queues up setting the target of a entity's pair at the end of the current tick.
@@ -299,6 +305,16 @@ impl Actions<'_>
});
}
+ /// Queues up creation of a sole at the end of the current tick, returning the [`Uid`]
+ /// of the sole.
+ pub fn create_sole<SoleT: Sole>(&mut self, sole: SoleT) -> Uid
+ {
+ self.action_queue
+ .push(Action::CreateSole(sole.into_parts()));
+
+ SoleT::id()
+ }
+
/// Stops the [`World`]. The world will finish the current tick and that tick will be
/// the last.
pub fn stop(&mut self)
@@ -334,5 +350,6 @@ pub(crate) enum Action
pair_id: Uid,
new_pair: ComponentParts,
},
+ CreateSole(ComponentParts),
Stop,
}
diff --git a/engine-ecs/src/component.rs b/engine-ecs/src/component.rs
index 400b12c..d424e16 100644
--- a/engine-ecs/src/component.rs
+++ b/engine-ecs/src/component.rs
@@ -3,6 +3,7 @@ use std::fmt::Debug;
use std::ops::{Deref, DerefMut};
use engine_ecs_macros::Component;
+use seq_macro::seq;
use crate::event::component::Changed;
use crate::event::Submitter as EventSubmitter;
@@ -23,13 +24,9 @@ pub mod local;
pub(crate) mod storage;
-pub trait Component: SystemInput + Any + IntoParts
+/// A component that is not a pair and is not a sole.
+pub trait Component: WithAssociatedId + SystemInput + Any + IntoParts
{
- /// Returns the ID of this component.
- fn id() -> Uid
- where
- Self: Sized;
-
fn type_reflection() -> Option<&'static TypeReflection>
where
Self: Sized;
@@ -38,32 +35,50 @@ pub trait Component: SystemInput + Any + IntoParts
fn name(&self) -> &'static str;
}
-impl dyn Component
+pub trait WithAssociatedId
{
- pub fn downcast_mut<Real: 'static>(&mut self) -> Option<&mut Real>
- {
- (self as &mut dyn Any).downcast_mut()
- }
+ /// Returns the ID of this component.
+ fn id() -> Uid;
+}
- pub fn downcast_ref<Real: 'static>(&self) -> Option<&Real>
- {
- (self as &dyn Any).downcast_ref()
- }
+/// A component that is removable from it's entity.
+///
+/// This trait is implemented for [`crate::pair::Pair`] so it does not have [`Component`]
+/// as supertrait.
+pub trait Removable: WithAssociatedId {}
- pub fn is<Other: 'static>(&self) -> bool
- {
- (self as &dyn Any).is::<Other>()
- }
-}
+impl<ComponentT: Component> Removable for ComponentT {}
-impl Debug for dyn Component
+/// Implemented by tuples of types implementing [`Removable`].
+///
+/// This trait is sealed so it cannot be implemented by types outside of this module.
+pub trait RemovableTuple: sealed::Sealed
{
- fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
- {
- formatter.debug_struct("Component").finish_non_exhaustive()
- }
+ fn ids() -> impl IntoIterator<Item = Uid>;
+}
+
+macro_rules! gen_removable_tuple_impl {
+ ($c: tt) => {
+ seq!(I in 0..=$c {
+ impl<#(RemovableT~I: Removable,)*> RemovableTuple for (#(RemovableT~I,)*)
+ {
+ fn ids() -> impl IntoIterator<Item = Uid>
+ {
+ [#(RemovableT~I::id(),)*]
+ }
+ }
+
+ impl<#(RemovableT~I: Removable,)*> sealed::Sealed for (#(RemovableT~I,)*)
+ {
+ }
+ });
+ };
}
+seq!(C in 0..=16 {
+ gen_removable_tuple_impl!(C);
+});
+
#[derive(Debug)]
pub struct Handle<'a, DataT: ?Sized + 'static>
{
@@ -394,3 +409,8 @@ pub struct Info
pub name: &'static str,
pub is_sole: bool,
}
+
+mod sealed
+{
+ pub trait Sealed {}
+}
diff --git a/engine-ecs/src/entity.rs b/engine-ecs/src/entity.rs
index 7515f73..e85c49c 100644
--- a/engine-ecs/src/entity.rs
+++ b/engine-ecs/src/entity.rs
@@ -232,9 +232,16 @@ impl<'a> Handle<'a>
}
}
+ /// Returns whether or not this entity contains the specified component.
+ #[must_use]
+ pub fn has_component<ComponentT: Component>(&self) -> bool
+ {
+ self.has_component_by_id(ComponentT::id())
+ }
+
/// Returns whether or not this entity contains a component with the specified `Uid`.
#[must_use]
- pub fn has_component(&self, component_uid: Uid) -> bool
+ pub fn has_component_by_id(&self, component_uid: Uid) -> bool
{
self.archetype
.contains_component_with_exact_id(component_uid)
@@ -327,7 +334,7 @@ macro_rules! declare_entity {
world.spawn_with_uid(
*$ident,
($components).with_elem($crate::entity::Name {
- name: concat!(module_path!(), stringify!($ident)).into()
+ name: concat!(module_path!(), "::", stringify!($ident)).into()
})
);
});
diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs
index a752f6a..f9e8143 100644
--- a/engine-ecs/src/lib.rs
+++ b/engine-ecs/src/lib.rs
@@ -22,6 +22,7 @@ use crate::component::{
Info as ComponentInfo,
IntoParts as IntoComponentParts,
Parts as ComponentParts,
+ WithAssociatedId,
};
use crate::entity::{
Declaration as EntityDeclaration,
@@ -59,10 +60,10 @@ use crate::sole::{Single, Sole};
use crate::system::observer::Observer;
use crate::system::{
Callbacks,
+ Function as SystemFunction,
Metadata as SystemMetadata,
Param as SystemParam,
System,
- SystemComponent,
};
use crate::uid::Uid;
@@ -252,6 +253,7 @@ impl World
[
sole.into_parts(),
EntityName { name: name.into() }.into_parts(),
+ crate::sole::Is.into_parts(),
],
&ComponentAddingFlags { allow_soles: true },
);
@@ -271,7 +273,7 @@ impl World
self.create_ent(
ent_id,
- [SystemComponent { system }.into_parts()].into_iter().chain(
+ [SystemFunction { system }.into_parts()].into_iter().chain(
ObserverT::observed_events()
.into_iter()
.map(IntoComponentParts::into_parts),
@@ -290,7 +292,7 @@ impl World
{
let (type_erased_system, mut system_callbacks) = system.finish();
- let system_ent_id = self.spawn((SystemComponent { system: type_erased_system },));
+ let system_ent_id = self.spawn((SystemFunction { system: type_erased_system },));
system_callbacks.on_created(self, SystemMetadata { ent_id: system_ent_id });
@@ -490,7 +492,7 @@ impl World
.into_iter()
.filter_map(|phase_has_system| phase_has_system.get_target_ent())
{
- let Some(system) = system_entity.get::<SystemComponent>() else {
+ let Some(system) = system_entity.get::<SystemFunction>() else {
cold_path();
continue;
};
@@ -666,6 +668,31 @@ impl World
&ComponentAddingFlags { allow_soles: false },
);
}
+ Action::CreateSole(sole_parts) => {
+ if let Err(EntityAlreadyExistsError) =
+ self.data.component_storage.create_entity(sole_parts.id)
+ {
+ tracing::error!(
+ name = sole_parts.name,
+ "Can not create sole that already exists"
+ );
+ continue;
+ }
+
+ let name = sole_parts.name;
+
+ Self::add_entity_components(
+ sole_parts.id,
+ [
+ sole_parts,
+ EntityName { name: name.into() }.into_parts(),
+ crate::sole::Is.into_parts(),
+ ],
+ &mut self.data.component_storage,
+ &EventSubmitter::new(&self.data.new_events),
+ &ComponentAddingFlags { allow_soles: true },
+ );
+ }
Action::Stop => {
self.stop.store(true, Ordering::Relaxed);
}
@@ -873,10 +900,10 @@ impl World
{
assert!(event_id.is_pair());
- let query = Query::<(&SystemComponent,)>::from_flexible_query(
+ let query = Query::<(&SystemFunction,)>::from_flexible_query(
self.flexible_query(
QueryTerms::<QUERY_MAX_TERM_CNT>::builder()
- .present([SystemComponent::id(), event_id])
+ .present([SystemFunction::id(), event_id])
.build(),
),
);
diff --git a/engine-ecs/src/pair.rs b/engine-ecs/src/pair.rs
index 834077c..efeead9 100644
--- a/engine-ecs/src/pair.rs
+++ b/engine-ecs/src/pair.rs
@@ -8,6 +8,8 @@ use crate::component::{
HandleMut as ComponentHandleMut,
IntoParts as IntoComponentParts,
Parts as ComponentParts,
+ Removable as RemovableComponent,
+ WithAssociatedId as ComponentWithAssociatedId,
};
use crate::entity::{
Handle as EntityHandle,
@@ -21,7 +23,7 @@ use crate::query::{
TermsBuilderInterface,
};
use crate::reflection::Type as TypeReflection;
-use crate::uid::{PairParams as UidPairParams, Uid, With as WithUid};
+use crate::uid::{PairParams as UidPairParams, Uid};
use crate::util::impl_multiple;
use crate::{Component, EntityComponentRef, World};
@@ -265,7 +267,7 @@ where
_term_metadata: QueryTermMetadata,
)
{
- terms_builder.present([Pair::<Relation, Target>::uid()]);
+ terms_builder.present([Pair::<Relation, Target>::id()]);
}
fn fields(
@@ -276,7 +278,7 @@ where
{
let target_component = search_result
.entity_handle
- .get_matching_components(Pair::<Relation, Target>::uid())
+ .get_matching_components(Pair::<Relation, Target>::id())
.next()
.expect("Not possible");
@@ -308,7 +310,7 @@ where
_term_metadata: QueryTermMetadata,
)
{
- terms_builder.present([Pair::<Relation, Target>::uid()]);
+ terms_builder.present([Pair::<Relation, Target>::id()]);
}
fn fields(
@@ -319,7 +321,7 @@ where
{
let target_component = search_result
.entity_handle
- .get_matching_components(Pair::<Relation, Target>::uid())
+ .get_matching_components(Pair::<Relation, Target>::id())
.next()
.expect("Not possible");
@@ -355,7 +357,7 @@ where
_term_metadata: QueryTermMetadata,
)
{
- terms_builder.present([Self::uid()]);
+ terms_builder.present([Self::id()]);
}
fn fields(
@@ -366,7 +368,7 @@ where
{
let first_matching_comp = search_result
.entity_handle
- .get_matching_components(Self::uid())
+ .get_matching_components(Self::id())
.next()
.expect("Not possible");
@@ -378,12 +380,12 @@ where
}
}
-impl<Relation, Target> WithUid for Pair<Relation, Target>
+impl<Relation, Target> ComponentWithAssociatedId for Pair<Relation, Target>
where
Relation: Component,
Target: Component,
{
- fn uid() -> Uid
+ fn id() -> Uid
{
Uid::new_pair(&UidPairParams {
relation: Relation::id(),
@@ -392,15 +394,28 @@ where
}
}
-impl<Relation> WithUid for Pair<Relation, Wildcard>
+impl<Relation, Target> RemovableComponent for Pair<Relation, Target>
where
Relation: Component,
+ Target: Component,
{
- fn uid() -> Uid
+}
+
+// TODO: Implement RemovableComponent for Pair<Relation, Wildcard>
+// and Pair<Wildcard, Target>.
+//
+// This should only be done after removal of wildcard pairs is added in lib.rs
+
+impl<Relation> Pair<Relation, Wildcard>
+where
+ Relation: Component,
+{
+ #[must_use]
+ pub fn id() -> Uid
{
Uid::new_pair(&UidPairParams {
relation: Relation::id(),
- target: Wildcard::uid(),
+ target: Wildcard::id(),
})
}
}
@@ -464,19 +479,17 @@ impl<'query, Relation, Target> WithWildcard<'query, Relation, Target>
assert!(component_id.is_pair());
assert!(
- Relation::uid() == Wildcard::uid()
+ Relation::uid() == Wildcard::id()
|| component_id.relation() == Relation::uid()
);
assert!(
- Target::uid() == Wildcard::uid() || component_id.target() == Target::uid()
+ Target::uid() == Wildcard::id() || component_id.target() == Target::uid()
);
- assert!(Relation::uid() == Wildcard::uid() || Target::uid() == Wildcard::uid());
+ assert!(Relation::uid() == Wildcard::id() || Target::uid() == Wildcard::id());
- assert!(
- !(Relation::uid() == Wildcard::uid() && Target::uid() == Wildcard::uid())
- );
+ assert!(!(Relation::uid() == Wildcard::id() && Target::uid() == Wildcard::id()));
WithWildcard {
world,
@@ -641,11 +654,9 @@ impl<'query, Relation, Target> MultipleWithWildcard<'query, Relation, Target>
Relation: ComponentOrWildcard,
Target: ComponentOrWildcard,
{
- assert!(Relation::uid() == Wildcard::uid() || Target::uid() == Wildcard::uid());
+ assert!(Relation::uid() == Wildcard::id() || Target::uid() == Wildcard::id());
- assert!(
- !(Relation::uid() == Wildcard::uid() && Target::uid() == Wildcard::uid())
- );
+ assert!(!(Relation::uid() == Wildcard::id() && Target::uid() == Wildcard::id()));
MultipleWithWildcard {
entity_handle,
@@ -691,7 +702,7 @@ impl<'a, Relation: Component> IntoIterator
WithWildcardIter {
inner: self
.entity_handle
- .get_matching_components(Pair::<Relation, Wildcard>::uid()),
+ .get_matching_components(Pair::<Relation, Wildcard>::id()),
world: self.world,
_pd: PhantomData,
}
@@ -736,7 +747,7 @@ pub struct Wildcard(Infallible);
impl Wildcard
{
#[must_use]
- pub fn uid() -> Uid
+ pub fn id() -> Uid
{
Uid::wildcard()
}
@@ -761,7 +772,7 @@ impl ComponentOrWildcard for Wildcard
{
fn uid() -> Uid
{
- Wildcard::uid()
+ Wildcard::id()
}
}
diff --git a/engine-ecs/src/phase.rs b/engine-ecs/src/phase.rs
index 64c1593..8d09ab4 100644
--- a/engine-ecs/src/phase.rs
+++ b/engine-ecs/src/phase.rs
@@ -56,7 +56,7 @@ pub(crate) fn check_parents(
continue;
};
- if !parent_ent.has_component(Phase::id()) {
+ if !parent_ent.has_component::<Phase>() {
let parent_ent_name = parent_ent.get::<EntityName>();
tracing::warn!(
diff --git a/engine-ecs/src/query/term.rs b/engine-ecs/src/query/term.rs
index 980ee87..f5fd531 100644
--- a/engine-ecs/src/query/term.rs
+++ b/engine-ecs/src/query/term.rs
@@ -5,7 +5,9 @@ use crate::component::{
Component,
Handle as ComponentHandle,
HandleMut as ComponentHandleMut,
+ WithAssociatedId as _,
};
+use crate::pair::{Pair, Wildcard};
use crate::query::{
FoundByTraversal,
SearchResult,
@@ -17,19 +19,61 @@ use crate::query::{
Traversal,
TraversalKind,
};
-use crate::uid::With as WithUid;
use crate::World;
-pub struct With<WithUidT>
+pub struct With<T>
+{
+ _pd: PhantomData<T>,
+}
+
+impl<'query, ComponentT: Component> Term<'query> for With<ComponentT>
+{
+ type Fields = ();
+
+ fn apply_to_terms_builder<const MAX_TERM_CNT: usize>(
+ terms_builder: &mut TermsBuilder<MAX_TERM_CNT>,
+ _term_metadata: TermMetadata,
+ )
+ {
+ terms_builder.present([ComponentT::id()]);
+ }
+
+ fn fields(
+ _world: &'query World,
+ _search_result: &SearchResult<'query, '_>,
+ _term_metadata: TermMetadata,
+ ) -> Self::Fields
+ {
+ }
+}
+
+impl<'query, Relation, Target> Term<'query> for With<Pair<Relation, Target>>
where
- WithUidT: WithUid,
+ Relation: Component,
+ Target: Component,
{
- _pd: PhantomData<WithUidT>,
+ type Fields = ();
+
+ fn apply_to_terms_builder<const MAX_TERM_CNT: usize>(
+ terms_builder: &mut TermsBuilder<MAX_TERM_CNT>,
+ _term_metadata: TermMetadata,
+ )
+ {
+ terms_builder.present([Pair::<Relation, Target>::id()]);
+ }
+
+ fn fields(
+ _world: &'query World,
+ _search_result: &SearchResult<'query, '_>,
+ _term_metadata: TermMetadata,
+ ) -> Self::Fields
+ {
+ }
}
-impl<'query, WithUidT> Term<'query> for With<WithUidT>
+impl<'query, Relation> Term<'query> for With<Pair<Relation, Wildcard>>
where
- WithUidT: WithUid,
+ Relation: Component,
{
type Fields = ();
@@ -38,7 +82,7 @@ where
_term_metadata: TermMetadata,
)
{
- terms_builder.present([WithUidT::uid()]);
+ terms_builder.present([Pair::<Relation, Wildcard>::id()]);
}
fn fields(
@@ -50,16 +94,59 @@ where
}
}
-pub struct Without<WithUidT>
+pub struct Without<T>
+{
+ _pd: PhantomData<T>,
+}
+
+impl<'query, ComponentT: Component> Term<'query> for Without<ComponentT>
+{
+ type Fields = ();
+
+ fn apply_to_terms_builder<const MAX_TERM_CNT: usize>(
+ terms_builder: &mut TermsBuilder<MAX_TERM_CNT>,
+ _term_metadata: TermMetadata,
+ )
+ {
+ terms_builder.absent([ComponentT::id()]);
+ }
+
+ fn fields(
+ _world: &'query World,
+ _search_result: &SearchResult<'query, '_>,
+ _term_metadata: TermMetadata,
+ ) -> Self::Fields
+ {
+ }
+}
+
+impl<'query, Relation, Target> Term<'query> for Without<Pair<Relation, Target>>
where
- WithUidT: WithUid,
+ Relation: Component,
+ Target: Component,
{
- _pd: PhantomData<WithUidT>,
+ type Fields = ();
+
+ fn apply_to_terms_builder<const MAX_TERM_CNT: usize>(
+ terms_builder: &mut TermsBuilder<MAX_TERM_CNT>,
+ _term_metadata: TermMetadata,
+ )
+ {
+ terms_builder.absent([Pair::<Relation, Target>::id()]);
+ }
+
+ fn fields(
+ _world: &'query World,
+ _search_result: &SearchResult<'query, '_>,
+ _term_metadata: TermMetadata,
+ ) -> Self::Fields
+ {
+ }
}
-impl<'query, WithUidT> Term<'query> for Without<WithUidT>
+impl<'query, Relation> Term<'query> for Without<Pair<Relation, Wildcard>>
where
- WithUidT: WithUid,
+ Relation: Component,
{
type Fields = ();
@@ -68,7 +155,7 @@ where
_term_metadata: TermMetadata,
)
{
- terms_builder.absent([WithUidT::uid()]);
+ terms_builder.absent([Pair::<Relation, Wildcard>::id()]);
}
fn fields(
diff --git a/engine-ecs/src/sole.rs b/engine-ecs/src/sole.rs
index 4047b48..cf5283b 100644
--- a/engine-ecs/src/sole.rs
+++ b/engine-ecs/src/sole.rs
@@ -4,18 +4,14 @@ use std::fmt::Debug;
use crate::component::{
HandleMut as ComponentHandleMut,
IntoParts as IntoComponentParts,
+ WithAssociatedId as ComponentWithAssociatedId,
};
use crate::system::{Metadata as SystemMetadata, Param as SystemParam};
-use crate::uid::Uid;
-use crate::World;
+use crate::{Component, World};
/// A component which has a single instance in the [`World`].
-pub trait Sole: Any + IntoComponentParts
+pub trait Sole: Any + IntoComponentParts + ComponentWithAssociatedId
{
- fn id() -> Uid
- where
- Self: Sized;
-
fn type_reflection() -> Option<&'static crate::reflection::Type>
where
Self: Sized;
@@ -24,31 +20,10 @@ pub trait Sole: Any + IntoComponentParts
fn name(&self) -> &'static str;
}
-impl dyn Sole
-{
- pub fn downcast_mut<Real: 'static>(&mut self) -> Option<&mut Real>
- {
- (self as &mut dyn Any).downcast_mut()
- }
-
- pub fn downcast_ref<Real: 'static>(&self) -> Option<&Real>
- {
- (self as &dyn Any).downcast_ref()
- }
-
- pub fn is<Other: 'static>(&self) -> bool
- {
- (self as &dyn Any).is::<Other>()
- }
-}
-
-impl Debug for dyn Sole
-{
- fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
- {
- formatter.debug_struct("Sole").finish_non_exhaustive()
- }
-}
+/// Marker component for the entities of soles.
+#[derive(Debug, Component)]
+#[non_exhaustive]
+pub struct Is;
/// Holds a reference to a singleton component.
#[derive(Debug)]
diff --git a/engine-ecs/src/system.rs b/engine-ecs/src/system.rs
index e0eac57..b79f20c 100644
--- a/engine-ecs/src/system.rs
+++ b/engine-ecs/src/system.rs
@@ -163,8 +163,10 @@ impl Callbacks for NoCallbacks
fn on_created(&mut self, _world: &mut World, _metadata: Metadata) {}
}
+/// System & observer function component. Intentionally not runnable outside of this
+/// crate.
#[derive(Debug, Component)]
-pub(crate) struct SystemComponent
+pub struct Function
{
pub(crate) system: TypeErased,
}
diff --git a/engine-ecs/src/system/stateful.rs b/engine-ecs/src/system/stateful.rs
index c9354c3..f1b9396 100644
--- a/engine-ecs/src/system/stateful.rs
+++ b/engine-ecs/src/system/stateful.rs
@@ -59,9 +59,7 @@ macro_rules! impl_system {
func(#({
TParam~I::new(&world, &metadata)
- },)*);
-
- Ok(())
+ },)*).into_result()
},
name: type_name::<Func>()
};
diff --git a/engine-ecs/src/uid.rs b/engine-ecs/src/uid.rs
index 78ca2ad..6b1a4b5 100644
--- a/engine-ecs/src/uid.rs
+++ b/engine-ecs/src/uid.rs
@@ -1,10 +1,7 @@
use std::fmt::{Debug, Display, Formatter};
use std::sync::atomic::{AtomicU32, Ordering};
-use seq_macro::seq;
-
-use crate::component::Component;
-use crate::util::{gen_mask_64, Array, BitMask, NumberExt};
+use crate::util::{gen_mask_64, BitMask, NumberExt};
static NEXT: AtomicU32 = AtomicU32::new(Uid::FIRST_UNIQUE_ID);
@@ -165,43 +162,3 @@ pub struct PairParams
pub relation: Uid,
pub target: Uid,
}
-
-pub trait With: 'static
-{
- fn uid() -> Uid;
-}
-
-impl<ComponentT: Component> With for ComponentT
-{
- fn uid() -> Uid
- {
- Self::id()
- }
-}
-
-pub trait WithUidTuple
-{
- type UidsArray: Array<Uid>;
-
- fn uids() -> Self::UidsArray;
-}
-
-macro_rules! impl_with_uid_tuple {
- ($c: tt) => {
- seq!(I in 0..=$c {
- impl<#(WithUid~I: With,)*> WithUidTuple for (#(WithUid~I,)*)
- {
- type UidsArray = [Uid; $c + 1];
-
- fn uids() -> Self::UidsArray
- {
- [#(WithUid~I::uid(),)*]
- }
- }
- });
- };
-}
-
-seq!(C in 0..=16 {
- impl_with_uid_tuple!(C);
-});