From dcc40c9205e5f4cf484523f97eb12a561d7b2b22 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 9 Dec 2024 14:05:33 +0100 Subject: refactor(ecs): use phases for system ordering --- ecs/src/event/component.rs | 54 ++-------------------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) (limited to 'ecs/src/event/component.rs') 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 where ComponentT: Component, @@ -43,19 +41,8 @@ where } } -impl Event for Added -where - ComponentT: Component, -{ - fn id() -> Id - where - Self: Sized, - { - Id::new::, _>(Some(ComponentT::id())) - } -} - /// Event emitted when a `ComponentT` component is removed from a entity. +#[derive(Clone, Component)] pub struct Removed where ComponentT: Component, @@ -85,40 +72,3 @@ where Self { _pd: PhantomData } } } - -impl Event for Removed -where - ComponentT: Component, -{ - fn id() -> Id - where - Self: Sized, - { - Id::new::, _>(Some(ComponentT::id())) - } -} - -#[must_use] -pub fn create_added_id(component_id: Uid) -> Id -{ - Id::new::, _>(Some(component_id)) -} - -#[must_use] -pub fn create_removed_id(component_id: Uid) -> Id -{ - Id::new::, _>(Some(component_id)) -} - -pub struct TypeTransformComponentsToAddedEvents; - -impl - TupleReduceElement for ComponentT -where - Accumulator: TupleWith>, -{ - type Return = Accumulator::With; -} - -#[derive(Debug, Component)] -struct ComponentForId; -- cgit v1.2.3-18-g5258