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
53
54
55
56
57
58
59
use super::item::Reagent;
use crate::{
    resources::{Secs, Time},
    uid::Uid,
};
use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage};
use std::time::Duration;
use vek::Vec3;

#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum Object {
    Bomb {
        owner: Option<Uid>,
    },
    Firework {
        owner: Option<Uid>,
        reagent: Reagent,
    },
    DeleteAfter {
        spawned_at: Time,
        timeout: Duration,
    },
    Portal {
        target: Vec3<f32>,
        requires_no_aggro: bool,
        buildup_time: Secs,
    },
    SurpriseEgg {
        owner: Option<Uid>,
    },
}

impl Component for Object {
    type Storage = DerefFlaggedStorage<Self, specs::VecStorage<Self>>;
}

#[derive(Clone, Debug)]
pub struct PortalData {
    pub target: Vec3<f32>,
    pub requires_no_aggro: bool,
    pub buildup_time: Secs,
}

impl From<PortalData> for Object {
    fn from(
        PortalData {
            target,
            requires_no_aggro,
            buildup_time,
        }: PortalData,
    ) -> Self {
        Self::Portal {
            target,
            requires_no_aggro,
            buildup_time,
        }
    }
}