diff options
Diffstat (limited to 'ecs/src/event')
-rw-r--r-- | ecs/src/event/component.rs | 54 | ||||
-rw-r--r-- | ecs/src/event/start.rs | 7 |
2 files changed, 2 insertions, 59 deletions
diff --git a/ecs/src/event/component.rs b/ecs/src/event/component.rs index 8b066a7..5b40c39 100644 --- a/ecs/src/event/component.rs +++ b/ecs/src/event/component.rs @@ -6,13 +6,11 @@ use std::marker::PhantomData; use ecs_macros::Component; use crate::component::Component; -use crate::uid::Uid; -use crate::event::{Event, Id}; -use crate::tuple::{ReduceElement as TupleReduceElement, With as TupleWith}; /// Event emitted when: /// a) A entity with component `ComponentT` is spawned. /// b) A component `ComponentT` is added to a entity. +#[derive(Clone, Component)] pub struct Added<ComponentT> where ComponentT: Component, @@ -43,19 +41,8 @@ where } } -impl<ComponentT> Event for Added<ComponentT> -where - ComponentT: Component, -{ - fn id() -> Id - where - Self: Sized, - { - Id::new::<Added<ComponentForId>, _>(Some(ComponentT::id())) - } -} - /// Event emitted when a `ComponentT` component is removed from a entity. +#[derive(Clone, Component)] pub struct Removed<ComponentT> where ComponentT: Component, @@ -85,40 +72,3 @@ where Self { _pd: PhantomData } } } - -impl<ComponentT> Event for Removed<ComponentT> -where - ComponentT: Component, -{ - fn id() -> Id - where - Self: Sized, - { - Id::new::<Removed<ComponentForId>, _>(Some(ComponentT::id())) - } -} - -#[must_use] -pub fn create_added_id(component_id: Uid) -> Id -{ - Id::new::<Added<ComponentForId>, _>(Some(component_id)) -} - -#[must_use] -pub fn create_removed_id(component_id: Uid) -> Id -{ - Id::new::<Removed<ComponentForId>, _>(Some(component_id)) -} - -pub struct TypeTransformComponentsToAddedEvents; - -impl<ComponentT: Component, Accumulator> - TupleReduceElement<Accumulator, TypeTransformComponentsToAddedEvents> for ComponentT -where - Accumulator: TupleWith<Added<Self>>, -{ - type Return = Accumulator::With; -} - -#[derive(Debug, Component)] -struct ComponentForId; diff --git a/ecs/src/event/start.rs b/ecs/src/event/start.rs deleted file mode 100644 index 248dd50..0000000 --- a/ecs/src/event/start.rs +++ /dev/null @@ -1,7 +0,0 @@ -use crate::event::Event; - -/// Start event. -#[derive(Debug, Clone, Copy)] -pub struct Start; - -impl Event for Start {} |