veloren/rtsim/src/event.rs

37 lines
679 B
Rust
Raw Normal View History

use crate::{RtState, Rule};
use common::{
resources::{Time, TimeOfDay},
rtsim::Actor,
};
2022-09-03 09:47:18 +00:00
use world::{IndexRef, World};
2022-08-09 23:02:56 +00:00
pub trait Event: Clone + 'static {}
2022-08-11 14:44:57 +00:00
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>,
}
2022-08-09 23:02:56 +00:00
#[derive(Clone)]
2022-08-11 14:44:57 +00:00
pub struct OnSetup;
impl Event for OnSetup {}
2022-08-09 23:02:56 +00:00
2022-08-11 14:44:57 +00:00
#[derive(Clone)]
pub struct OnTick {
2022-08-14 14:20:22 +00:00
pub time_of_day: TimeOfDay,
pub time: Time,
2023-04-05 15:32:54 +00:00
pub tick: u64,
pub dt: f32,
}
2022-08-09 23:02:56 +00:00
impl Event for OnTick {}
2023-01-05 23:15:43 +00:00
#[derive(Clone)]
pub struct OnDeath {
pub actor: Actor,
pub killer: Option<Actor>,
2023-01-05 23:15:43 +00:00
}
impl Event for OnDeath {}