Skip to main content

thedes_domain/
block.rs

1use serde::{Deserialize, Serialize};
2
3use crate::monster;
4
5#[derive(
6    Debug,
7    Clone,
8    Copy,
9    PartialEq,
10    Eq,
11    PartialOrd,
12    Ord,
13    Hash,
14    Serialize,
15    Deserialize,
16)]
17#[repr(u8)]
18pub enum Block {
19    Placeable(PlaceableBlock),
20    Special(SpecialBlock),
21}
22
23impl Default for Block {
24    fn default() -> Self {
25        Self::Placeable(PlaceableBlock::default())
26    }
27}
28
29impl From<PlaceableBlock> for Block {
30    fn from(block: PlaceableBlock) -> Self {
31        Self::Placeable(block)
32    }
33}
34
35impl From<SpecialBlock> for Block {
36    fn from(block: SpecialBlock) -> Self {
37        Self::Special(block)
38    }
39}
40
41#[derive(
42    Debug,
43    Clone,
44    Copy,
45    PartialEq,
46    Eq,
47    PartialOrd,
48    Ord,
49    Hash,
50    Default,
51    Serialize,
52    Deserialize,
53)]
54#[repr(u8)]
55pub enum PlaceableBlock {
56    #[default]
57    Air = 0,
58}
59
60#[derive(
61    Debug,
62    Clone,
63    Copy,
64    PartialEq,
65    Eq,
66    PartialOrd,
67    Ord,
68    Hash,
69    Default,
70    Serialize,
71    Deserialize,
72)]
73#[repr(u8)]
74pub enum SpecialBlock {
75    #[default]
76    Player = 0,
77    Monster(monster::Id),
78}