fly_b/simul/
plane.rs

1//! Encapsulates the logic behind the plane that is traversed by the in-game hero.
2
3pub mod res;
4pub mod sector;
5pub mod sys;
6pub mod err {
7    pub use super::res::plane::err::{NotSpawned, SectorXMissing};
8}
9
10use bevy::prelude::*;
11
12/// Provides the simulation plane with all strictly embeded objects.
13#[derive(Default)]
14pub struct SimulPlanePlugin {
15    _future_priv_fields: (),
16}
17impl Plugin for SimulPlanePlugin {
18    fn build(&self, app: &mut App) {
19        app.insert_resource(crate::SimulPlane::new_open());
20
21        // CRUD-C: Startup
22        app.add_systems(
23            OnEnter(crate::SimulState::Startup),
24            (sys::reset_logical_plane, crate::SimulPlane::spawn).chain(),
25        );
26        // CRUD-U: Update
27        app.add_systems(
28            Update,
29            (sys::advance,).run_if(crate::SimulState::is_running_cond()),
30        );
31        // CRUD-D: Cleanup
32        app.add_systems(
33            OnEnter(crate::SimulState::Cleanup),
34            crate::SimulPlane::despawn,
35        );
36        // CRUD-D: App exit
37        app.add_systems(Update, (sys::run_special_drop_of_sects,));
38    }
39}