summaryrefslogtreecommitdiff
path: root/ecs/src/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/component.rs
parent158e36bf6bfcbc2ed0ffc670788ed8c0abd3f282 (diff)
refactor(ecs): use phases for system ordering
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r--ecs/src/component.rs28
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,