use bevy::{
    diagnostic::FrameTimeDiagnosticsPlugin,
    prelude::{App, IntoSystemDescriptor, Plugin},
};
use bevy_rapier3d::prelude::{NoUserData, RapierPhysicsPlugin};

mod components;
mod systems;

pub use components::*;
use systems::*;

pub struct CyberActionPlugin;
impl Plugin for CyberActionPlugin {
    fn build(&self, app: &mut App) {
        app.init_resource::<MovementSettings>()
            .register_type::<MovementSettings>()
            .init_resource::<CatControllerSettings>()
            .init_resource::<ActionDebugInstant>()
            .register_type::<CatControllerSettings>()
            .add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
            .add_plugin(FrameTimeDiagnosticsPlugin::default())
            .add_startup_system(zero_gravity)
            .add_system(surface_fix.label("surface_fix"))
            .add_system(gravity.before("cat"))
            .add_system(falling_cat.label("cat"))
            .add_system(input_forces.label("iforces").after("cat"))
            .add_system(
                tunnel_out
                    .label("tunnel")
                    .before("surface_fix")
                    .after("drag"),
            )
            .add_system(surface_fix.label("surface_fix").after("cat"))
            .add_system(drag.label("drag").after("iforces"));
    }
}
