fantasy_craft/core/
plugins.rs1use crate::{audio::plugin::AudioPlugin, core::{app::App, event::EventBus, time::DeltaTime}, hierarchy::plugins::HierarchyPlugin, input::plugin::InputPlugin, prelude::{AnimationPlugin, Camera2dPlugin, GameState, GuiPlugin, PhysicsPlugin, Stage, System, TiledMapPlugin, collider_debug_render_system}, utils::plugins::UtilsPlugin};
2
3pub trait Plugin {
4 fn build(&self, app: &mut App);
5}
6
7pub struct Default2dPlugin;
8
9impl Plugin for Default2dPlugin {
10 fn build(&self, app: &mut App) {
11 app.context.insert_resource(EventBus::new());
12 app.context.insert_resource(DeltaTime(0.0));
13
14 app
15 .add_plugin(UtilsPlugin)
16 .add_plugin(PhysicsPlugin)
17 .add_plugin(Camera2dPlugin)
18 .add_plugin(HierarchyPlugin)
19 .add_plugin(TiledMapPlugin)
20 .add_plugin(AnimationPlugin)
21 .add_plugin(GuiPlugin)
22 .add_plugin(AudioPlugin)
23 .add_plugin(InputPlugin);
24 }
25}
26
27pub struct DebugPlugin;
28
29impl Plugin for DebugPlugin {
30 fn build(&self, app: &mut App) {
31 app
32 .add_system(Stage::PostRender, System::new(
33 collider_debug_render_system,
34 vec![GameState::Playing]
35 ));
36 }
37}