dotzuki_engine/lib.rs
1//! # dotzuki-engine
2//!
3//! Core trait definitions for a JRPG engine framework.
4//!
5//! This crate defines the foundational abstractions that any JRPG engine
6//! implementation must provide. It has **zero dependency** on specific game
7//! data — all types are generic associated types or marker traits that
8//! the implementing crate supplies.
9//!
10//! ## Design Philosophy
11//!
12//! The traits in this crate follow these principles:
13//!
14//! - **Generic over game data**: No concrete game-specific, item, or move types.
15//! All identifiers are associated types bounded by `Copy + Eq + Hash + Debug`.
16//! - **Provider pattern**: Data providers (tilesets, maps, palettes, tile
17//! metadata, render data) are obtained through a single `GameData` master
18//! trait, enabling dependency injection and testing.
19//! - **No I/O, no platform**: This crate contains only trait definitions
20//! and simple data types. No file loading, no GPU code, no platform calls.
21//!
22//! ## Modules
23//!
24//! | Module | Contents |
25//! |--------|----------|
26//! | [`tileset`] | `TilesetTrait` and `TilesetProvider` — tileset loading and querying |
27//! | [`tile_meta`] | `CollisionType`, `TileMetaTrait`, `TileMetadata` — collision and terrain |
28//! | [`tilemap`] | `TilemapEntry`, `Tilemap` — 16-bit tilemap with per-tile metadata |
29//! | [`map`] | `MapTrait`, `MapProvider`, `MapConnection` — map data and connections |
30//! | [`palette`] | `PaletteTrait`, `PaletteProvider` — colour palette lookups |
31//! | [`render_data`] | `RenderData` — display-name and metadata lookups for moves, items, species |
32//! | [`save`] | `SaveData`, `SaveManager`, `SaveStorage`, `SaveError` — save/load with CRC16 |
33//! | [`link`] | `NetworkTransport<M>`, `TransportError`, `ChannelTransport<M>`, `LinkRole` — game-agnostic link-play transport seam (zero-I/O) |
34
35pub mod battle;
36pub mod camera;
37pub mod items;
38pub mod link;
39pub mod map;
40pub mod menu;
41pub mod metatile;
42pub mod overworld;
43pub mod palette;
44pub mod party;
45pub mod render;
46pub mod render_config;
47pub mod render_data;
48pub mod save;
49pub mod tile_meta;
50pub mod tilemap;
51pub mod text;
52pub mod tileset;
53pub mod trigger_manager;
54
55use std::fmt::Debug;
56use std::hash::Hash;
57
58/// Master trait that provides access to all game data subsystems.
59///
60/// `GameData` is the central dependency-injection point for the engine.
61/// Implementations supply concrete types for tilesets, maps, palettes,
62/// tile metadata, moves, items, and species, along with provider objects
63/// that serve the corresponding data.
64///
65/// # Type Parameters
66///
67/// * `Tileset` — A [`TilesetTrait`](tileset::TilesetTrait) implementation
68/// (typically an enum of tileset IDs).
69/// * `Map` — A [`MapTrait`](map::MapTrait) implementation (typically an
70/// enum of map IDs).
71/// * `Palette` — A [`PaletteTrait`](palette::PaletteTrait) implementation
72/// (typically an enum of palette IDs).
73/// * `TileMeta` — A [`TileMetaTrait`](tile_meta::TileMetaTrait) implementation
74/// for tile collision lookups.
75/// * `Move` — The move/ability ID type (`Copy + Eq + Hash + Debug`).
76/// * `Item` — The item ID type (`Copy + Eq + Hash + Debug`).
77/// * `Species` — The species/monster ID type (`Copy + Eq + Hash + Debug`).
78///
79/// # Example
80///
81/// ```ignore
82/// struct MonsterGameData;
83///
84/// impl GameData for MonsterGameData {
85/// type Tileset = TilesetId;
86/// type Map = MapId;
87/// type Palette = PaletteId;
88/// type TileMeta = TileMetaId;
89/// type Move = MoveId;
90/// type Item = ItemId;
91/// type Species = SpeciesId;
92///
93/// fn tileset_provider(&self) -> &dyn TilesetProvider<Self::Tileset> {
94/// &MY_TILESET_PROVIDER
95/// }
96/// // ... etc
97/// }
98/// ```
99pub trait GameData {
100 /// The tileset identifier type.
101 type Tileset: tileset::TilesetTrait;
102
103 /// The map identifier type.
104 type Map: map::MapTrait;
105
106 /// The palette identifier type.
107 type Palette: palette::PaletteTrait;
108
109 /// The tile metadata identifier type.
110 type TileMeta: tile_meta::TileMetaTrait;
111
112 /// The move (ability/skill) identifier type.
113 type Move: Copy + Eq + Hash + Debug;
114
115 /// The item identifier type.
116 type Item: Copy + Eq + Hash + Debug;
117
118 /// The species (monster/character) identifier type.
119 type Species: Copy + Eq + Hash + Debug;
120
121 /// Returns a reference to the tileset data provider.
122 fn tileset_provider(&self) -> &dyn tileset::TilesetProvider<Self::Tileset>;
123
124 /// Returns a reference to the map data provider.
125 fn map_provider(&self) -> &dyn map::MapProvider<Self::Map>;
126
127 /// Returns a reference to the palette data provider.
128 fn palette_provider(&self) -> &dyn palette::PaletteProvider<Self::Palette>;
129
130 /// Returns a reference to the tile metadata provider.
131 fn tile_metadata(&self) -> &dyn tile_meta::TileMetadata<Self::TileMeta>;
132
133 /// Returns a reference to the render data provider.
134 fn render_data(
135 &self,
136 ) -> &dyn render_data::RenderData<Move = Self::Move, Item = Self::Item, Species = Self::Species>;
137}