summaryrefslogtreecommitdiff
path: root/ecs/src/event/component.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-12-09 14:05:33 +0100
committerHampusM <hampus@hampusmat.com>2024-12-09 14:05:33 +0100
commitdcc40c9205e5f4cf484523f97eb12a561d7b2b22 (patch)
tree2908b6ca3b2fa390a45b383b91edf7a72c42ef4b /ecs/src/event/component.rs
parent158e36bf6bfcbc2ed0ffc670788ed8c0abd3f282 (diff)
refactor(ecs): use phases for system ordering
Diffstat (limited to 'ecs/src/event/component.rs')
-rw-r--r--ecs/src/event/component.rs54
1 files changed, 2 insertions, 52 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;