Struct rusty_sword_arena::game::PlayerState[][src]

pub struct PlayerState {
    pub id: u8,
    pub name: String,
    pub color: Color,
    pub pos: Vector2,
    pub direction: f32,
    pub radius: f32,
    pub velocity: Vector2,
    pub health: f32,
    pub weapon: Weapon,
    pub player_events: Vec<PlayerEvent>,
    pub drop_timer: Timer,
    pub respawn_timer: Timer,
    pub dead: bool,
    // some fields omitted
}

The state of a player on the server. The server broadcasts these to all clients every frame as part of a FrameState. Note that you can receive PlayerStates before you have gotten a corresponding GameSetting telling you their name and color!

Fields

The ID of the player

The name of the player

The color of the player

The position of the player in OpenGL units.

The direction the player is facing, in radians

Your player occupies a circle of this radius, in OpenGL units.

Current velocity of the player

Current health of the player [0.0, 100.0]

Current weapon of the player

Any player events that have occurred to the player this frame

How long the server will wait to get input from you before disconnecting you

How long until the player respawns. If respawn_timer.ready == false, then the player is dead and you should seriously consider indicating that visually somehow, even if only by not displaying the player.

Are you dead? Untangling health/respawn_timer dynamics is a pain, so we'll use this much more convenient boolean.

Methods

impl PlayerState
[src]

Represents the state of the player on the server for the current frame. Always delivered by the server to the client inside a GameState. The server always creates PlayeStates, updates them, and sends them to the client each frame. The client is free to modify its local copy (for example, to remove PlayerEvents it has processed) -- a new set of PlayerStates will be delivered the next frame. Clients typically look at the fields and events, and don't use any of the methods.

The client should never create a PlayerState -- the server will do that.

Clients never need to call update. The server calls it each time it processes some amount of time.

Used by the server to reset things that have been taken care of last frame.

Used by the server when a player needs to die

Used by the server when a player needs to spawn

Trait Implementations

impl Clone for PlayerState
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for PlayerState
[src]

Formats the value using the given formatter. Read more

impl PartialEq for PlayerState
[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 PlayerState

impl Sync for PlayerState