Documentation ¶
Index ¶
- Variables
- func GlobalSessionManager() *internal.Map[string, *Session]
- type Allower
- type Config
- type Factory
- type FactoryConfig
- type Game
- func (g *Game) End(tx *world.Tx)
- func (g *Game) ID() uuid.UUID
- func (g *Game) Impl() Impl
- func (g *Game) InGame(p *player.Player) bool
- func (g *Game) Join(p *player.Player) error
- func (g *Game) Leave(p *player.Player) (bool, error)
- func (g *Game) Load() error
- func (g *Game) Map() *Map
- func (g *Game) MapLoaded() bool
- func (g *Game) Messagef(tx *world.Tx, format string, args ...any)
- func (g *Game) ParticipantByXUID(xuid string) (*Participant, bool)
- func (g *Game) ParticipantLen() int
- func (g *Game) Participants() iter.Seq[*Participant]
- func (g *Game) Players(tx *world.Tx, fn func(p *player.Player, par *Participant))
- func (g *Game) PlayingParticipantLen() int
- func (g *Game) PlayingParticipants() iter.Seq[*Participant]
- func (g *Game) PlayingPlayers(tx *world.Tx, fn func(p *player.Player, par *Participant))
- func (g *Game) SetSpectator(p *player.Player)
- func (g *Game) Start(tx *world.Tx)
- func (g *Game) State() State
- func (g *Game) ValidTx(tx *world.Tx) (valid bool)
- type Impl
- type Map
- type Participant
- func (par *Participant) Closed() bool
- func (par *Participant) Impl() ParticipantImpl
- func (par *Participant) MustPlayer(tx *world.Tx) *player.Player
- func (par *Participant) Name() string
- func (par *Participant) Player(tx *world.Tx) (*player.Player, bool)
- func (par *Participant) State() ParticipantState
- func (par *Participant) XUID() string
- type ParticipantImpl
- type ParticipantState
- type PlayerHandler
- func (ph *PlayerHandler) HandleAttackEntity(ctx *player.Context, e world.Entity, force, height *float64, critical *bool)
- func (ph *PlayerHandler) HandleBlockBreak(ctx *player.Context, pos cube.Pos, drops *[]item.Stack, xp *int)
- func (ph *PlayerHandler) HandleBlockPick(ctx *player.Context, pos cube.Pos, b world.Block)
- func (ph *PlayerHandler) HandleBlockPlace(ctx *player.Context, pos cube.Pos, b world.Block)
- func (ph *PlayerHandler) HandleChangeWorld(p *player.Player, before, after *world.World)
- func (ph *PlayerHandler) HandleChat(ctx *player.Context, message *string)
- func (ph *PlayerHandler) HandleCommandExecution(ctx *player.Context, command cmd.Command, args []string)
- func (ph *PlayerHandler) HandleDeath(p *player.Player, src world.DamageSource, keepInv *bool)
- func (ph *PlayerHandler) HandleDiagnostics(p *player.Player, d session.Diagnostics)
- func (ph *PlayerHandler) HandleExperienceGain(ctx *player.Context, amount *int)
- func (ph *PlayerHandler) HandleFireExtinguish(ctx *player.Context, pos cube.Pos)
- func (ph *PlayerHandler) HandleFoodLoss(ctx *player.Context, from int, to *int)
- func (ph *PlayerHandler) HandleHeal(ctx *player.Context, health *float64, src world.HealingSource)
- func (ph *PlayerHandler) HandleHeldSlotChange(ctx *player.Context, from, to int)
- func (ph *PlayerHandler) HandleHurt(ctx *player.Context, damage *float64, immune bool, ...)
- func (ph *PlayerHandler) HandleItemConsume(ctx *player.Context, item item.Stack)
- func (ph *PlayerHandler) HandleItemDamage(ctx *player.Context, i item.Stack, damage int)
- func (ph *PlayerHandler) HandleItemDrop(ctx *player.Context, s item.Stack)
- func (ph *PlayerHandler) HandleItemPickup(ctx *player.Context, i *item.Stack)
- func (ph *PlayerHandler) HandleItemRelease(ctx *player.Context, item item.Stack, dur time.Duration)
- func (ph *PlayerHandler) HandleItemUse(ctx *player.Context)
- func (ph *PlayerHandler) HandleItemUseOnBlock(ctx *player.Context, pos cube.Pos, face cube.Face, clickPos mgl64.Vec3)
- func (ph *PlayerHandler) HandleItemUseOnEntity(ctx *player.Context, e world.Entity)
- func (ph *PlayerHandler) HandleJump(p *player.Player)
- func (ph *PlayerHandler) HandleLecternPageTurn(ctx *player.Context, pos cube.Pos, oldPage int, newPage *int)
- func (ph *PlayerHandler) HandleMove(ctx *player.Context, newPos mgl64.Vec3, newRot cube.Rotation)
- func (ph *PlayerHandler) HandlePunchAir(ctx *player.Context)
- func (ph *PlayerHandler) HandleQuit(p *player.Player)
- func (ph *PlayerHandler) HandleRespawn(p *player.Player, pos *mgl64.Vec3, w **world.World)
- func (ph *PlayerHandler) HandleSignEdit(ctx *player.Context, pos cube.Pos, frontSide bool, oldText, newText string)
- func (ph *PlayerHandler) HandleSkinChange(ctx *player.Context, skin *skin.Skin)
- func (ph *PlayerHandler) HandleStartBreak(ctx *player.Context, pos cube.Pos)
- func (ph *PlayerHandler) HandleTeleport(ctx *player.Context, pos mgl64.Vec3)
- func (ph *PlayerHandler) HandleToggleSneak(ctx *player.Context, after bool)
- func (ph *PlayerHandler) HandleToggleSprint(ctx *player.Context, after bool)
- func (ph *PlayerHandler) HandleTransfer(ctx *player.Context, addr *net.UDPAddr)
- type ResetPlayerHealSource
- type Session
- type SetterGame
- type State
Constants ¶
This section is empty.
Variables ¶
var DefaultWaitingWorld *world.World
Functions ¶
Types ¶
type Config ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is a factory for games.
type FactoryConfig ¶
type FactoryConfig struct {
CreateFunc func() *Game
}
FactoryConfig is a configuration for a game factory.
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game ...
func (*Game) Join ¶
Join is used to join a player to the game. If the game is not in the waiting State, an error is returned.
func (*Game) ParticipantByXUID ¶
func (g *Game) ParticipantByXUID(xuid string) (*Participant, bool)
ParticipantByXUID returns the participant with the XUID passed.
func (*Game) ParticipantLen ¶
ParticipantLen returns the amount of participants in the game.
func (*Game) Participants ¶
func (g *Game) Participants() iter.Seq[*Participant]
Participants returns the participants in the game.
func (*Game) Players ¶
Players are used to iterate over all players in the game, calling the function passed for each player.
func (*Game) PlayingParticipantLen ¶
PlayingParticipantLen returns the amount of participants in the game that are playing.
func (*Game) PlayingParticipants ¶
func (g *Game) PlayingParticipants() iter.Seq[*Participant]
PlayingParticipants returns the participants in the game that are playing.
func (*Game) PlayingPlayers ¶
PlayingPlayers are used to iterate over all players in the game that are playing, calling the function passed for each player.
func (*Game) SetSpectator ¶
SetSpectator is used to set a player to spectator mode.
type Impl ¶
type Impl interface { // MaxPlayers returns the maximum amount of players that can be in the game at once. MaxPlayers() int // MinPlayers returns the minimum amount of players that are required to start the game. MinPlayers() int // WaitingDuration returns the duration that the game should wait before starting after the minimum amount of players // has joined. WaitingDuration() time.Duration // HandleStart is called when the game should start. HandleStart(tx *world.Tx) // HandleQuit is called when a player quits the game. HandleQuit(tx *world.Tx, p *Participant) // HandleJoin is called when a player joins the game. HandleJoin(tx *world.Tx, p *Participant) // HandleClose is called when the game is closed. HandleClose(tx *world.Tx) // HandlePlayingTick is called every tick while the game is playing. HandlePlayingTick(tx *world.Tx, currentTick uint64) // RenderWaitingScoreboard renders the scoreboard for the waiting State. RenderWaitingScoreboard(p *player.Player, startingIn int, participantLen int) // RenderFinishedScoreboard renders the scoreboard for the finished State. RenderFinishedScoreboard(p *player.Player, closingIn int) // HandleMapReady is called when the map is ready to be played. HandleMapReady(tx *world.Tx, m *Map) // Load is called when the game is loaded. Load() // HandleParticipantCreate is called when a participant is created. It should return the implementation of the participant. HandleParticipantCreate(par *Participant) ParticipantImpl }
type Participant ¶
type Participant struct {
// contains filtered or unexported fields
}
func (*Participant) Closed ¶
func (par *Participant) Closed() bool
Closed returns whether the participant is closed.
func (*Participant) Impl ¶
func (par *Participant) Impl() ParticipantImpl
Impl returns the implementation of the participant.
func (*Participant) MustPlayer ¶
func (par *Participant) MustPlayer(tx *world.Tx) *player.Player
MustPlayer returns the player of the participant. If the participant is not a player, this function panics.
func (*Participant) Name ¶
func (par *Participant) Name() string
Name returns the name of the participant.
func (*Participant) Player ¶
Player returns the player of the participant. If the participant is not a player, the second return value is false.
func (*Participant) State ¶
func (par *Participant) State() ParticipantState
State returns the state of the participant.
func (*Participant) XUID ¶
func (par *Participant) XUID() string
XUID returns the XUID of the participant.
type ParticipantImpl ¶
type ParticipantImpl interface {
Close() error
}
type ParticipantState ¶
type ParticipantState uint8
const ( ParticipantStateUnknown ParticipantState = iota ParticipantStatePlaying ParticipantStateSpectating )
func (ParticipantState) Playing ¶
func (state ParticipantState) Playing() bool
func (ParticipantState) Spectating ¶
func (state ParticipantState) Spectating() bool
func (ParticipantState) Unknown ¶
func (state ParticipantState) Unknown() bool
type PlayerHandler ¶
type PlayerHandler struct{}
func (*PlayerHandler) HandleAttackEntity ¶
func (*PlayerHandler) HandleBlockBreak ¶
func (*PlayerHandler) HandleBlockPick ¶
func (*PlayerHandler) HandleBlockPlace ¶
func (*PlayerHandler) HandleChangeWorld ¶
func (ph *PlayerHandler) HandleChangeWorld(p *player.Player, before, after *world.World)
func (*PlayerHandler) HandleChat ¶
func (ph *PlayerHandler) HandleChat(ctx *player.Context, message *string)
func (*PlayerHandler) HandleCommandExecution ¶
func (*PlayerHandler) HandleDeath ¶
func (ph *PlayerHandler) HandleDeath(p *player.Player, src world.DamageSource, keepInv *bool)
func (*PlayerHandler) HandleDiagnostics ¶
func (ph *PlayerHandler) HandleDiagnostics(p *player.Player, d session.Diagnostics)
func (*PlayerHandler) HandleExperienceGain ¶
func (ph *PlayerHandler) HandleExperienceGain(ctx *player.Context, amount *int)
func (*PlayerHandler) HandleFireExtinguish ¶
func (ph *PlayerHandler) HandleFireExtinguish(ctx *player.Context, pos cube.Pos)
func (*PlayerHandler) HandleFoodLoss ¶
func (ph *PlayerHandler) HandleFoodLoss(ctx *player.Context, from int, to *int)
func (*PlayerHandler) HandleHeal ¶
func (ph *PlayerHandler) HandleHeal(ctx *player.Context, health *float64, src world.HealingSource)
func (*PlayerHandler) HandleHeldSlotChange ¶
func (ph *PlayerHandler) HandleHeldSlotChange(ctx *player.Context, from, to int)
func (*PlayerHandler) HandleHurt ¶
func (ph *PlayerHandler) HandleHurt(ctx *player.Context, damage *float64, immune bool, attackImmunity *time.Duration, src world.DamageSource)
func (*PlayerHandler) HandleItemConsume ¶
func (ph *PlayerHandler) HandleItemConsume(ctx *player.Context, item item.Stack)
func (*PlayerHandler) HandleItemDamage ¶
func (*PlayerHandler) HandleItemDrop ¶
func (ph *PlayerHandler) HandleItemDrop(ctx *player.Context, s item.Stack)
func (*PlayerHandler) HandleItemPickup ¶
func (ph *PlayerHandler) HandleItemPickup(ctx *player.Context, i *item.Stack)
func (*PlayerHandler) HandleItemRelease ¶
func (*PlayerHandler) HandleItemUse ¶
func (ph *PlayerHandler) HandleItemUse(ctx *player.Context)
func (*PlayerHandler) HandleItemUseOnBlock ¶
func (*PlayerHandler) HandleItemUseOnEntity ¶
func (ph *PlayerHandler) HandleItemUseOnEntity(ctx *player.Context, e world.Entity)
func (*PlayerHandler) HandleJump ¶
func (ph *PlayerHandler) HandleJump(p *player.Player)
func (*PlayerHandler) HandleLecternPageTurn ¶
func (*PlayerHandler) HandleMove ¶
func (*PlayerHandler) HandlePunchAir ¶
func (ph *PlayerHandler) HandlePunchAir(ctx *player.Context)
func (*PlayerHandler) HandleQuit ¶
func (ph *PlayerHandler) HandleQuit(p *player.Player)
func (*PlayerHandler) HandleRespawn ¶
func (*PlayerHandler) HandleSignEdit ¶
func (*PlayerHandler) HandleSkinChange ¶
func (ph *PlayerHandler) HandleSkinChange(ctx *player.Context, skin *skin.Skin)
func (*PlayerHandler) HandleStartBreak ¶
func (ph *PlayerHandler) HandleStartBreak(ctx *player.Context, pos cube.Pos)
func (*PlayerHandler) HandleTeleport ¶
func (ph *PlayerHandler) HandleTeleport(ctx *player.Context, pos mgl64.Vec3)
func (*PlayerHandler) HandleToggleSneak ¶
func (ph *PlayerHandler) HandleToggleSneak(ctx *player.Context, after bool)
func (*PlayerHandler) HandleToggleSprint ¶
func (ph *PlayerHandler) HandleToggleSprint(ctx *player.Context, after bool)
func (*PlayerHandler) HandleTransfer ¶
func (ph *PlayerHandler) HandleTransfer(ctx *player.Context, addr *net.UDPAddr)
type ResetPlayerHealSource ¶
type ResetPlayerHealSource struct{}
func (ResetPlayerHealSource) HealingSource ¶
func (ResetPlayerHealSource) HealingSource()
func (ResetPlayerHealSource) ResetPlayer ¶
func (ResetPlayerHealSource) ResetPlayer()
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
NewSession creates a new session for the player p.
func (*Session) EntityHandle ¶
func (s *Session) EntityHandle() *world.EntityHandle
EntityHandle returns the entity handle of the player that the session is for.
type SetterGame ¶
type SetterGame interface { // SetGame sets the game that the player is in. SetGame(g *Game) }