use std::ops::{Deref, DerefMut};
use bstr::BString;
use crate::enums::*;
#[cfg(feature = "serde")]
use crate::packets::serde::{opt_vec, VecRemote};
use crate::types::*;
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ChatPublic {
pub id: Player,
pub text: BString,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ChatSay {
pub id: Player,
pub text: BString,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ChatTeam {
pub id: Player,
pub text: BString,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ChatVoteMutePassed {
pub id: Player,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ChatWhisper {
pub from: Player,
pub to: Player,
pub text: BString,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct CommandReply {
pub ty: CommandReplyType,
pub text: BString,
}
#[derive(Copy, Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Backup;
#[derive(Copy, Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Ack;
#[derive(Copy, Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ChatVoteMuted;
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Error {
pub error: ErrorType,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct EventBoost {
pub clock: u32,
pub id: Player,
pub boost: bool,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub rot: Rotation,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub speed: Velocity,
pub energy: Energy,
pub energy_regen: EnergyRegen,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct EventBounce {
pub clock: u32,
pub id: Player,
pub keystate: ServerKeyState,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub rot: Rotation,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub speed: Velocity,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct EventLeaveHorizon {
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: LeaveHorizonType,
pub id: u16,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct EventRepelPlayer {
pub id: Player,
pub keystate: ServerKeyState,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub rot: Rotation,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub speed: Velocity,
pub energy: Energy,
pub energy_regen: EnergyRegen,
pub health: Health,
pub health_regen: HealthRegen,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct EventRepelMob {
pub id: Mob,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: MobType,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub speed: Velocity,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub accel: Accel,
pub max_speed: Speed,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct EventRepel {
pub clock: u32,
pub id: Player,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub rot: Rotation,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub speed: Velocity,
pub energy: Energy,
pub energy_regen: EnergyRegen,
pub players: Vec<EventRepelPlayer>,
pub mobs: Vec<EventRepelMob>,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct EventStealth {
pub id: Player,
pub state: bool,
pub energy: Energy,
pub energy_regen: EnergyRegen,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct GameFirewall {
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: u8,
pub status: FirewallStatus,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub radius: f32,
pub speed: f32,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct GameFlag {
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: FlagUpdateType,
pub flag: u8,
pub id: Option<Player>,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub blueteam: u8,
pub redteam: u8,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct GamePlayersAlive {
pub players: u16,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct GameSpectate {
pub id: Player,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LoginPlayer {
pub id: Player,
pub status: PlayerStatus,
pub level: Level,
pub name: BString,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: PlaneType,
pub team: Team,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub rot: Rotation,
pub flag: FlagCode,
pub upgrades: Upgrades,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Login {
pub success: bool,
pub id: Player,
pub team: Team,
pub clock: u32,
pub token: BString,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: GameType,
pub room: BString,
pub players: Vec<LoginPlayer>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LoginBot {
pub id: Player,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Login2 {
#[cfg_attr(feature = "serde", serde(flatten))]
pub login: Login,
#[cfg_attr(feature = "serde", serde(rename = "serverConfiguration"))]
pub config: BString,
pub bots: Vec<LoginBot>,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MobDespawnCoords {
pub id: Mob,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: MobType,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MobDespawn {
pub id: Mob,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: DespawnType,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MobUpdateStationary {
pub id: Mob,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: MobType,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MobUpdate {
pub clock: u32,
pub id: Mob,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: MobType,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub speed: Velocity,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub accel: Accel,
pub max_speed: Speed,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MobUpdate2 {
#[cfg_attr(feature = "serde", serde(flatten))]
pub update: MobUpdate,
#[cfg_attr(feature = "serde", serde(flatten))]
#[cfg_attr(feature = "serde", serde(rename = "ownerId"))]
pub owner: Player,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PingResult {
pub ping: u16,
#[cfg_attr(feature = "serde", serde(rename = "playersTotal"))]
pub players_total: u32,
#[cfg_attr(feature = "serde", serde(rename = "playersGame"))]
pub players_game: u32,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Ping {
pub clock: u32,
pub num: u32,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerFireProjectile {
pub id: Mob,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: MobType,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub speed: Velocity,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub accel: Accel,
pub max_speed: Speed,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerFire {
pub clock: u32,
pub id: Player,
pub energy: Energy,
pub energy_regen: EnergyRegen,
pub projectiles: Vec<PlayerFireProjectile>,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerFlag {
pub id: Player,
pub flag: FlagCode,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerHitPlayer {
pub id: Player,
pub health: Health,
pub health_regen: HealthRegen,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerHit {
pub id: Mob,
pub ty: MobType,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub owner: Player,
pub players: Vec<PlayerHitPlayer>,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerKill {
pub id: Player,
pub killer: Option<Player>,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerLeave {
pub id: Player,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerLevel {
pub id: Player,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: PlayerLevelType,
pub level: Level,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerNew {
pub id: Player,
pub status: PlayerStatus,
pub name: BString,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: PlaneType,
pub team: Team,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub rot: Rotation,
pub flag: FlagCode,
pub upgrades: Upgrades,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerPowerup {
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: PowerupType,
pub duration: u32,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerRespawn {
pub id: Player,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub rot: Rotation,
pub upgrades: Upgrades,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerReteamPlayer {
pub id: Player,
pub team: Team,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerReteam {
pub players: Vec<PlayerReteamPlayer>,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerType {
pub id: Player,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: PlaneType,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerUpdate {
pub clock: u32,
pub id: Player,
pub keystate: ServerKeyState,
pub upgrades: Upgrades,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub pos: Position,
pub rot: Rotation,
#[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
pub speed: Velocity,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerUpgrade {
pub upgrades: u16,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: UpgradeType,
pub speed: u8,
pub defense: u8,
pub energy: u8,
pub missile: u8,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreBoardData {
pub id: Player,
pub score: Score,
pub level: Level,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreBoardRanking {
pub id: Player,
#[cfg_attr(feature = "serde", serde(with = "opt_vec"))]
pub pos: Option<Position>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreBoard {
pub data: Vec<ScoreBoardData>,
pub rankings: Vec<ScoreBoardRanking>,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreUpdate {
pub id: Player,
pub score: Score,
pub earnings: Score,
pub upgrades: u16,
pub total_kills: u32,
pub total_deaths: u32,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ServerCustom {
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: ServerCustomType,
pub data: BString,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ServerMessage {
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: ServerMessageType,
pub duration: u32,
pub text: BString,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreDetailedBTREntry {
pub id: Player,
pub level: Level,
pub alive: bool,
pub wins: u16,
pub score: Score,
pub kills: u16,
pub deaths: u16,
pub damage: f32,
pub ping: u16,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreDetailedBTR {
pub scores: Vec<ScoreDetailedBTREntry>,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreDetailedCTFEntry {
pub id: Player,
pub level: Level,
pub captures: u16,
pub score: Score,
pub kills: u16,
pub deaths: u16,
pub damage: f32,
pub ping: u16,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreDetailedCTF {
pub scores: Vec<ScoreDetailedCTFEntry>,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreDetailedFFAEntry {
pub id: Player,
pub level: Level,
pub score: Score,
pub kills: u16,
pub deaths: u16,
pub damage: f32,
pub ping: u16,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScoreDetailedFFA {
pub scores: Vec<ScoreDetailedFFAEntry>,
}
impl Deref for Login2 {
type Target = Login;
fn deref(&self) -> &Self::Target {
&self.login
}
}
impl DerefMut for Login2 {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.login
}
}
impl Deref for MobUpdate2 {
type Target = MobUpdate;
fn deref(&self) -> &Self::Target {
&self.update
}
}
impl DerefMut for MobUpdate2 {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.update
}
}