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

Which frame we're on. Starts at zero and increments by 1 each frame.

The actual time the server measured since the previous frame.

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.

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. The server will only send the top 10.

Trait Implementations

impl Clone for GameState
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for GameState
[src]

Formats the value using the given formatter. Read more

impl PartialEq for GameState
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

impl Send for GameState

impl Sync for GameState