use titan::{LogicLong, Payload}; #[derive(Debug, Default, Clone, PartialEq, Eq, Payload)] pub struct LogicBattleEvent { #[codec(byte)] pub event_type: u8, #[codec(vlong)] pub account_id: LogicLong, #[codec(vint)] pub ticks: Vec, #[codec(vint)] pub coords: Vec, #[codec(vint)] pub params: Vec, } impl LogicBattleEvent { pub fn num_coords(&self) -> usize { self.coords.len() / 2 } pub fn coord(&self, index: usize) -> Option<(i32, i32)> { let x = *self.coords.get(index * 2)?; let y = *self.coords.get(index * 2 + 1)?; Some((x, y)) } }