summaryrefslogtreecommitdiff
path: root/ecs/src/component.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-08-01 16:11:15 +0200
committerHampusM <hampus@hampusmat.com>2024-08-02 15:34:54 +0200
commitfd42ca5a25f8bab3ea66252f8bc0db02604f70dd (patch)
tree6d384b5f462e2699342372f6b56791fc4607e9c6 /ecs/src/component.rs
parent70c7d745f918dd23343599963a619539f4f880cb (diff)
feat(ecs): add relationships
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r--ecs/src/component.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/ecs/src/component.rs b/ecs/src/component.rs
index 67ae453..057b5ff 100644
--- a/ecs/src/component.rs
+++ b/ecs/src/component.rs
@@ -6,7 +6,7 @@ use seq_macro::seq;
use crate::lock::WriteGuard;
use crate::system::{ComponentRefMut, Input as SystemInput};
use crate::type_name::TypeName;
-use crate::EntityComponent;
+use crate::{EntityComponent, WorldData};
pub mod local;
@@ -36,6 +36,12 @@ pub trait Component: SystemInput + Any + TypeName
{
false
}
+
+ fn prepare(_world_data: &WorldData)
+ where
+ Self: Sized,
+ {
+ }
}
impl dyn Component
@@ -144,6 +150,8 @@ pub trait Sequence
fn from_components<'component>(
components: impl Iterator<Item = &'component EntityComponent>,
) -> Self::Refs<'component>;
+
+ fn prepare(_world_data: &WorldData);
}
/// [`Component`] metadata.
@@ -254,6 +262,13 @@ macro_rules! inner {
Comp~I::RefMut::from_optional_component(comp_~I),
)*)
}
+
+ fn prepare(world_data: &WorldData)
+ {
+ #(
+ Comp~I::prepare(world_data);
+ )*
+ }
}
});
};