Struct GameState

Source
#[non_exhaustive]
pub struct GameState { pub players: Vec<Player>, pub buildings: BTreeMap<EntityId, Building>, pub projectiles: BTreeMap<EntityId, Projectile>, pub collisions: Vec<Collision>, pub world: Option<World>, pub kills: Vec<Kill>, pub tick: DemoTick, pub server_classes: Vec<ServerClass>, pub interval_per_tick: f32, pub outer_map: HashMap<Handle, EntityId>, pub events: Vec<(DemoTick, GameEvent)>, pub objectives: BTreeMap<EntityId, Objective>, }

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§players: Vec<Player>§buildings: BTreeMap<EntityId, Building>§projectiles: BTreeMap<EntityId, Projectile>§collisions: Vec<Collision>§world: Option<World>§kills: Vec<Kill>§tick: DemoTick§server_classes: Vec<ServerClass>§interval_per_tick: f32§outer_map: HashMap<Handle, EntityId>§events: Vec<(DemoTick, GameEvent)>§objectives: BTreeMap<EntityId, Objective>

Implementations§

Source§

impl GameState

Source

pub fn get_player(&self, id: EntityId) -> Option<&Player>

Source

pub fn get_or_create_player(&mut self, entity_id: EntityId) -> &mut Player

Source

pub fn get_or_create_building( &mut self, entity_id: EntityId, class: BuildingClass, ) -> &mut Building

Source

pub fn check_collision(&self, projectile: &Projectile) -> Option<&Player>

Source

pub fn projectile_destroy(&mut self, id: EntityId)

Source

pub fn remove_building(&mut self, entity_id: EntityId)

Trait Implementations§

Source§

impl Debug for GameState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GameState

Source§

fn default() -> GameState

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for GameState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for GameState

Source§

fn eq(&self, other: &GameState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for GameState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for GameState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,