pub mod tiledb_edit_ui; use std::{fmt::Debug, marker::PhantomData, ops::Index}; use egui_inspect::{derive::Inspect, Inspect}; use serde::{Deserialize, Serialize}; use crate::{math::TILE_SIZE, texture_atlas::RectMap}; #[derive(Inspect, PartialEq, Eq)] pub struct TileId(pub u16, PhantomData); impl Copy for TileId {} impl Clone for TileId { fn clone(&self) -> Self { Self(self.0, PhantomData) } } impl Debug for TileId { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { loop {} } } impl TileId { pub fn empty(&self) -> bool { loop {} } pub const EMPTY: Self = Self(0, PhantomData); } #[derive(Debug)] pub enum Bg {} #[derive(Debug)] pub enum Mid {} #[derive(Debug)] pub enum Fg {} impl Bg { pub fn unknown_def() -> TileDef { loop {} } } impl Mid { pub fn unknown_def() -> TileDef { loop {} } } impl Fg { pub fn unknown_def() -> TileDef { loop {} } } pub trait TileLayer { /// Definitions specific to this layer type SpecificDef; } impl TileLayer for Bg { type SpecificDef = (); } impl TileLayer for Mid { type SpecificDef = MidDef; } impl TileLayer for Fg { type SpecificDef = (); } pub type BgTileId = TileId; pub type MidTileId = TileId; pub type FgTileId = TileId; impl BgTileId { pub const DIRT: Self = Self(1, PhantomData); pub const STONE: Self = Self(2, PhantomData); } impl MidTileId { pub const DIRT: Self = Self(1, PhantomData); pub const STONE: Self = Self(2, PhantomData); pub const TORCH: Self = Self(3, PhantomData); pub const PLATFORM: Self = Self(4, PhantomData); pub const PANZERIUM: Self = Self(5, PhantomData); pub const UNBREAKANIUM: Self = Self(6, PhantomData); } impl FgTileId { pub const COAL: Self = Self(1, PhantomData); } #[derive(Serialize, Deserialize, Inspect)] pub struct TileDef where Layer::SpecificDef: Debug + Inspect, { /// Whether the tile emits light, and the light source offset pub layer: Layer::SpecificDef, //ADD pub blend_graphic: String, } #[derive(Debug, Inspect, Default, Serialize, Deserialize)] pub struct MidDef { /// Platform behavior: Horizontally passable, vertically passable upwards pub platform: bool, /// Collision bounding box pub bb: Option, } impl Debug for TileDef where Layer::SpecificDef: Debug + Inspect, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { loop {} } } impl Default for TileDef where Layer::SpecificDef: Default + Debug + Inspect, { fn default() -> Self { loop {} } } const DEFAULT_TILE_BB: TileBb = TileBb { x: 0, y: 0, w: TILE_SIZE, h: TILE_SIZE, }; #[derive(Serialize, Deserialize, Debug, Inspect, Clone, Copy)] pub struct TileBb { pub x: u8, pub y: u8, pub w: u8, pub h: u8, } #[derive(Serialize, Deserialize, Debug, Inspect)] pub struct TileDb { unknown_bg: TileDef, unknown_mid: TileDef, unknown_fg: TileDef, bg: Vec>, mid: Vec>, fg: Vec>, } impl Default for TileDb { fn default() -> Self { loop {} } } impl Index for TileDb { type Output = TileDef; fn index(&self, index: BgTileId) -> &Self::Output { loop {} } } impl Index for TileDb { type Output = TileDef; fn index(&self, index: MidTileId) -> &Self::Output { loop {} } } impl Index for TileDb { type Output = TileDef; fn index(&self, index: FgTileId) -> &Self::Output { loop {} } } const PATH: &str = "tiles.dat"; impl TileDb { pub fn load_or_default() -> Self { loop {} } pub fn try_save(&self) { loop {} } pub(crate) fn update_rects(&mut self, rects: &RectMap) { loop {} } } fn update_rect_db(db: &mut Vec>, rects: &RectMap) where Layer::SpecificDef: Debug + Inspect, { loop {} }