Documentation ¶
Index ¶
- Constants
- Variables
- func Dist(p1 image.Point, p2 image.Point) float64
- func NextStep(s image.Point, target image.Point) image.Point
- type Action
- type ActionType
- type ActionsHandler
- type DispatchFunc
- type GameLogic
- type GenericAction
- type MapLoadAction
- type MapLoadPayload
- type MapLoadSuccessAction
- type MapLoadSuccessPayload
- type MoveStartAction
- type MoveStartPayload
- type MoveStepAction
- type MoveStepPayload
- type MoveStopAction
- type PF
- type Player
- type PlayerIdType
- type PlayerJoinAction
- type PlayerJoinSuccessAction
- type PlayerJoinSuccessPayload
- type SpawnUnitAction
- type Store
- type StoreImpl
- func (s *StoreImpl) CreateTile(point image.Point) *Tile
- func (s *StoreImpl) GetAllPlayers() []*Player
- func (s *StoreImpl) GetAllUnits() []*Unit
- func (s *StoreImpl) GetPlayer(id PlayerIdType) (*Player, bool)
- func (s *StoreImpl) GetTile(point image.Point) (*Tile, bool)
- func (s *StoreImpl) GetTilesByRect(rect image.Rectangle) map[image.Point]*Tile
- func (s *StoreImpl) GetTilesByUnitId(id UnitIdType) []*Tile
- func (s *StoreImpl) GetUnitById(id UnitIdType) *Unit
- func (s *StoreImpl) GetUnitsByPlayerId(id PlayerIdType) []*Unit
- func (s *StoreImpl) StorePlayer(player Player)
- func (s *StoreImpl) StoreTile(tile world.Tile) *Tile
- func (s *StoreImpl) StoreUnit(unit *Unit)
- type Tile
- type Unit
- type UnitIdType
Constants ¶
View Source
const (
UnitSpeed = 0.1
)
Variables ¶
View Source
var ZeroPoint = image.Pt(0, 0)
View Source
var ZeroUnitId = UnitIdType(uuid.Nil)
Functions ¶
Types ¶
type Action ¶
type Action interface { GetType() ActionType GetPayload() any }
func UnmarshalAction ¶
type ActionType ¶
type ActionType string
const ( PlayerJoinActionType ActionType = "PlayerJoin" PlayerJoinSuccessActionType ActionType = "PlayerJoinSuccess" SpawnUnitActionType ActionType = "SpawnUnit" MoveStartActionType ActionType = "MoveStart" MoveStepActionType ActionType = "MoveStep" MoveStopActionType ActionType = "MoveStop" MapLoadActionType ActionType = "MapLoad" MapLoadSuccessActionType ActionType = "MapLoadSuccess" )
type ActionsHandler ¶
type ActionsHandler interface {
HandleAction(Action, DispatchFunc)
}
type DispatchFunc ¶
type DispatchFunc func(Action)
type GameLogic ¶
type GameLogic struct {
// contains filtered or unexported fields
}
func NewGameLogic ¶
func (*GameLogic) HandleAction ¶
func (g *GameLogic) HandleAction(action Action, dispatch DispatchFunc)
type GenericAction ¶
type GenericAction[T any] struct { Type ActionType Payload T }
func (GenericAction[T]) GetPayload ¶
func (a GenericAction[T]) GetPayload() any
func (GenericAction[T]) GetType ¶
func (a GenericAction[T]) GetType() ActionType
type MapLoadAction ¶
type MapLoadAction = GenericAction[MapLoadPayload]
func NewMapLoadAction ¶
func NewMapLoadAction(rect image.Rectangle, playerId PlayerIdType) MapLoadAction
type MapLoadPayload ¶
type MapLoadPayload struct { world.WorldRequest PlayerId PlayerIdType }
type MapLoadSuccessAction ¶
type MapLoadSuccessAction = GenericAction[MapLoadSuccessPayload]
type MapLoadSuccessPayload ¶
type MapLoadSuccessPayload struct { world.WorldResponse PlayerId PlayerIdType }
type MoveStartAction ¶
type MoveStartAction = GenericAction[MoveStartPayload]
type MoveStartPayload ¶
type MoveStartPayload struct { UnitId UnitIdType Point image.Point }
type MoveStepAction ¶
type MoveStepAction = GenericAction[MoveStepPayload]
type MoveStepPayload ¶
type MoveStepPayload struct { UnitId UnitIdType Position PF Path []image.Point Step int }
type MoveStopAction ¶
type MoveStopAction = GenericAction[UnitIdType]
type PF ¶
func (PF) ImagePoint ¶
type PlayerJoinAction ¶
type PlayerJoinAction = GenericAction[Player]
type PlayerJoinSuccessAction ¶
type PlayerJoinSuccessAction = GenericAction[PlayerJoinSuccessPayload]
type PlayerJoinSuccessPayload ¶
type PlayerJoinSuccessPayload struct { PlayerId PlayerIdType Units []Unit Players []Player }
type SpawnUnitAction ¶
type SpawnUnitAction = GenericAction[Unit]
type Store ¶
type Store interface { StoreUnit(unit *Unit) GetUnitById(id UnitIdType) *Unit GetAllUnits() []*Unit GetUnitsByPlayerId(id PlayerIdType) []*Unit GetPlayer(id PlayerIdType) (*Player, bool) GetAllPlayers() []*Player StorePlayer(player Player) GetTilesByUnitId(id UnitIdType) []*Tile StoreTile(tile world.Tile) *Tile GetTile(image.Point) (*Tile, bool) CreateTile(image.Point) *Tile GetTilesByRect(rect image.Rectangle) map[image.Point]*Tile }
type StoreImpl ¶
type StoreImpl struct {
// contains filtered or unexported fields
}
func NewStoreImpl ¶
func NewStoreImpl() *StoreImpl
func (*StoreImpl) GetAllPlayers ¶
func (*StoreImpl) GetAllUnits ¶
func (*StoreImpl) GetTilesByRect ¶
func (*StoreImpl) GetTilesByUnitId ¶
func (s *StoreImpl) GetTilesByUnitId(id UnitIdType) []*Tile
func (*StoreImpl) GetUnitById ¶
func (s *StoreImpl) GetUnitById(id UnitIdType) *Unit
func (*StoreImpl) GetUnitsByPlayerId ¶
func (s *StoreImpl) GetUnitsByPlayerId(id PlayerIdType) []*Unit
func (*StoreImpl) StorePlayer ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.