注释补充

This commit is contained in:
kercylan98 2023-05-05 15:18:46 +08:00
parent 2113a7be01
commit e3804a086b
3 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import (
"sync/atomic"
)
// NewWorld 创建一个内置的游戏世界
func NewWorld[PlayerID comparable, Player game.Player[PlayerID]](guid int64, options ...WorldOption[PlayerID, Player]) *World[PlayerID, Player] {
world := &World[PlayerID, Player]{
guid: guid,
@ -23,6 +24,7 @@ func NewWorld[PlayerID comparable, Player game.Player[PlayerID]](guid int64, opt
return world
}
// World 游戏世界的内置实现,实现了基本的游戏世界接口
type World[PlayerID comparable, Player game.Player[PlayerID]] struct {
guid int64
actorGuid atomic.Int64

View File

@ -3,6 +3,6 @@ package builtin
import "errors"
var (
ErrWorldPlayerLimit = errors.New("the number of players in the world has reached the upper limit")
ErrWorldReleased = errors.New("the world has been released")
ErrWorldPlayerLimit = errors.New("the number of players in the world has reached the upper limit") // 玩家数量达到上限
ErrWorldReleased = errors.New("the world has been released") // 世界已被释放
)

View File

@ -2,8 +2,10 @@ package builtin
import "minotaur/game"
// WorldOption 世界构建可选项
type WorldOption[PlayerID comparable, Player game.Player[PlayerID]] func(world *World[PlayerID, Player])
// WithWorldPlayerLimit 限制世界的玩家数量上限
func WithWorldPlayerLimit[PlayerID comparable, Player game.Player[PlayerID]](playerLimit int) WorldOption[PlayerID, Player] {
return func(world *World[PlayerID, Player]) {
world.playerLimit = playerLimit