veloren_rtsim/data/
architect.rs

1use std::collections::VecDeque;
2
3use common::{
4    comp,
5    resources::TimeOfDay,
6    rtsim::{FactionId, Role},
7};
8use serde::{Deserialize, Serialize};
9
10use super::Npc;
11
12#[derive(Clone, Serialize, Deserialize)]
13pub struct Death {
14    pub time: TimeOfDay,
15    pub body: comp::Body,
16    pub role: Role,
17    pub faction: Option<FactionId>,
18}
19
20/// The architect has the responsibility of making sure the game keeps working.
21/// Which means keeping the simulation in check, and making sure interesting
22/// stuff keeps happening.
23///
24/// Currently it handles:
25/// - Keeping track of all deaths that happen, and respawn something similar to
26///   keep the world from dying out.
27#[derive(Default, Clone, Serialize, Deserialize)]
28pub struct Architect {
29    pub deaths: VecDeque<Death>,
30}
31
32impl Architect {
33    pub fn on_death(&mut self, npc: &Npc, time: TimeOfDay) {
34        self.deaths.push_back(Death {
35            time,
36            body: npc.body,
37            role: npc.role.clone(),
38            faction: npc.faction,
39        })
40    }
41}