#[path = "danmaku/components.rs"]
mod components;
#[path = "danmaku/patterns.rs"]
mod patterns;
#[path = "danmaku/systems.rs"]
mod systems;
#[path = "danmaku/target.rs"]
mod target;
pub use components::*;
pub use patterns::*;
pub use systems::*;
pub use target::*;
use bevy::asset::AssetApp;
use bevy::prelude::*;
use crate::core::ron_loader::RonAssetLoader;
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
pub struct DanmakuUpdate;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum DanmakuActiveState {
#[default]
Battle,
Overworld,
}
#[derive(Resource, Debug, Clone, Default)]
pub struct DanmakuSpawnContext {
pub state: DanmakuActiveState,
}
impl DanmakuSpawnContext {
pub fn battle() -> Self {
Self {
state: DanmakuActiveState::Battle,
}
}
pub fn overworld() -> Self {
Self {
state: DanmakuActiveState::Overworld,
}
}
}
pub struct CoreDanmakuPlugin;
impl Plugin for CoreDanmakuPlugin {
fn build(&self, app: &mut App) {
app.init_asset::<DanmakuPerformance>()
.register_asset_loader(RonAssetLoader::<DanmakuPerformance>::new(&[
"performance.ron",
"danmaku.ron",
]))
.init_resource::<PendingPerformanceLoads>()
.init_resource::<DanmakuSpawnContext>()
.add_message::<PlayPerformanceEvent>()
.add_systems(
Update,
(
process_play_performance_events,
spawn_performance_players,
advance_performance_timeline,
update_bullet_motion,
update_bullet_lifetime,
cleanup_dead_bullets,
)
.chain()
.in_set(DanmakuUpdate),
);
}
}