game

package
v0.0.0-...-3befcbb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TICKRATE    = time.Second / 5
	MINUTES_DAY = 24 * 60
	BOT_COUNT   = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	// current time
	// we wrap around {MINUTES_DAY}
	Time   float32
	Ticker *time.Ticker

	SpawnPosition schema.Position

	Players      []*p.Player
	ItemEntities []*gameItem.ItemEntity

	Register   chan *p.Player
	Unregister chan *p.Player
	Broadcast  chan messages.BroadcastMessage
}

func NewGame

func NewGame() *Game

func (*Game) AddBots

func (game *Game) AddBots(amount int)

func (*Game) DispatchPlayerJoin

func (g *Game) DispatchPlayerJoin(ctx context.Context, player *p.Player)

func (*Game) DispatchPlayerLeave

func (g *Game) DispatchPlayerLeave(ctx context.Context, player *p.Player)

func (*Game) GenerateHandshakeData

func (g *Game) GenerateHandshakeData(ctx context.Context, client *ent.Client, player *p.Player) HandshakeData

func (*Game) GenerateItemEntitiesData

func (g *Game) GenerateItemEntitiesData() []gameItem.ItemEntityData

func (*Game) GeneratePlayersData

func (g *Game) GeneratePlayersData() []p.PlayerData

func (*Game) HandleGameMessages

func (g *Game) HandleGameMessages(ctx context.Context, client *ent.Client, conn *websocket.Conn)

func (*Game) HandlePlayerJoin

func (g *Game) HandlePlayerJoin(ctx context.Context, conn *websocket.Conn, client *ent.Client, gameHustler *ent.GameHustler)

func (*Game) PlayerByConn

func (g *Game) PlayerByConn(conn *websocket.Conn) *p.Player

func (*Game) PlayerByHustlerID

func (g *Game) PlayerByHustlerID(id string) *p.Player

func (*Game) PlayerByUUID

func (g *Game) PlayerByUUID(uuid uuid.UUID) *p.Player

func (*Game) Start

func (g *Game) Start(ctx context.Context, client *ent.Client)

type HandshakeData

type HandshakeData struct {
	Id         string  `json:"id"`
	CurrentMap string  `json:"current_map"`
	X          float32 `json:"x"`
	Y          float32 `json:"y"`
	// citizen: relation{}
	Relations json.RawMessage `json:"relations"`

	Players      []p.PlayerData            `json:"players"`
	ItemEntities []gameItem.ItemEntityData `json:"itemEntities"`
}

type PlayerJoinData

type PlayerJoinData struct {
	Name      string `json:"name"`
	HustlerId string `json:"hustlerId"`
}

type TickData

type TickData struct {
	Time    float32            `json:"time"`
	Tick    int64              `json:"tick"`
	Players []p.PlayerMoveData `json:"players"`
}

Directories

Path Synopsis
api
ws

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL