strafe-client-jed/src/event.rs

41 lines
913 B
Rust
Raw Normal View History

2023-09-08 18:33:20 +00:00
pub struct EventStruct {
pub time: crate::body::TIME,
pub event: EventEnum,
}
pub enum EventEnum {
2023-09-08 22:54:22 +00:00
CollisionStart(crate::body::RelativeCollision),//Body::CollisionStart
CollisionEnd(crate::body::RelativeCollision),//Body::CollisionEnd
2023-09-08 18:33:20 +00:00
StrafeTick,
Jump,
}
pub trait EventTrait {
fn next_event(&self) -> Option<EventStruct>;
2023-09-08 19:48:11 +00:00
}
//PROPER PRIVATE FIELDS!!!
pub struct EventCollector {
event: Option<EventStruct>,
}
impl EventCollector {
pub fn new() -> Self {
Self{event:None}
}
pub fn collect(&mut self,test_event:Option<EventStruct>){
match &test_event {
Some(unwrap_test_event) => match &self.event {
Some(unwrap_best_event) => if unwrap_test_event.time<unwrap_best_event.time {
self.event=test_event;
},
None => self.event=test_event,
},
None => (),
}
}
pub fn event(self) -> Option<EventStruct> {
//STEAL EVENT AND DESTROY EVENTCOLLECTOR
return self.event
}
2023-09-08 18:33:20 +00:00
}