ashscript_types/
objects.rs

1use enum_dispatch::enum_dispatch;
2use hexx::Hex;
3use serde::Serialize;
4use uuid::Uuid;
5
6use crate::{storage::Storage, structures::{factory::Factory, turret::Turret}, unit::Unit};
7
8pub trait HasHex {
9    fn hex(&self) -> Hex;
10}
11
12pub trait HasHealth {
13    fn health(&self) -> u32;
14}
15
16#[derive(Clone, Copy)]
17pub enum Attackable {
18    Unit,
19    Turret,
20    Factory,
21}
22
23pub trait HasId {
24    fn id(&self) -> Uuid;
25}
26
27pub trait HasStorage {
28    fn storage(&self) -> &Storage;
29}
30
31#[derive(Clone, Copy)]
32pub enum WithStorage {
33    Unit,
34    Turret,
35    Factory,
36}
37
38/* pub enum GameObject<'a> {
39    Unit(&'a Unit),
40    Turret(&'a Turret),
41    Factory(&'a Factory),
42}
43
44pub enum GameObjectMut<'a> {
45    Unit(&'a mut Unit),
46    Turret(&'a mut Turret),
47    Factory(&'a mut Factory),
48} */
49
50/// Each type has its own storage inside of a chunk, and cannot share a hex/tile with another of its own type (ex: two units cannot be on the same tile)
51/// Not exactly sure if this is useful anywhere
52#[derive(Serialize, Clone, Copy, Default, Eq, PartialEq, Hash)]
53pub enum GameObjectKind {
54    Unit,
55    Turret,
56    Factory,
57    #[default]
58    Unknown,
59}
60
61/* pub struct Identifier {
62    pub hex: Hex,
63    pub kind: GameObjectKind,
64} */