From 61ce6ce0a603384b07ede2d149f6ec0542a2d03e Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 16 Jun 2024 19:30:27 +0200 Subject: fix(ecs): update archetype lookups when entity is spawned with Actions --- ecs/src/system/stateful.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'ecs/src/system/stateful.rs') diff --git a/ecs/src/system/stateful.rs b/ecs/src/system/stateful.rs index ae6a5b5..49fd3bf 100644 --- a/ecs/src/system/stateful.rs +++ b/ecs/src/system/stateful.rs @@ -111,7 +111,7 @@ macro_rules! impl_system { { TypeErased { data: Box::new(self), - func: Box::new(|data, world_data| { + run: Box::new(|data, world_data| { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct let data = unsafe { &*(data as *const dyn Any) }; @@ -126,6 +126,21 @@ macro_rules! impl_system { me.run(world_data); }), + prepare: Box::new(|data, world_data| { + // SAFETY: The caller of TypeErased::run ensures the lifetime + // is correct + let data = unsafe { &*(data as *const dyn Any) }; + + let me = data.downcast_ref::().unwrap(); + + // SAFETY: The caller of TypeErased::run ensures the lifetime + // is correct + let world_data = unsafe { + &*(world_data as *const WorldData) + }; + + me.prepare(world_data); + }), } } -- cgit v1.2.3-18-g5258