~starkingdoms/starkingdoms

ref: 93b350fc44934524b95c9f80884d921c53fe7981 starkingdoms/crates/server/src/crafting/components.rs -rw-r--r-- 1.5 KiB
93b350fc — ghostly_zsh chassis change merge 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use std::collections::HashMap;

use bevy::prelude::Component;
use starkingdoms_common::PlanetType;

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum MaterialType {
    Plasma,    // Sun
    Composite, // Mercury
    Sulfur,    // Venus
    Silicon,   // Moon
    Iron,      // Mars
    Hydrogen,  // Jupiter
    Helium,    // Saturn
    Rubber,    // Uranus
    Methane,   // Neptune
    Ice,       // Pluto
}
impl TryFrom<PlanetType> for MaterialType {
    type Error = ();
    fn try_from(value: PlanetType) -> Result<Self, ()> {
        match value {
            PlanetType::Sun => Ok(Self::Plasma),
            PlanetType::Mercury => Ok(Self::Composite),
            PlanetType::Venus => Ok(Self::Sulfur),
            PlanetType::Moon => Ok(Self::Silicon),
            PlanetType::Mars => Ok(Self::Iron),
            PlanetType::Jupiter => Ok(Self::Hydrogen),
            PlanetType::Saturn => Ok(Self::Helium),
            PlanetType::Uranus => Ok(Self::Rubber),
            PlanetType::Neptune => Ok(Self::Methane),
            PlanetType::Pluto => Ok(Self::Ice),
            _ => Err(()),
        }
    }
}

#[derive(Component, Debug, Clone)]
pub struct MaterialStorage {
    pub material_type: MaterialType,
    pub stored: u32,
    pub capacity: u32,
}

#[derive(Component, Debug, Clone, Default)]
pub struct VarietyMaterialStorage {
    pub materials: HashMap<MaterialType, u32>,
    pub capacity: u32,
}

#[derive(Component, Debug, Clone, Default)]
pub struct IsMining(pub bool);