euv_core/game/tilemap/struct.rs
1use super::*;
2
3/// Visual and physical definition for a single tile ID inside a `TileMap`.
4#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
5pub struct TilePaletteEntry {
6 /// Tile fill color.
7 #[get(type(copy))]
8 pub(crate) color: Color,
9 /// Optional inner bevel or accent color.
10 #[get(type(copy))]
11 pub(crate) border_color: Color,
12 /// Whether this tile blocks movement and collision queries.
13 #[get(type(copy))]
14 pub(crate) solid: bool,
15}
16
17/// Grid-based 2D tilemap supporting O(visible) frustum-culled rendering and tile solidity queries.
18#[derive(Clone, Data, Debug)]
19pub struct TileMap {
20 /// Grid column count.
21 #[get(type(copy))]
22 pub(crate) columns: usize,
23 /// Grid row count.
24 #[get(type(copy))]
25 pub(crate) rows: usize,
26 /// Square tile edge size in world units.
27 #[get(type(copy))]
28 pub(crate) tile_size: f32,
29 /// Flat row-major tile identifier grid (`0` = empty/air).
30 pub(crate) cells: Vec<u16>,
31 /// Palette mapping tile IDs to colors and collision flags.
32 pub(crate) palette: Vec<TilePaletteEntry>,
33}
34
35/// Sprite sheet slicing descriptor over an RGBA8 `ImageBuffer`.
36#[derive(Clone, Data, Debug)]
37pub struct SpriteSheet {
38 /// Source RGBA8 sprite sheet texture.
39 pub(crate) texture: ImageBuffer,
40 /// Individual frame width in pixels.
41 #[get(type(copy))]
42 pub(crate) frame_width: u32,
43 /// Individual frame height in pixels.
44 #[get(type(copy))]
45 pub(crate) frame_height: u32,
46 /// Number of frame columns in the sheet.
47 #[get(type(copy))]
48 pub(crate) columns: u32,
49}
50
51/// Frame-rate-driven sprite animation clip state.
52#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
53pub struct SpriteAnimator {
54 /// Starting frame index in the sprite sheet.
55 #[get(type(copy))]
56 pub(crate) start_frame: u32,
57 /// Total frame count in this clip.
58 #[get(type(copy))]
59 pub(crate) frame_count: u32,
60 /// Playback cadence in frames per second.
61 #[get(type(copy))]
62 pub(crate) fps: f32,
63 /// Whether playback wraps continuously.
64 #[get(type(copy))]
65 pub(crate) looping: bool,
66 /// Elapsed clip playback time in seconds.
67 #[get(type(copy))]
68 pub(crate) elapsed_secs: f32,
69}