unbanished_game/work/construction/site/work.rs
1//! A site's attendance, piles and the work it offers: clearing, pickup, gathering and building.
2
3use super::*;
4
5// vtable 0x14015ee00
6/// AttendanceComponent: who attends a school, chapel or doctor.
7#[derive(Debug, Clone, PartialEq)]
8pub struct Attendance {
9 // +0x20
10 /// AttendanceDescription.
11 pub capacity: i32,
12 // +0x28
13 /// Attendees in arrival order.
14 pub attendees: Vec<usize>,
15 /// The workplace's profession (teacher, priest, doctor).
16 pub profession: Option<usize>,
17}
18
19// vtable 0x14016a5a0
20/// `RawMaterialComponent`: a loose pile.
21///
22/// Original: `FUN_14012e8d0`.
23#[derive(Debug, Clone, PartialEq)]
24pub struct Pile {
25 /// The raw material (RawMaterialDescription of the pile's template).
26 pub material: usize,
27 // +0x28
28 /// Units.
29 pub count: i32,
30 // +0x38
31 /// Age; after 3600 s the pile is destroyed.
32 ///
33 /// Original: `FUN_14012e600`.
34 pub age: i64,
35 /// The Pickup work its WorkComponent registered.
36 ///
37 /// Original: `FUN_14012e6a0`.
38 pub work: i32,
39 /// The work's category mask.
40 ///
41 /// Original: `FUN_14012e950`.
42 pub mask: u32,
43 /// A priority to keep from the work at its cell, applied on activation.
44 ///
45 /// Original: `FUN_1400fe220`.
46 pub priority: Option<i32>,
47 /// The workplace whose AutoPickup gets the Pickup work once registered.
48 pub auto_pickup: Option<usize>,
49 // +0x48; +0x50
50 /// The Pickup work's (0 free, 1 claimed, 2 picked up) and (claimer). Kept on the pile: one
51 /// Pickup try claims several piles' works.
52 pub state: i32,
53 /// The citizen who claimed the pile, if any.
54 pub claimer: Option<usize>,
55}
56
57// +0x48; +0x58; +0x68; +0x70..+0x72
58/// `ClearArea` state: claimed resources (entity → citizen), claimed cells, template filter,
59/// resources / cells / piles.
60#[derive(Debug, Clone, Default)]
61pub struct ClearWork {
62 /// The claimed resources: entity → citizen.
63 pub resources: BTreeMap<usize, usize>,
64 /// The claimed cells: cell → citizen.
65 pub cells: BTreeMap<i32, usize>,
66 /// Only resources of this template are cleared, when set.
67 pub filter: Option<String>,
68 /// Whether natural resources are cleared.
69 pub clear_resources: bool,
70 /// Whether cells are cleared.
71 pub clear_cells: bool,
72 /// Whether piles are cleared.
73 pub clear_piles: bool,
74}
75
76// +0x48; +0x50
77/// `Pickup` work: its state lives on the [`Pile`] it belongs to.
78#[derive(Debug, Clone, Default)]
79pub struct PickupWork;
80
81// +0x48; +0x58; +0x68
82/// `GatherRawMaterials` state (delivered per requirement, in transit, workers).
83#[derive(Debug, Clone, Default)]
84pub struct Gather {
85 /// The materials delivered, for each requirement.
86 pub stored: Vec<i32>,
87 /// The materials on their way, for each requirement.
88 pub transit: Vec<i32>,
89 /// The workers.
90 pub workers: BTreeSet<usize>,
91}
92
93// +0x48; +0x4c; +0x50; +0x60
94/// `BuildStructure` state (destroy flag, point cursor, occupied build points, workers).
95#[derive(Debug, Clone, Default)]
96pub struct BuildWork {
97 /// Whether this is demolition instead of construction.
98 pub destroy: bool,
99 /// The next build point to try.
100 pub cursor: i32,
101 /// Which build points are taken.
102 pub occupied: Vec<bool>,
103 /// The workers.
104 pub workers: BTreeSet<usize>,
105}