Documentation ¶
Index ¶
- Constants
- func SendAllToOne(conn net.Conn, gs *GameState)
- func SendOneToAll[T protoreflect.ProtoMessage](gs *GameState, packet T)
- func SendOneToOne[T protoreflect.ProtoMessage](conn net.Conn, gs *GameState, packet T)
- func UpdateCombatSystem(gs *GameState)
- func UpdateZombiesSystem(gs *GameState)
- type Chunk
- type GameState
- func (gs *GameState) AddChunks(chunks []*Chunk)
- func (gs *GameState) AddPlayer(p *components.Player)
- func (gs *GameState) GetChunkAtCoords(x, y int64) *Chunk
- func (gs *GameState) GetChunksAroundPlayer(p *components.Player) ([]*Chunk, []*Chunk)
- func (gs *GameState) GetIntStore(key string) (int64, bool)
- func (gs *GameState) GetPlayer(playerID int64) *components.Player
- func (gs *GameState) GetPlayersAroundPlayer(p *components.Player) []*components.Player
- func (gs *GameState) GetTerrainAtCoords(x, y int64) byte
- func (gs *GameState) HandlePlayerAction(player *components.Player, action int32)
- func (gs *GameState) InitNewPlayer(newPlayer *components.Player)
- func (gs *GameState) InitNewZombie(newZombie *components.Zombie, x, y int64)
- func (gs *GameState) MovePlayer(playerID components.EntityId, x, y int64)
- func (gs *GameState) NextEntityId() components.EntityId
- func (gs *GameState) RemovePlayer(playerID components.EntityId)
- func (gs *GameState) RemoveZombie(zombieID components.EntityId)
- func (gs *GameState) RunGameLoop()
- func (gs *GameState) SetIntStore(key string, value int64)
- func (gs *GameState) UpdatePlayerChunks(playerID components.EntityId, x, y int64)
- func (gs *GameState) UpdatePositionComponent(entityId components.EntityId, position *components.Position)
- func (gs *GameState) UpdateSpriteComponent(entityId components.EntityId, sprite *components.Sprite)
- func (gs *GameState) UseItem(p *components.Player, itemID int64)
Constants ¶
View Source
const ( CHUNK_W int64 = 8 CHUNK_H int64 = 8 )
Variables ¶
This section is empty.
Functions ¶
func SendAllToOne ¶
func SendOneToAll ¶
func SendOneToAll[T protoreflect.ProtoMessage](gs *GameState, packet T)
func SendOneToOne ¶
func SendOneToOne[T protoreflect.ProtoMessage](conn net.Conn, gs *GameState, packet T)
func UpdateCombatSystem ¶
func UpdateCombatSystem(gs *GameState)
func UpdateZombiesSystem ¶
func UpdateZombiesSystem(gs *GameState)
Types ¶
type Chunk ¶
func ParseChunksFromBytes ¶
func (*Chunk) FillPerlin ¶
func (c *Chunk) FillPerlin()
func (*Chunk) GetTopBlock ¶
type GameState ¶
type GameState struct { EntityCounter int64 PlayerComponents map[components.EntityId]*components.Player ZombieComponents map[components.EntityId]*components.Zombie SpriteComponents map[components.EntityId]*components.Sprite PositionComponents map[components.EntityId]*components.Position Mutex sync.Mutex Logger *log.Logger Chunks map[int64]map[int64]*Chunk IntStore map[string]int64 TPS int // ticks per second }
func NewGameState ¶
func NewGameState() *GameState
func (*GameState) AddPlayer ¶
func (gs *GameState) AddPlayer(p *components.Player)
func (*GameState) GetChunkAtCoords ¶
func (*GameState) GetChunksAroundPlayer ¶
func (gs *GameState) GetChunksAroundPlayer(p *components.Player) ([]*Chunk, []*Chunk)
func (*GameState) GetPlayersAroundPlayer ¶
func (gs *GameState) GetPlayersAroundPlayer(p *components.Player) []*components.Player
func (*GameState) GetTerrainAtCoords ¶
func (*GameState) HandlePlayerAction ¶
func (gs *GameState) HandlePlayerAction(player *components.Player, action int32)
func (*GameState) InitNewPlayer ¶
func (gs *GameState) InitNewPlayer(newPlayer *components.Player)
func (*GameState) InitNewZombie ¶
func (gs *GameState) InitNewZombie(newZombie *components.Zombie, x, y int64)
func (*GameState) MovePlayer ¶
func (gs *GameState) MovePlayer(playerID components.EntityId, x, y int64)
func (*GameState) NextEntityId ¶
func (gs *GameState) NextEntityId() components.EntityId
func (*GameState) RemovePlayer ¶
func (gs *GameState) RemovePlayer(playerID components.EntityId)
func (*GameState) RemoveZombie ¶
func (gs *GameState) RemoveZombie(zombieID components.EntityId)
func (*GameState) RunGameLoop ¶
func (gs *GameState) RunGameLoop()
func (*GameState) SetIntStore ¶
func (*GameState) UpdatePlayerChunks ¶
func (gs *GameState) UpdatePlayerChunks(playerID components.EntityId, x, y int64)
func (*GameState) UpdatePositionComponent ¶
func (gs *GameState) UpdatePositionComponent(entityId components.EntityId, position *components.Position)
func (*GameState) UpdateSpriteComponent ¶
func (gs *GameState) UpdateSpriteComponent(entityId components.EntityId, sprite *components.Sprite)
Click to show internal directories.
Click to hide internal directories.