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/component.rs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'ecs/src/component.rs') diff --git a/ecs/src/component.rs b/ecs/src/component.rs index a9894b7..0f64695 100644 --- a/ecs/src/component.rs +++ b/ecs/src/component.rs @@ -3,6 +3,10 @@ use std::fmt::Debug; use seq_macro::seq; +use crate::event::component::{ + Added as ComponentAddedEvent, + Removed as ComponentRemovedEvent, +}; use crate::lock::{ReadGuard, WriteGuard}; use crate::system::{ComponentRef, ComponentRefMut, Input as SystemInput}; use crate::type_name::TypeName; @@ -20,11 +24,11 @@ pub trait Component: SystemInput + Any + TypeName where Self: Sized; - type RefMut<'component> + type RefMut<'component>: FromOptionalMut<'component> where Self: Sized; - type Ref<'component> + type Ref<'component>: FromOptional<'component> where Self: Sized; @@ -159,6 +163,10 @@ pub trait Sequence fn metadata() -> Vec; + fn added_event_ids() -> Vec; + + fn removed_event_ids() -> Vec; + fn from_components_mut<'component>( components: impl Iterator, world: &'component World, @@ -265,12 +273,26 @@ macro_rules! inner { #( Metadata { id: Comp~I::id(), - is_optional: Comp~I::is_optional() + is_optional: Comp~I::is_optional(), }, )* ] } + fn added_event_ids() -> Vec + { + vec![ + #(ComponentAddedEvent::::id(),)* + ] + } + + fn removed_event_ids() -> Vec + { + vec![ + #(ComponentRemovedEvent::::id(),)* + ] + } + fn from_components_mut<'component>( components: impl Iterator, world: &'component World, -- cgit v1.2.3-18-g5258