Generating a system from a closure taking an arbitrary SystemParam #19582
Unanswered
Strackeror
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The type that a system is passed is actually not app.add_systems(Update, move |mut param: P::Item<'_, '_>| { not sure that is valid rust. For a normal function this would look something like: fn apply_damage<S: SystemParam>(mut param: S::Item<'_, '_>)
where
for<'w, 's> S::Item<'w, 's>: GetDamage,
{
param.apply_damage();
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there !
I'm having trouble finding a way to write a function that would build a system from a custom closure, that closure taking an arbitrary SystemParam.
think something like this:
this would mean that the 'Total' resource would increment by 3 each update, as the closure is run for all elements of
vec![1,2]
on each run of the system.I'm having trouble landing on bounds for
P
andF
to make this function compile in some way. I can kinda make it work by making the closure take aStaticSystemParam<P>
but that's very clunky to actually use.This is currently mostly a thought experiment, to see if I can simplify a pattern in my codebase that I'm seeing repeated a lot, of which this is a simplified version.
Beta Was this translation helpful? Give feedback.
All reactions