From 69d90ece7f54996f0f51fc120a38d37717c5248e Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 8 Jun 2024 20:47:35 +0200 Subject: perf(ecs): store components using archetypes --- ecs/src/system.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ecs/src/system.rs') diff --git a/ecs/src/system.rs b/ecs/src/system.rs index 47872a6..868afa7 100644 --- a/ecs/src/system.rs +++ b/ecs/src/system.rs @@ -25,6 +25,8 @@ pub trait System<'world, Impl>: 'static #[must_use] fn initialize(self, input: Self::Input) -> Self; + fn prepare(&self, world_data: &WorldData); + fn run<'this>(&'this self, world_data: &'world WorldData) where 'this: 'world; @@ -57,6 +59,13 @@ macro_rules! impl_system { self } + fn prepare(&self, world_data: &WorldData) + { + #( + TParam~I::handle_pre_run(world_data); + )* + } + fn run<'this>(&'this self, world_data: &'world WorldData) where 'this: 'world @@ -179,6 +188,8 @@ pub unsafe trait Param<'world> fn is_compatible>() -> bool; fn get_comparable() -> Box; + + fn handle_pre_run(_world_data: &WorldData) {} } pub struct NoInitParamFlag {} -- cgit v1.2.3-18-g5258