diff options
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r-- | ecs/src/component.rs | 28 |
1 files changed, 25 insertions, 3 deletions
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<Metadata>; + fn added_event_ids() -> Vec<Uid>; + + fn removed_event_ids() -> Vec<Uid>; + fn from_components_mut<'component>( components: impl Iterator<Item = &'component EntityComponent>, 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<Uid> + { + vec![ + #(ComponentAddedEvent::<Comp~I>::id(),)* + ] + } + + fn removed_event_ids() -> Vec<Uid> + { + vec![ + #(ComponentRemovedEvent::<Comp~I>::id(),)* + ] + } + fn from_components_mut<'component>( components: impl Iterator<Item = &'component EntityComponent>, world: &'component World, |