flatland-play-loop 0.2.8

Engine-agnostic Flatland3 play session frame logic (gfx client)
Documentation
//! Client-local play state (not mirrored from server).

use flatland_client_ui::{HudViewMode, MapTargetState, MovementState};

use crate::chat::ChatSession;

#[derive(Debug)]
pub struct PlayLocalState {
    pub movement: MovementState,
    pub map_target: MapTargetState,
    pub auto_nav_goal: Option<(f32, f32)>,
    pub chat: ChatSession,
    pub hud_view: HudViewMode,
    pub mouse_hover: Option<(f32, f32)>,
    pub was_harvesting: bool,
}

impl PlayLocalState {
    pub fn new(keys: flatland_client_lib::ClientKeyBindings) -> Self {
        Self {
            movement: MovementState::with_keys(keys),
            map_target: MapTargetState::default(),
            auto_nav_goal: None,
            chat: ChatSession::default(),
            hud_view: HudViewMode::default(),
            mouse_hover: None,
            was_harvesting: false,
        }
    }

    pub fn cycle_hud_view(&mut self) {
        self.hud_view = self.hud_view.cycle();
    }

    pub fn clear_nav(&mut self) {
        self.map_target.deactivate();
        self.auto_nav_goal = None;
        self.movement.reset();
    }
}