use crate::model::geometry::RoomBounds;
use serde::{Deserialize, Serialize};
pub type RoomId = String;
pub type BranchId = String;
pub type RoomEdgeId = String;
pub type TemplateRef = String;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Room {
pub id: RoomId,
pub room_type: RoomType,
pub depth_from_start: u16,
pub branch_id: Option<BranchId>,
pub difficulty: u16,
pub theme_tags: Vec<String>,
pub bounds: Option<RoomBounds>,
pub template_ref: Option<TemplateRef>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub grammar_token: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum RoomType {
Start,
Combat,
Treasure,
Shop,
Elite,
Puzzle,
Safe,
Boss,
Event,
Secret,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RoomGraph {
pub nodes: Vec<Room>,
pub edges: Vec<RoomEdge>,
pub critical_path: Vec<RoomId>,
pub branches: Vec<Branch>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RoomEdge {
pub id: RoomEdgeId,
pub from_room: RoomId,
pub to_room: RoomId,
pub is_critical: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Branch {
pub id: BranchId,
pub start_room: RoomId,
pub end_room: RoomId,
pub room_ids: Vec<RoomId>,
pub purpose: BranchPurpose,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
pub enum BranchPurpose {
Reward,
Shop,
Event,
Secret,
}
pub type DoorAnchorId = String;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DoorAnchor {
pub id: DoorAnchorId,
pub room_id: RoomId,
pub edge_id: RoomEdgeId,
pub grid_pos: crate::model::geometry::GridPoint,
pub facing: crate::model::geometry::CardinalDir,
pub width_tiles: u16,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub socket_tag: Option<String>,
}
pub type CorridorId = String;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Corridor {
pub id: CorridorId,
pub from_room: RoomId,
pub to_room: RoomId,
pub from_anchor: DoorAnchorId,
pub to_anchor: DoorAnchorId,
pub width_tiles: u16,
pub path: CorridorPath,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub segment_tags: Vec<CorridorSegmentTag>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub enum CorridorPath {
Straight(Vec<crate::model::geometry::GridPoint>),
Orthogonal(Vec<crate::model::geometry::GridPoint>),
Polyline(Vec<crate::model::geometry::GridPoint>),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CorridorSegmentTag {
pub length: u16,
pub turn_type: TurnType,
pub theme: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TurnType {
Straight,
Left,
Right,
TJunction,
Cross,
}