mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
gamestate api bits
This commit is contained in:
parent
83a13e5e52
commit
fb166e0808
3 changed files with 18 additions and 10 deletions
|
|
@ -2,7 +2,7 @@ use crate::demo::gameevent_gen::GameEventType::PlayerSappedObject;
|
|||
use crate::demo::message::packetentities::{EntityId, PacketEntity};
|
||||
use crate::demo::message::Message;
|
||||
use crate::demo::packet::datatable::{ParseSendTable, SendTableName, ServerClass, ServerClassName};
|
||||
use crate::demo::parser::analyser::{Class, Team, UserId};
|
||||
pub use crate::demo::parser::analyser::{Class, Team, UserId};
|
||||
use crate::demo::parser::handler::BorrowMessageHandler;
|
||||
use crate::demo::parser::MessageHandler;
|
||||
use crate::demo::vector::{Vector, VectorXY};
|
||||
|
|
@ -35,13 +35,13 @@ impl PlayerState {
|
|||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct Player {
|
||||
entity: EntityId,
|
||||
position: Vector,
|
||||
health: u16,
|
||||
max_health: u16,
|
||||
class: Class,
|
||||
team: Team,
|
||||
view_angle: f32,
|
||||
state: PlayerState,
|
||||
pub position: Vector,
|
||||
pub health: u16,
|
||||
pub max_health: u16,
|
||||
pub class: Class,
|
||||
pub team: Team,
|
||||
pub view_angle: f32,
|
||||
pub state: PlayerState,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
|
|
@ -96,8 +96,8 @@ pub enum Building {
|
|||
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub struct GameState {
|
||||
players: Vec<Player>,
|
||||
buildings: Vec<Building>,
|
||||
pub players: Vec<Player>,
|
||||
pub buildings: Vec<Building>,
|
||||
}
|
||||
|
||||
impl GameState {
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ impl<A: MessageHandler> DemoParser<A> {
|
|||
Ok((header, ticker.into_state()))
|
||||
}
|
||||
|
||||
/// A Ticker provides a way to step trough the demo packet by packet
|
||||
/// while allowing to see the intermediate states
|
||||
pub fn ticker(mut self) -> Result<(Header, DemoTicker<A>)> {
|
||||
let header = Header::read(&mut self.stream)?;
|
||||
let ticker = DemoTicker {
|
||||
|
|
|
|||
|
|
@ -28,3 +28,9 @@ impl PartialEq for VectorXY {
|
|||
(self.x - other.x < 0.001) && (self.y - other.y < 0.001)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vector> for VectorXY {
|
||||
fn from(vec: Vector) -> Self {
|
||||
VectorXY { x: vec.x, y: vec.y }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue