//! Docked state management.
//!
//! Tracks the player's current docking status and the station they're docked at.

use bevy::prelude::*;

/// Tracks the player's docked state within a system.
#[derive(Resource, Debug, Clone, Default)]
pub struct DockedState {
    /// The entity ID of the station the player is docked at.
    pub station_entity: Option<Entity>,
    /// The ID of the system the player is in.
    pub system_id: String,
    /// Whether the player is currently docked.
    pub is_docked: bool,
}

impl DockedState {
    /// Create a new docked state for the given system.
    pub fn new(system_id: String) -> Self {
        Self {
            station_entity: None,
            system_id,
            is_docked: true,
        }
    }

    /// Dock at a specific station.
    pub fn dock_at(&mut self, station: Entity) {
        self.station_entity = Some(station);
        self.is_docked = true;
    }

    /// Undock from the current station.
    pub fn undock(&mut self) {
        self.station_entity = None;
        self.is_docked = false;
    }
}

/// Event fired when the player undocks from a station.
#[derive(Event, Debug, Clone)]
pub struct UndockEvent {
    /// The station entity the player is undocking from.
    pub station_entity: Entity,
}
