igame

package
v0.0.0-...-205331c Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IGame

type IGame interface {
	Join(p *player.Player) error
	Quit(p *player.Player) error
	SetCloseHook(func())
	ID() string
	IsWaiting() bool
	IsPlaying() bool
	IsEnding() bool
	CurrentTick() uint64
	Participants() map[string]IParticipant
	PlayingParticipants() map[string]IParticipant
	End()
	World() *world.World
	Players(tx *world.Tx) []*player.Player
	SetSpectator(p *player.Player)
	HandleBlockBreak(ctx *player.Context, pos cube.Pos, drops *[]item.Stack, xp *int)
	HandleBlockPlace(ctx *player.Context, pos cube.Pos, b world.Block)
	HandleMove(ctx *player.Context, pos mgl64.Vec3, rot cube.Rotation)
	HandleFoodLoss(ctx *player.Context, from int, to *int)
	HandleHeal(ctx *player.Context, health *float64, src world.HealingSource)
	HandleHurt(ctx *player.Context, damage *float64, immune bool, immunity *time.Duration, src world.DamageSource)
	HandleItemUse(ctx *player.Context)
	HandleItemUseOnEntity(ctx *player.Context, e world.Entity)
	HandleAttackEntity(ctx *player.Context, e world.Entity, force *float64, height *float64, critical *bool)
	HandleDrop(ctx *inventory.Context, slot int, stack item.Stack)
	HandlePlace(ctx *inventory.Context, slot int, stack item.Stack)
	HandleTake(ctx *inventory.Context, slot int, stack item.Stack)
	Load() error
	Messaget(translationName string, args ...any)
	Sound(name string)
	HandleItemPickup(ctx *player.Context, i *item.Stack)
	SetPlayAgainHook(hook func(p *player.Player) error)
	SetDuelRequestMode(b bool)
}

type IParticipant

type IParticipant interface {
	XUID() string
	User() User
	IsSpectating() bool
	IsPlaying() bool
	PearlCooldown() time.Time
	SetPearlCooldown(time.Time)
}

type Impl

type Impl interface {
	// PlayingTime returns the playing time of the game in seconds.
	PlayingTime() int
	// WaitingTime returns the waiting time of the game in seconds.
	WaitingTime() int
	// EndingTime returns the ending time of the game in seconds.
	EndingTime() int
	// MaxParticipants returns the maximum number of participants in the game.
	MaxParticipants() int
	// MinimumParticipants returns the minimum number of participants in the game.
	MinimumParticipants() int
	// GameName returns the name of the game.
	GameName() string
	// OnJoin is called when a player joins the game. Return an error to prevent the player from joining.
	OnJoin(p *player.Player) error
	// OnJoined is called when a player has successfully joined the game.
	OnJoined(par IParticipant, p *player.Player)
	// OnQuit is called when a player quits the game.
	OnQuit(p *player.Player)
	// OnInit is called when the game is initialized.
	OnInit()
	// OnStart is called when the game starts.
	OnStart()
	// OnEnd is called when the game ends.
	OnEnd()
	// OnStop is called when the game stops.
	OnStop()
	// OnTick is called every 50 milliseconds.
	OnTick()
	// CheckEnd is called when the game should check if it should end or not.
	CheckEnd()
	// Game returns the game instance.
	Game() IGame
	// Create sets the game instance.
	Create(g IGame)
	// AllowBuild returns whether the player is allowed to place or break blocks.
	AllowBuild() bool

	HandleHurt(ctx *player.Context, damage *float64, immune bool, immunity *time.Duration, src world.DamageSource)
	HandleHeal(ctx *player.Context, health *float64, src world.HealingSource)
	HandleFoodLoss(ctx *player.Context, from int, to *int)
	HandleBlockBreak(ctx *player.Context, pos cube.Pos, drops *[]item.Stack, xp *int)
	HandleBlockPlace(ctx *player.Context, pos cube.Pos, b world.Block)
	HandleMove(ctx *player.Context, pos mgl64.Vec3, rot cube.Rotation)
	HandleAttackEntity(ctx *player.Context, e world.Entity, force *float64, height *float64, critical *bool)
	HandleItemUse(ctx *player.Context)
	HandleItemUseOnEntity(ctx *player.Context, e world.Entity)
	HandleDrop(ctx *inventory.Context, slot int, stack item.Stack)
	HandlePlace(ctx *inventory.Context, slot int, stack item.Stack)
	HandleTake(ctx *inventory.Context, slot int, stack item.Stack)
}

type Nop

type Nop struct {
}

func (Nop) AllowBuild

func (g Nop) AllowBuild() bool

func (Nop) CheckEnd

func (g Nop) CheckEnd()

func (Nop) Create

func (g Nop) Create(_ IGame)

func (Nop) EndingTime

func (g Nop) EndingTime() int

func (Nop) Game

func (g Nop) Game() IGame

func (Nop) GameName

func (g Nop) GameName() string

func (Nop) HandleAttackEntity

func (g Nop) HandleAttackEntity(ctx *player.Context, e world.Entity, force *float64, height *float64, critical *bool)

func (Nop) HandleBlockBreak

func (g Nop) HandleBlockBreak(ctx *player.Context, pos cube.Pos, drops *[]item.Stack, xp *int)

func (Nop) HandleBlockPlace

func (g Nop) HandleBlockPlace(ctx *player.Context, pos cube.Pos, b world.Block)

func (Nop) HandleDrop

func (g Nop) HandleDrop(ctx *inventory.Context, slot int, stack item.Stack)

func (Nop) HandleFoodLoss

func (g Nop) HandleFoodLoss(ctx *player.Context, from int, to *int)

func (Nop) HandleHeal

func (g Nop) HandleHeal(ctx *player.Context, health *float64, src world.HealingSource)

func (Nop) HandleHurt

func (g Nop) HandleHurt(ctx *player.Context, damage *float64, immune bool, immunity *time.Duration, src world.DamageSource)

func (Nop) HandleItemUse

func (g Nop) HandleItemUse(ctx *player.Context)

func (Nop) HandleItemUseOnEntity

func (g Nop) HandleItemUseOnEntity(ctx *player.Context, e world.Entity)

func (Nop) HandleMove

func (g Nop) HandleMove(ctx *player.Context, pos mgl64.Vec3, rot cube.Rotation)

func (Nop) HandlePlace

func (g Nop) HandlePlace(ctx *inventory.Context, slot int, stack item.Stack)

func (Nop) HandleTake

func (g Nop) HandleTake(ctx *inventory.Context, slot int, stack item.Stack)

func (Nop) MaxParticipants

func (g Nop) MaxParticipants() int

func (Nop) MinimumParticipants

func (g Nop) MinimumParticipants() int

func (Nop) OnEnd

func (g Nop) OnEnd()

func (Nop) OnInit

func (g Nop) OnInit()

func (Nop) OnJoin

func (g Nop) OnJoin(p *player.Player) error

func (Nop) OnJoined

func (g Nop) OnJoined(par IParticipant, p *player.Player)

func (Nop) OnQuit

func (g Nop) OnQuit(p *player.Player)

func (Nop) OnStart

func (g Nop) OnStart()

func (Nop) OnStop

func (g Nop) OnStop()

func (Nop) OnTick

func (g Nop) OnTick()

func (Nop) PlayingTime

func (g Nop) PlayingTime() int

func (Nop) WaitingTime

func (g Nop) WaitingTime() int

type User

type User interface {
	XUID() string
	Ping() int
	EntityHandle() *world.EntityHandle
	SendScoreboard(lines []string)
	Player(tx *world.Tx) (*player.Player, bool)
	Conn() session.Conn
	Translatef(format string, args ...any) string
	Messaget(translationName string, args ...any)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳