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
60
61
62
63
64
65
use crate::{RtState, Rule};
use common::{
    mounting::VolumePos,
    resources::{Time, TimeOfDay},
    rtsim::{Actor, NpcId, SiteId},
    terrain::SpriteKind,
};
use vek::*;
use world::{IndexRef, World};

pub trait Event: Clone + 'static {}

pub struct EventCtx<'a, R: Rule, E: Event> {
    pub state: &'a RtState,
    pub rule: &'a mut R,
    pub event: &'a E,
    pub world: &'a World,
    pub index: IndexRef<'a>,
}

#[derive(Clone)]
pub struct OnSetup;
impl Event for OnSetup {}

#[derive(Clone)]
pub struct OnTick {
    pub time_of_day: TimeOfDay,
    pub time: Time,
    pub tick: u64,
    pub dt: f32,
}
impl Event for OnTick {}

#[derive(Clone)]
pub struct OnDeath {
    pub actor: Actor,
    pub wpos: Option<Vec3<f32>>,
    pub killer: Option<Actor>,
}
impl Event for OnDeath {}

#[derive(Clone)]
pub struct OnHealthChange {
    pub actor: Actor,
    pub cause: Option<Actor>,
    pub new_health_fraction: f32,
}
impl Event for OnHealthChange {}

#[derive(Clone)]
pub struct OnTheft {
    pub actor: Actor,
    pub wpos: Vec3<i32>,
    pub sprite: SpriteKind,
    pub site: Option<SiteId>,
}

impl Event for OnTheft {}

#[derive(Clone)]
pub struct OnMountVolume {
    pub actor: Actor,
    pub pos: VolumePos<NpcId>,
}
impl Event for OnMountVolume {}