Struct rusty_sword_arena::game::GameState [−][src]
pub struct GameState { pub frame_number: u64, pub delta: Duration, pub game_setting_hash: u64, pub player_states: HashMap<u8, PlayerState>, pub high_scores: HighScores, }
Once per frame, the server will broadcast a GameState to all clients. IMPORTANT: If you don't receive a GameState for 2 full seconds, the client MUST DROP its ServerConnection (or just exit entirely). The underlying networking that we're currently using hides network disconnects, which can leave the networking in a funky state if one end drops. So we need to rely on detecting this heartbeat and shutting down the clients to ensure networking is clean when the server restarts. (In the future, lets switch to a protocol that can detect disconnects...)
Fields
frame_number: u64
Which frame we're on. Starts at zero and increments by 1 each frame.
delta: Duration
The actual time the server measured since the previous frame.
game_setting_hash: u64
The hash of the current game setting. Your client should store this somewhere. If it changes then something has changed (most likely a player has joined or disconnected), so you should send a GameControlMsg::Fetch to get the new GameSetting from the server and update your client state.
player_states: HashMap<u8, PlayerState>
All of the current player's states, including your own! NOTE: The only reliable method of knowing that a player is present in the game or not is whether or not a state is in player_states. If there isn't a state, then the player has left or has been kicked/dropped. If there is a state, then the player is in the game (and might have joined since the last GameState was sent).
high_scores: HighScores
High scores. The server will only send the top 10.
Trait Implementations
impl Clone for GameState
[src]
impl Clone for GameState
fn clone(&self) -> GameState
[src]
fn clone(&self) -> GameState
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for GameState
[src]
impl Debug for GameState
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for GameState
[src]
impl PartialEq for GameState