Split crate into shared logic library and binary crate (#52) (#53)

This commit is contained in:
extrawurst
2025-06-29 12:45:25 +02:00
committed by GitHub
parent 5d4c7630ef
commit 7996d632f7
65 changed files with 497 additions and 82 deletions

View File

@@ -0,0 +1,36 @@
use crate::{
cutscene::StartCutscene, global_observer, keys::KeyCollected, movables::TriggerMovableEvent,
sounds::PlaySound,
};
use bevy::{platform::collections::HashSet, prelude::*};
pub fn plugin(app: &mut App) {
global_observer!(app, on_key_collected);
}
fn on_key_collected(trigger: Trigger<KeyCollected>, mut commands: Commands) {
match trigger.event().0.as_str() {
"fence_gate" => {
commands.trigger(StartCutscene("fence_01".to_string()));
let entities: HashSet<_> = vec!["fence_01", "fence_02"]
.into_iter()
.map(String::from)
.collect();
commands.trigger(PlaySound::Gate);
commands.trigger(TriggerMovableEvent(entities));
}
"fence_shaft" => {
commands.trigger(StartCutscene("cutscene_02".to_string()));
let entities: HashSet<_> = vec!["fence_shaft"].into_iter().map(String::from).collect();
commands.trigger(PlaySound::Gate);
commands.trigger(TriggerMovableEvent(entities));
}
_ => {
error!("unknown key logic: {}", trigger.event().0);
}
}
}