Expand wire protocol with version field, GameTime (day/phase/paused), FacingDirection (8-directional), VisibleTile, VisibilitySector (Forward/Peripheral), and visibility tag on VisibleEntity. Regenerate all msgpack fixtures for client compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,21 +1,86 @@
|
||||
// Bridge type definitions
|
||||
// ObserverSnapshot: data crossing the client-server boundary
|
||||
// Bridge type definitions — v2 (Sprint 2: See)
|
||||
// ObserverSnapshot: data crossing the client-server boundary (D-020)
|
||||
// PlayerInput: semantic actions from client
|
||||
|
||||
use bevy_ecs::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use crate::simulation::time::DayPhase;
|
||||
|
||||
/// The ONLY data structure crossing the client-server boundary (D-020)
|
||||
/// Contains all information visible to the observer at a given tick.
|
||||
///
|
||||
/// TODO: Planned fields — fog/visibility data, ambient sound events,
|
||||
/// internal monologue triggers, HUD state (D-020 expansion).
|
||||
/// v2 adds: game_time, player_facing, visible_tiles, visibility sectors.
|
||||
/// Future fields: ambient sound events, internal monologue triggers,
|
||||
/// HUD state (D-020 expansion).
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ObserverSnapshot {
|
||||
/// Protocol version for forward compatibility. Current: 2.
|
||||
pub version: u8,
|
||||
/// Simulation tick when this snapshot was produced
|
||||
pub tick: u64,
|
||||
/// All entities visible to the observer
|
||||
/// Game time data for client HUD display (D-031)
|
||||
pub game_time: GameTime,
|
||||
/// Player character's facing direction for vision cone (D-015)
|
||||
pub player_facing: FacingDirection,
|
||||
/// All entities visible to the observer (filtered by LOS + vision cone)
|
||||
pub entities: Vec<VisibleEntity>,
|
||||
/// Tiles visible to the observer for fog rendering
|
||||
pub visible_tiles: Vec<VisibleTile>,
|
||||
}
|
||||
|
||||
/// Game time data for client display (D-031)
|
||||
/// 10 ticks = 1 game-minute, 4 day phases of 360 minutes each.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct GameTime {
|
||||
/// Current day (0-indexed)
|
||||
pub day: u64,
|
||||
/// Time of day in game-minutes (0..1439)
|
||||
pub time_of_day: u64,
|
||||
/// Current day phase (Morning/Afternoon/Evening/Night)
|
||||
pub day_phase: DayPhase,
|
||||
/// Whether simulation is paused
|
||||
pub paused: bool,
|
||||
}
|
||||
|
||||
/// 8-directional facing direction, matching movement system.
|
||||
/// Used for vision cone computation (D-015) and snapshot wire format.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum FacingDirection {
|
||||
North,
|
||||
Northeast,
|
||||
East,
|
||||
Southeast,
|
||||
South,
|
||||
Southwest,
|
||||
West,
|
||||
Northwest,
|
||||
}
|
||||
|
||||
impl Default for FacingDirection {
|
||||
fn default() -> Self {
|
||||
FacingDirection::North
|
||||
}
|
||||
}
|
||||
|
||||
/// A tile visible to the observer with its visibility quality
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct VisibleTile {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub z: i32,
|
||||
/// Which vision cone sector this tile falls in (D-015)
|
||||
pub visibility: VisibilitySector,
|
||||
}
|
||||
|
||||
/// Vision cone sectors per D-015.
|
||||
/// Behind = not visible at all (tile absent from visible_tiles list).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum VisibilitySector {
|
||||
/// Full LOS, full detail (forward arc)
|
||||
Forward,
|
||||
/// Reduced range, dimmer rendering (side arcs)
|
||||
Peripheral,
|
||||
}
|
||||
|
||||
/// A visible entity in the simulation
|
||||
@@ -28,10 +93,12 @@ pub struct VisibleEntity {
|
||||
pub y: f32,
|
||||
pub z: i32,
|
||||
pub kind: EntityKind,
|
||||
/// Which vision cone sector this entity falls in (D-015)
|
||||
pub visibility: VisibilitySector,
|
||||
}
|
||||
|
||||
/// Category of visible entity
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum EntityKind {
|
||||
Player,
|
||||
Npc,
|
||||
|
||||
Reference in New Issue
Block a user