1use crate::{RtState, Rule, ai::NpcSystemData};
2use common::{
3 mounting::VolumePos,
4 resources::{Time, TimeOfDay},
5 rtsim::{Actor, NpcId, SiteId},
6 terrain::SpriteKind,
7};
8use vek::*;
9use world::{IndexRef, World};
10
11pub trait Event: Clone + 'static {
12 type SystemData<'a>;
13}
14
15pub struct EventCtx<'a, 'd, R: Rule, E: Event> {
16 pub state: &'a RtState,
17 pub rule: &'a mut R,
18 pub event: &'a E,
19 pub world: &'a World,
20 pub index: IndexRef<'a>,
21 pub system_data: &'a mut E::SystemData<'d>,
22}
23
24#[derive(Clone)]
25pub struct OnSetup;
26impl Event for OnSetup {
27 type SystemData<'a> = ();
28}
29
30#[derive(Clone)]
31pub struct OnTick {
32 pub time_of_day: TimeOfDay,
33 pub time: Time,
34 pub tick: u64,
35 pub dt: f32,
36}
37impl Event for OnTick {
38 type SystemData<'a> = NpcSystemData<'a>;
39}
40
41#[derive(Clone)]
42pub struct OnDeath {
43 pub actor: Actor,
44 pub wpos: Option<Vec3<f32>>,
45 pub killer: Option<Actor>,
46}
47impl Event for OnDeath {
48 type SystemData<'a> = ();
49}
50
51#[derive(Clone)]
52pub struct OnHelped {
53 pub actor: Actor,
54 pub saver: Option<Actor>,
55}
56impl Event for OnHelped {
57 type SystemData<'a> = ();
58}
59
60#[derive(Clone)]
61pub struct OnHealthChange {
62 pub actor: Actor,
63 pub cause: Option<Actor>,
64 pub new_health_fraction: f32,
65 pub change: f32,
66}
67impl Event for OnHealthChange {
68 type SystemData<'a> = ();
69}
70
71#[derive(Clone)]
72pub struct OnTheft {
73 pub actor: Actor,
74 pub wpos: Vec3<i32>,
75 pub sprite: SpriteKind,
76 pub site: Option<SiteId>,
77}
78
79impl Event for OnTheft {
80 type SystemData<'a> = ();
81}
82
83#[derive(Clone)]
84pub struct OnMountVolume {
85 pub actor: Actor,
86 pub pos: VolumePos<NpcId>,
87}
88impl Event for OnMountVolume {
89 type SystemData<'a> = ();
90}