summaryrefslogtreecommitdiff
path: root/ecs/src/system/stateful.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/system/stateful.rs')
-rw-r--r--ecs/src/system/stateful.rs17
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);
+ }),
}
}