pub struct GameStateData {
pub positions: HashMap<u32, (f32, f32)>,
pub velocities: HashMap<u32, (f32, f32)>,
pub scores: HashMap<String, i32>,
pub flags: HashMap<String, bool>,
pub custom: HashMap<String, Value>,
}Expand description
Game state data container
Fields§
§positions: HashMap<u32, (f32, f32)>Entity positions (entity_id -> (x, y))
velocities: HashMap<u32, (f32, f32)>Entity velocities (entity_id -> (vx, vy))
scores: HashMap<String, i32>Scores
flags: HashMap<String, bool>Game flags
custom: HashMap<String, Value>Custom state values
Implementations§
Source§impl GameStateData
impl GameStateData
Sourcepub fn add_position(&mut self, entity_id: u32, x: f32, y: f32)
pub fn add_position(&mut self, entity_id: u32, x: f32, y: f32)
Add entity position
Sourcepub fn add_velocity(&mut self, entity_id: u32, vx: f32, vy: f32)
pub fn add_velocity(&mut self, entity_id: u32, vx: f32, vy: f32)
Add entity velocity
Sourcepub fn compute_hash(&self) -> u64
pub fn compute_hash(&self) -> u64
Compute hash of the state
Trait Implementations§
Source§impl Clone for GameStateData
impl Clone for GameStateData
Source§fn clone(&self) -> GameStateData
fn clone(&self) -> GameStateData
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GameStateData
impl Debug for GameStateData
Source§impl Default for GameStateData
impl Default for GameStateData
Source§fn default() -> GameStateData
fn default() -> GameStateData
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for GameStateData
impl<'de> Deserialize<'de> for GameStateData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GameStateData
impl RefUnwindSafe for GameStateData
impl Send for GameStateData
impl Sync for GameStateData
impl Unpin for GameStateData
impl UnsafeUnpin for GameStateData
impl UnwindSafe for GameStateData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more