-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Bevy version
0.15.3
What you did
I was creating a effect system that run one shot system, and can take effect as parameters to run them from that one shot system (which mean i can call the same one shot system from the same system, but it's not rly recursive)
What went wrong
I discovered that you cannot call X one shot system from the same system
Isolated minimal example
use bevy::{ecs::system::SystemId, prelude::*};
fn main() {
let mut app = App::new();
let id = app.register_system(one_shot_system);
app.add_plugins(DefaultPlugins);
app.insert_resource(TestRes {
id: id,
counter: 5
});
app.add_systems(Startup, test_startup);
app.run();
}
pub fn test_startup(mut commands: Commands, test: Res<TestRes>) {
commands.run_system(test.id);
}
#[derive(Resource)]
pub struct TestRes {
id: SystemId,
counter: u32
}
pub fn one_shot_system(mut commands: Commands, mut test: ResMut<TestRes>) {
println!("{:?}", test.counter);
test.counter = test.counter-1;
if test.counter > 0 {
commands.run_system(test.id);
}
}This only call one_shot_sytem once and the commands.run_system inside it do nothing.
Of course this is not rly my use case but it's the same bug in the end.
Apparently i can just go with observers since i was told they can recursivly call themself, which i tried to avoid since in my use case it's mean 500 entities, one for each effect), but in the end it's probably nothing and have 0 perf issue.
But i wanted to know if this was intended or not cause it's documented nowhere (or i'm blind, it's a posibility i just have reading issues).
I think this happens cause the system may be removed from the world while it's executed