aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/player_service.rs
blob: 7f6c2fa0e8b9a436604aa71be5a2d8f3bb2e664e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::StaticVulkanApp;
use fparkan_runtime::{at_research_laboratory, order_lab_research, toggle_self_repair};

impl StaticVulkanApp {
    pub(super) fn handle_player_service(&mut self, clock_ms: u32) {
        let (true, Some(cockpit), Some(engine)) = (
            std::mem::take(&mut self.player_service_pressed),
            self.cockpit,
            self.mission_engine.as_mut(),
        ) else {
            return;
        };
        if self.boarded_hero_index.is_none() && at_research_laboratory(engine, cockpit) {
            match order_lab_research(engine, cockpit, clock_ms) {
                Ok((component, duration)) => {
                    eprintln!("laboratory_research_order component={component} duration_ms={duration} queue_time_ms={clock_ms}");
                }
                Err(error) => eprintln!("laboratory_research_rejected {error}"),
            }
            return;
        }
        if let Some(enabled) = toggle_self_repair(engine, cockpit) {
            eprintln!("player_self_repair enabled={enabled} queue_time_ms={clock_ms}");
            if let Some(audio) = &mut self.audio {
                let voice = if enabled {
                    "VOICE_REPAIR_SYS_ON"
                } else {
                    "VOICE_REPAIR_SYS_OFF"
                };
                if let Err(error) = audio.queue_game_voice(voice) {
                    eprintln!(
                        "sim_coverage mission_voice_unavailable=1 notice={voice} reason={error}"
                    );
                }
            }
        }
    }
}