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 OnHealthChange {
53 pub actor: Actor,
54 pub cause: Option<Actor>,
55 pub new_health_fraction: f32,
56}
57impl Event for OnHealthChange {
58 type SystemData<'a> = ();
59}
60
61#[derive(Clone)]
62pub struct OnTheft {
63 pub actor: Actor,
64 pub wpos: Vec3<i32>,
65 pub sprite: SpriteKind,
66 pub site: Option<SiteId>,
67}
68
69impl Event for OnTheft {
70 type SystemData<'a> = ();
71}
72
73#[derive(Clone)]
74pub struct OnMountVolume {
75 pub actor: Actor,
76 pub pos: VolumePos<NpcId>,
77}
78impl Event for OnMountVolume {
79 type SystemData<'a> = ();
80}