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
//! Population-related components.

use derive_new::new;
use getset::Getters;
use legion::Entity;
use smallvec::SmallVec;

use crate::def::building::storage::population as storage;
use crate::SetupEcs;

/// List of population storages in a node.
///
/// This component is applied on all nodes.
#[derive(Debug, Getters)]
pub struct StorageList {
    /// The entities containing the Storage.
    #[getset(get = "pub")]
    storages: SmallVec<[Entity; 2]>, // usually only 2 storages, "transit" and "operator".
}

/// A storage of population.
#[derive(Getters, new)]
pub struct Storage {
    /// The capacity of the storage.
    #[getset(get = "pub")]
    capacity: u32,
}

codegen::component_depends! {
    Storage = (
        Storage,
    ) + ?()
}

/// Copmonent applied on nodes to indicate housing provision.
#[derive(new, getset::CopyGetters)]
pub struct Housing {
    /// The population storage used as housing.
    #[getset(get_copy = "pub")]
    storage: storage::Id,
}

/// Initializes ECS
pub fn setup_ecs(setup: SetupEcs) -> SetupEcs { setup }