Documentation ¶
Index ¶
- type ChatAuthorAddedPacket
- type ChatAuthorRemovedPacket
- type ChatAuthorSync
- type ChatAuthorUpdatePacket
- type ChatMessagePacket
- type GameObjectAddedPacket
- type GameObjectRemovedPacket
- type GameObjectSync
- type GameObjectUpdatePacket
- type GameSyncPacket
- type GameSyncPacketPlayer
- type GameSyncPacketTeam
- type Packet
- type PlayerAddedPacket
- type PlayerSync
- type PolygonDetails
- type ResourceSync
- type Shape
- type SmartObjectAddedPacket
- type SmartObjectSync
- type SmartObjectUpdatePacket
- type TeamResourceChangedPacket
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatAuthorAddedPacket ¶
type ChatAuthorAddedPacket struct { // chat-author-added Type string `mapstructure:"type" json:"type"` // GameTime this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` ChatAuthorSync }
ChatAuthorAddedPacket informs a client that there is a new person able to hear their messages
func (*ChatAuthorAddedPacket) GetType ¶
func (p *ChatAuthorAddedPacket) GetType() string
func (*ChatAuthorAddedPacket) PrepareForMarshal ¶
func (p *ChatAuthorAddedPacket) PrepareForMarshal()
type ChatAuthorRemovedPacket ¶
type ChatAuthorRemovedPacket struct { // chat-author-removed Type string `mapstructure:"type" json:"type"` // GameTime this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` // UID is the identifier for the chat author UID string `mapstructure:"uid" json:"uid"` }
ChatAuthorRemovedPacket informs a client that someone left range for communicating with them
func (*ChatAuthorRemovedPacket) GetType ¶
func (p *ChatAuthorRemovedPacket) GetType() string
func (*ChatAuthorRemovedPacket) PrepareForMarshal ¶
func (p *ChatAuthorRemovedPacket) PrepareForMarshal()
type ChatAuthorSync ¶
type ChatAuthorSync struct { // UID is the identifier for this chat author UID string `mapstructure:"uid" json:"uid"` // Name is the display name for this chat author Name string `mapstructure:"name" json:"name"` // Color is the font color for this player Color string `mapstructure:"color" json:"color"` // BonusClasses contains additional styles for this players text BonusClasses []string `mapstructure:"bonus_classes" json:"bonus_classes"` }
ChatAuthorSync contains all the information the client needs to learn about a chat author
type ChatAuthorUpdatePacket ¶
type ChatAuthorUpdatePacket struct { // chat-author-update Type string `mapstructure:"type" json:"type"` // GameTime this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` ChatAuthorSync }
ChatAuthorUpdatePacket informs a client that one of the people they can hear in chat changed something about how their messages are displayed
func (*ChatAuthorUpdatePacket) GetType ¶
func (p *ChatAuthorUpdatePacket) GetType() string
func (*ChatAuthorUpdatePacket) PrepareForMarshal ¶
func (p *ChatAuthorUpdatePacket) PrepareForMarshal()
type ChatMessagePacket ¶
type ChatMessagePacket struct { // chat-message Type string `mapstructure:"type" json:"type"` // GameTime this packet was sent using our game time measurement, // which is consistent across all players but doesn't necessarily // correspond to anything real GameTime float64 `mapstructure:"game_time" json:"game_time"` // Time is the unix time that the message was canonically received Time float64 `mapstructure:"time" json:"time"` // AuthorUID is the uid of the chat author which sent this message AuthorUID string `mapstructure:"author_uid" json:"author_uid"` // Text that should be displayed. Must be treated as untrusted by // the client. Text string `mapstructure:"text" json:"text"` }
ChatMessagePacket tells a player about a new message from someone nearby, or possibly about a server message
func (*ChatMessagePacket) GetType ¶
func (p *ChatMessagePacket) GetType() string
func (*ChatMessagePacket) PrepareForMarshal ¶
func (p *ChatMessagePacket) PrepareForMarshal()
type GameObjectAddedPacket ¶
type GameObjectAddedPacket struct { // game-object-added Type string `mapstructure:"type" json:"type"` // GameTime this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` // Object is the object that just entered view. Object GameObjectSync `mapstructure:"object" json:"object"` }
GameObjectAddedPacket is a top-level packet that can be sent to a client to inform them a new game object came into view.
func (*GameObjectAddedPacket) GetType ¶
func (p *GameObjectAddedPacket) GetType() string
func (*GameObjectAddedPacket) PrepareForMarshal ¶
func (p *GameObjectAddedPacket) PrepareForMarshal()
type GameObjectRemovedPacket ¶
type GameObjectRemovedPacket struct { // game-object-removed Type string `mapstructure:"type" json:"type"` // GameTime this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` // UID of the object removed UID string `mapstructure:"uid" json:"uid"` }
GameObjectRemovedPacket is used to inform the client they are no longer able to see the given game object, likely because it's just out view now
func (*GameObjectRemovedPacket) GetType ¶
func (p *GameObjectRemovedPacket) GetType() string
func (*GameObjectRemovedPacket) PrepareForMarshal ¶
func (p *GameObjectRemovedPacket) PrepareForMarshal()
type GameObjectSync ¶
type GameObjectSync struct { // UID of the object UID string `mapstructure:"uid" json:"uid"` // SheetURL is the URL to the json object that contains the vast majority of // information about how to display this object; it is formatted as a // PixiJS-compatible spritesheet with an additional animationMeta section // which may include additional render hints not controlled by the server. SheetURL string `mapstructure:"sheet_url" json:"sheet_url"` // SpriteScale determines the scale that the object should be // rendered at. This is in addition to any scaling described by the // sheet. This is used to allow dynamic sizing on some objects, e.g., // walls. SpriteScale Vector `mapstructure:"sprite_scale" json:"sprite_scale"` // SpriteRotation determines a static rotation offset in radians, // used to correct for certain types of rotations. SpriteRotation float64 `mapstructure:"sprite_rotation" json:"sprite_rotation"` // RenderOffset determines a static render offset in pixels, used // to correct the rendered bounds to match the physics offset in // some situations. Note that the spritesheet may RenderOffset Vector `mapstructure:"render_offset" json:"render_offset"` // Animation is the name of the animation within the sheet that // should currently be used to render this object. Animation string `mapstructure:"animation" json:"animation"` // AnimationSpeed is the speed of the animation, where 1 is 60 // frames per second, 0.5 is 30 frames per second, and 2 is // 120 frames per second. AnimationSpeed float64 `mapstructure:"animation_speed" json:"animation_speed"` // AnimationPlaying is true if the animation should actually play // and false if it should be frozen on an arbitrary frame. AnimationPlaying bool `mapstructure:"animation_playing" json:"animation_playing"` // AnimationLooping is true if the animation should loop when // finished and false if it should not. AnimationLooping bool `mapstructure:"animation_looping" json:"animation_looping"` // Shapes describes the physics shapes of this body. Shapes []Shape `mapstructure:"shapes" json:"shapes"` // Position is where this object is located in game units, where 1 // game unit is 64 pixels at standard zoom. Position Vector `mapstructure:"position" json:"position"` // Velocity is the change in position of the object in game units per // second. Velocity Vector `mapstructure:"velocity" json:"velocity"` // Rotation is the rotation of the object in radians. Rotation float64 `mapstructure:"rotation" json:"rotation"` // AngularVelocity is the change in rotation of the object in // radians per second AngularVelocity float64 `mapstructure:"angular_velocity" json:"angular_velocity"` }
GameObjectSync describes everything required for a client to learn about a game object its never heard of before.
type GameObjectUpdatePacket ¶
type GameObjectUpdatePacket struct { // game-object-update Type string `mapstructure:"type" json:"type"` // GameTime this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` // UID of the object that changed UID string `mapstructure:"uid" json:"uid"` // Position is the new position of the object in game units Position Vector `mapstructure:"position" json:"position"` // Velocity is the new change in position of the object in game units per // second Velocity Vector `mapstructure:"velocity" json:"velocity"` // Rotation is the new rotation of the object in radians Rotation float64 `mapstructure:"rotation" json:"rotation"` // AngularVelocity is the new change in rotation of the object in radians // per second. AngularVelocity float64 `mapstructure:"angular_velocity" json:"angular_velocity"` // Animation is the new animation of the object Animation string `mapstructure:"animation" json:"animation"` // AnimationPlaying is true if the new animation should play, false if it // should be frozen on an arbitrary frame. AnimationPlaying bool `mapstructure:"animation_playing" json:"animation_playing"` // AnimationLooping is true if the new animation should start over when it // finishes and false if it should not. AnimationLooping bool `mapstructure:"animation_looping" json:"animation_looping"` }
GameObjectUpdatePacket informs a client about a small update to a game object
func (*GameObjectUpdatePacket) GetType ¶
func (p *GameObjectUpdatePacket) GetType() string
func (*GameObjectUpdatePacket) PrepareForMarshal ¶
func (p *GameObjectUpdatePacket) PrepareForMarshal()
type GameSyncPacket ¶
type GameSyncPacket struct { // Type is game-sync Type string `mapstructure:"type" json:"type"` // GameTime in fractional seconds. GameTime float64 `mapstructure:"game_time" json:"game_time"` // Player describes high-level information about the actual player Player GameSyncPacketPlayer `mapstructure:"game_time" json:"player"` // Team describes high-level information about the team the player is on Team GameSyncPacketTeam `mapstructure:"team" json:"team"` // Resources describes the resources that are in the game, where the // keys are resource uids and the values have info about that resource Resources map[string]ResourceSync `mapstructure:"resources" json:"resources"` // Players contains all the players that you can see, which at least // contains you. The keys are game object uids. The client should // assume that anything we send here is fair game to display. Players map[string]PlayerSync `mapstructure:"players" json:"players"` // DumbObjects contains all the dumb game objects on the map that you // can see. This may contain objects way out of vision that are known // in advance. The client should assume anything we send here is fair // game to display. The keys are the game object uids. DumbObjects map[string]GameObjectSync `mapstructure:"dumb_objects" json:"dumb_objects"` // SmartObjects contains all the smart game objects on the map that // you can see. The keys are the game object uids. SmartObjects map[string]SmartObjectSync `mapstructure:"smart_objects" json:"smart_objects"` // ChatAuthors contains all the things that the player can communicate // with right now, including the player itself. ChatAuthors map[string]ChatAuthorSync `mapstructure:"chat_authors" json:"chat_authors"` }
GameSyncPacket provides everything necessary for a player which has no idea about the state of the game to fill in the state.
func (*GameSyncPacket) GetType ¶
func (p *GameSyncPacket) GetType() string
func (*GameSyncPacket) PrepareForMarshal ¶
func (p *GameSyncPacket) PrepareForMarshal()
type GameSyncPacketPlayer ¶
type GameSyncPacketPlayer struct { // UID is the UID of the primary game object for this player UID string `mapstructure:"uid" json:"uid"` // Team is the team that the player is on Team int `mapstructure:"team" json:"team"` // Role is the role that the player fulfilling Role string `mapstructure:"role" json:"role"` }
GameSyncPacketPlayer is used only within GameSyncPackets to describe the player
type GameSyncPacketTeam ¶
type GameSyncPacketTeam struct { // Resources is how many resources the team has, where the keys are // resource UIDs and the values are the amount of the resource that // the player team has Resources map[string]int `mapstructure:"resources" json:"resources"` }
GameSyncPacketTeam is used only within GameSyncPackets to describe the player team
type Packet ¶
type Packet interface { // GetType returns the canonical unique identifier for the packet GetType() string // Prepare ensures that the default values for this packet have been // set correctly. PrepareForMarshal() }
Packet describes any of the packets within this package, which is useful for grabbing the Type of the packet without a large switch statement.
func ParsePacket ¶
ParsePacket attempts to parse the packet described by the given bytes as one of the packets in this package. The resulting interface is nil if error is not nil, otherwise its a pointer to one of the Packet structs and should be switched on by type.
func ParseSinglePacket ¶
ParseSinglePacket parses a single packet which has already been converted to the map interpretation. Note that many of these may be sent within a single websocket message frame, formatted as a JSON array. In order to parse from the raw bytes of a websocket message frame, use ParsePacket.
type PlayerAddedPacket ¶
type PlayerAddedPacket struct { // Type is player-added Type string `mapstructure:"type" json:"type"` // GameTime is the time at which this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` // Object is the player that just entered view. Object PlayerSync `mapstructure:"object" json:"object"` }
PlayerAddedPacket is a top-level packet that can be sent to a client to inform them a new player came into view.
func (*PlayerAddedPacket) GetType ¶
func (p *PlayerAddedPacket) GetType() string
func (*PlayerAddedPacket) PrepareForMarshal ¶
func (p *PlayerAddedPacket) PrepareForMarshal()
type PlayerSync ¶
type PlayerSync struct { GameObjectSync // Role is the role of the player, see core.Role and core.RoleToName Role string `mapstructure:"role" json:"role"` // Team is the team of the player, generally 1-6 inclusive Team int `mapstructure:"team" json:"team"` }
PlayerSync contains all of the information required for a client who has never learned about a player before to render them.
type PolygonDetails ¶
type PolygonDetails struct { // Vertices is the vertices of the polygon relative to its center // of gravity Vertices []Vector `mapstructure:"vertices" json:"vertices"` // Radius is the rounding on the edges in game units. The actual shape // is this amount larger than the vertices would imply in any // direction. This rounding reduces collision oddities. Radius float64 `mapstructure:"radius" json:"radius"` }
PolygonDetails are the Details for the "polygon" Shape
type ResourceSync ¶
type ResourceSync struct { // UID is the unique identifier for this resource UID string `map_structure:"uid" json:"uid"` // SheetURL is the URL of the spritesheet (JSON) where the // icon for this resource can be found SheetURL string `map_structure:"sheet_url" json:"sheet_url"` // Animation is the name within the sheet for the icon for this // resource. Currently this is always a single-icon animation but we // leave room for real animations later Animation string `map_structure:"animation" json:"animation"` // Name is the display name for this resource Name string `map_structure:"name" json:"name"` }
ResourceSync describes everything a client needs to know to render a resource they've never seen before
type Shape ¶
type Shape struct { // ShapeType is currently always "polygon" ShapeType string `mapstructure:"shape_type" json:"shape_type"` // Mass is the mass of this shape in kg Mass float64 `mapstructure:"mass" json:"mass"` // Details is currently always a PolygonDetails Details interface{} `mapstructure:"details" json:"details"` }
Shape describes a single collision shape on a game object.
type SmartObjectAddedPacket ¶
type SmartObjectAddedPacket struct { // Type is smart-object-added Type string `mapstructure:"type" json:"type"` // GameTime is the time at which this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` // Object is the object that just entered view. Object SmartObjectSync `mapstructure:"object" json:"object"` }
SmartObjectAddedPacket is a top-level packet that can be sent to a client to inform them a new smart object came into view.
func (*SmartObjectAddedPacket) GetType ¶
func (p *SmartObjectAddedPacket) GetType() string
func (*SmartObjectAddedPacket) PrepareForMarshal ¶
func (p *SmartObjectAddedPacket) PrepareForMarshal()
type SmartObjectSync ¶
type SmartObjectSync struct { GameObjectSync // UnitType is the identifier of the Unit this smart object is. Generally // AIs will use this to determine what orders are available for the unit, // e.g, a "market" unit might have a "buy" order. UnitType string `mapstructure:"unit_type" json:"unit_type"` // CurrentHealth is the current amount of health this object has. This // value may be a rounded representation of the objects true health. CurrentHealth int `mapstructure:"current_health" json:"current_health"` // MaxHealth is the maximum amount of health this object can have. MaxHealth int `mapstructure:"max_health" json:"max_health"` // ControllingTeam is the team which controls this object. ControllingTeam int `mapstructure:"controlling_team" json:"controlling_team"` // ControllingRole is the role required to control this object. See core.Role // and core.RoleToName. ControllingRole string `mapstructure:"controlling_role" json:"controlling_role"` // Additional contains the SyncInfo on the Unit controlling this smart object, // and depends on the type of unit. Additional interface{} `mapstructure:"additional" json:"additional"` }
SmartObjectSync provides all the information required to know about a SmartObject for a client who has never seen it before.
type SmartObjectUpdatePacket ¶
type SmartObjectUpdatePacket struct { GameObjectUpdatePacket // CurrentHealth is how much health this smart object has. This may be // a rounded representation of the objects true health. CurrentHealth int `mapstructure:"current_health" json:"current_health"` // Additional depends on the UnitType of this smart object. Additional interface{} `mapstructure:"additional" json:"additional"` }
SmartObjectUpdatePacket informs the client about an update to a smart object
func (*SmartObjectUpdatePacket) GetType ¶
func (p *SmartObjectUpdatePacket) GetType() string
func (*SmartObjectUpdatePacket) PrepareForMarshal ¶
func (p *SmartObjectUpdatePacket) PrepareForMarshal()
type TeamResourceChangedPacket ¶
type TeamResourceChangedPacket struct { // Type is team-resource-changed Type string `mapstructure:"type" json:"type"` // GameTime is the time at which this packet was sent GameTime float64 `mapstructure:"game_time" json:"game_time"` // Resources contains a subset (not necessarily strict) of the teams // resources; for each key in this map, the value is the amount // of that resource the team has Resources map[string]int `mapstructure:"resources" json:"resources"` }
TeamResourceChangedPacket informs a player that he amount of resources their team has has changed
func (*TeamResourceChangedPacket) GetType ¶
func (p *TeamResourceChangedPacket) GetType() string
func (*TeamResourceChangedPacket) PrepareForMarshal ¶
func (p *TeamResourceChangedPacket) PrepareForMarshal()
Source Files ¶
- chat_author_added_packet.go
- chat_author_removed_packet.go
- chat_author_sync.go
- chat_author_update_packet.go
- chat_message_packet.go
- game_object_added_packet.go
- game_object_removed_packet.go
- game_object_sync.go
- game_object_update_packet.go
- game_sync_packet.go
- packet.go
- parse_packet.go
- player_added_packet.go
- player_sync.go
- resource_sync.go
- shape.go
- smart_object_added_packet.go
- smart_object_sync.go
- smart_object_update_packet.go
- team_resource_changed_packet.go
- vector.go