diff options
author | HampusM <hampus@hampusmat.com> | 2024-06-16 19:30:27 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-06-16 19:51:59 +0200 |
commit | 61ce6ce0a603384b07ede2d149f6ec0542a2d03e (patch) | |
tree | 4786c775787e7fa493b7918599056c8c566981f9 /ecs/src/system | |
parent | a7c9b0a9dfe5051a60763e123df47f4c16052e32 (diff) |
fix(ecs): update archetype lookups when entity is spawned with Actions
Diffstat (limited to 'ecs/src/system')
-rw-r--r-- | ecs/src/system/stateful.rs | 17 |
1 files changed, 16 insertions, 1 deletions
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::<Self>().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); + }), } } |