Extent system interface

This commit is contained in:
hodasemi 2025-04-10 12:08:16 +02:00
parent e92cd4e46e
commit 467207af21
3 changed files with 17 additions and 4 deletions

View file

@ -292,4 +292,4 @@ impl_update_filter!(Nonuple, [R, r], [S, s], [T, t], [U, u], [V, v], [W, w],
#[rustfmt::skip] #[rustfmt::skip]
impl_update_filter!(Decuple, [R, r], [S, s], [T, t], [U, u], [V, v], [W, w], [X, x], [Y, y], [Z, z], [A, a]); impl_update_filter!(Decuple, [R, r], [S, s], [T, t], [U, u], [V, v], [W, w], [X, x], [Y, y], [Z, z], [A, a]);
implement_updates!(5, 6); implement_updates!(2, 2);

View file

@ -10,7 +10,7 @@ use utilities::prelude::{remove_life_time, remove_life_time_mut};
use crate::{entity_object_manager::EntityObjectManager, *}; use crate::{entity_object_manager::EntityObjectManager, *};
pub trait AddSystem<R, Func> { pub trait AddSystem<R, Func, W> {
fn add_system(&mut self, priority: u32, f: Func); fn add_system(&mut self, priority: u32, f: Func);
} }

View file

@ -351,7 +351,7 @@ impl Update {
} }
} }
impl<Func, #resource_type_impls> AddSystem<#resource_types, Func> for WorldBuilder impl<Func, #resource_type_impls> AddSystem<#resource_types, Func, ()> for WorldBuilder
where where
Func: Fn(&mut Commands, #resources ) -> Result<bool> + Send + Sync + 'static, Func: Fn(&mut Commands, #resources ) -> Result<bool> + Send + Sync + 'static,
#reource_requirement #reource_requirement
@ -365,7 +365,20 @@ impl Update {
} }
} }
impl<Func, #resource_type_impls> AddSystem<#resource_types, Func, World> for WorldBuilder
where
Func: Fn(&World, &mut Commands, #resources ) -> Result<bool> + Send + Sync + 'static,
#reource_requirement
{
fn add_system(&mut self, priority: u32, func: Func) {
self.systems.push((priority, Box::new(move |world: &mut World, commands: &mut Commands| {
let w = unsafe { utilities::unsafe_life_time::remove_life_time(world) };
#resource_store
func(w, commands, #( #resource_idents, )*)
})));
self.systems.sort_by_key(|(priority, _)| *priority);
}
}
} }
} }
} }