Documentation ¶
Overview ¶
Package builtin 包含了通用游戏相关的接口的内置实现
Index ¶
- Variables
- type AOI2D
- func (slf *AOI2D) AddEntity(entity game.AOIEntity2D)
- func (slf *AOI2D) DeleteEntity(entity game.AOIEntity2D)
- func (slf *AOI2D) GetFocus(guid int64) map[int64]game.AOIEntity2D
- func (slf *AOI2D) OnEntityJoinVisionEvent(entity, target game.AOIEntity2D)
- func (slf *AOI2D) OnEntityLeaveVisionEvent(entity, target game.AOIEntity2D)
- func (slf *AOI2D) Refresh(entity game.AOIEntity2D)
- func (slf *AOI2D) RegEntityJoinVisionEvent(handle game.EntityJoinVisionEventHandle)
- func (slf *AOI2D) RegEntityLeaveVisionEvent(handle game.EntityLeaveVisionEventHandle)
- func (slf *AOI2D) SetAreaSize(width, height int)
- func (slf *AOI2D) SetSize(width, height int)
- type Actor
- type Attrs
- func (slf *Attrs) ChangeAttrFloat32(id int, value float32)
- func (slf *Attrs) ChangeAttrFloat64(id int, value float64)
- func (slf *Attrs) ChangeAttrHugeInt(id int, value *huge.Int)
- func (slf *Attrs) ChangeAttrInt(id int, value int)
- func (slf *Attrs) ChangeAttrInt16(id int, value int16)
- func (slf *Attrs) ChangeAttrInt32(id int, value int32)
- func (slf *Attrs) ChangeAttrInt64(id int, value int64)
- func (slf *Attrs) ChangeAttrInt8(id int, value int8)
- func (slf *Attrs) ChangeAttrUint(id int, value uint)
- func (slf *Attrs) ChangeAttrUint16(id int, value uint16)
- func (slf *Attrs) ChangeAttrUint32(id int, value uint32)
- func (slf *Attrs) ChangeAttrUint64(id int, value uint64)
- func (slf *Attrs) ChangeAttrUint8(id int, value uint8)
- func (slf *Attrs) GetAttrFloat32(id int) float32
- func (slf *Attrs) GetAttrFloat64(id int) float64
- func (slf *Attrs) GetAttrHugeInt(id int) *huge.Int
- func (slf *Attrs) GetAttrInt(id int) int
- func (slf *Attrs) GetAttrInt16(id int) int16
- func (slf *Attrs) GetAttrInt32(id int) int32
- func (slf *Attrs) GetAttrInt64(id int) int64
- func (slf *Attrs) GetAttrInt8(id int) int8
- func (slf *Attrs) GetAttrUint(id int) uint
- func (slf *Attrs) GetAttrUint16(id int) uint16
- func (slf *Attrs) GetAttrUint32(id int) uint32
- func (slf *Attrs) GetAttrUint64(id int) uint64
- func (slf *Attrs) GetAttrUint8(id int) uint8
- func (slf *Attrs) OnAttrChangeEvent(id int)
- func (slf *Attrs) OnAttrIdChangeEvent(id int)
- func (slf *Attrs) RegAttrChangeEvent(handle game.AttrChangeEventHandle)
- func (slf *Attrs) RegAttrIdChangeEvent(id int, handle game.AttrChangeEventHandle)
- func (slf *Attrs) SetAttrFloat32(id int, value float32)
- func (slf *Attrs) SetAttrFloat64(id int, value float64)
- func (slf *Attrs) SetAttrHugeInt(id int, value *huge.Int)
- func (slf *Attrs) SetAttrInt(id int, value int)
- func (slf *Attrs) SetAttrInt16(id int, value int16)
- func (slf *Attrs) SetAttrInt32(id int, value int32)
- func (slf *Attrs) SetAttrInt64(id int, value int64)
- func (slf *Attrs) SetAttrInt8(id int, value int8)
- func (slf *Attrs) SetAttrUint(id int, value uint)
- func (slf *Attrs) SetAttrUint16(id int, value uint16)
- func (slf *Attrs) SetAttrUint32(id int, value uint32)
- func (slf *Attrs) SetAttrUint64(id int, value uint64)
- func (slf *Attrs) SetAttrUint8(id int, value uint8)
- type FSM
- type FSMState
- type Gameplay
- func (slf *Gameplay) GameStart(handle func() error) error
- func (slf *Gameplay) GetCurrentTime() time.Time
- func (slf *Gameplay) GetTime() *offset.Time
- func (slf *Gameplay) OnGameplayReleaseEvent()
- func (slf *Gameplay) OnGameplayStartEvent()
- func (slf *Gameplay) OnGameplayTimeChangeEvent()
- func (slf *Gameplay) RegGameplayReleaseEvent(handle game.GameplayReleaseEventHandle)
- func (slf *Gameplay) RegGameplayStartEvent(handle game.GameplayStartEventHandle)
- func (slf *Gameplay) RegGameplayTimeChangeEvent(handle game.GameplayTimeChangeEventHandle)
- func (slf *Gameplay) Release()
- func (slf *Gameplay) SetTimeOffset(offset time.Duration)
- type GameplayOver
- type GameplayTime
- type GameplayTimeOption
- type Item
- type ItemContainer
- func (slf *ItemContainer[ItemID, Item]) AddItem(item Item, count *huge.Int) (guid int64, err error)
- func (slf *ItemContainer[ItemID, Item]) CheckAllowAdd(item Item, count *huge.Int) error
- func (slf *ItemContainer[ItemID, Item]) CheckDeductItem(guid int64, count *huge.Int) error
- func (slf *ItemContainer[ItemID, Item]) Clear()
- func (slf *ItemContainer[ItemID, Item]) DeductItem(guid int64, count *huge.Int) error
- func (slf *ItemContainer[ItemID, Item]) ExistItem(guid int64) bool
- func (slf *ItemContainer[ItemID, Item]) ExistItemWithID(id ItemID) bool
- func (slf *ItemContainer[ItemID, Item]) GetItem(guid int64) (game.ItemContainerMember[ItemID, Item], error)
- func (slf *ItemContainer[ItemID, Item]) GetItems() []game.ItemContainerMember[ItemID, Item]
- func (slf *ItemContainer[ItemID, Item]) GetItemsFull() []game.ItemContainerMember[ItemID, Item]
- func (slf *ItemContainer[ItemID, Item]) GetItemsMap() map[int64]game.ItemContainerMember[ItemID, Item]
- func (slf *ItemContainer[ItemID, Item]) GetSize() int
- func (slf *ItemContainer[ItemID, Item]) GetSizeLimit() int
- func (slf *ItemContainer[ItemID, Item]) Remove(guid int64)
- func (slf *ItemContainer[ItemID, Item]) RemoveWithID(id ItemID)
- func (slf *ItemContainer[ItemID, Item]) SetExpandSize(size int)
- func (slf *ItemContainer[ItemID, Item]) TransferTo(guid int64, count *huge.Int, target game.ItemContainer[ItemID, Item]) error
- type ItemContainerMember
- type ItemContainerOption
- type Player
- type RankingList
- func (slf *RankingList[CompetitorID, Score]) Clear()
- func (slf *RankingList[CompetitorID, Score]) Cmp(s1, s2 Score) int
- func (slf *RankingList[CompetitorID, Score]) Competitor(competitorId CompetitorID, score Score)
- func (slf *RankingList[CompetitorID, Score]) CompetitorIncrease(competitorId CompetitorID, score Score)
- func (slf *RankingList[CompetitorID, Score]) GetAllCompetitor() []CompetitorID
- func (slf *RankingList[CompetitorID, Score]) GetCompetitor(rank int) (competitorId CompetitorID, err error)
- func (slf *RankingList[CompetitorID, Score]) GetCompetitorWithRange(start, end int) ([]CompetitorID, error)
- func (slf *RankingList[CompetitorID, Score]) GetRank(competitorId CompetitorID) (int, error)
- func (slf *RankingList[CompetitorID, Score]) GetScore(competitorId CompetitorID) (score Score, err error)
- func (slf *RankingList[CompetitorID, Score]) MarshalJSON() ([]byte, error)
- func (slf *RankingList[CompetitorID, Score]) OnRankChangeEvent(competitorId CompetitorID, oldRank, newRank int, oldScore, newScore Score)
- func (slf *RankingList[CompetitorID, Score]) OnRankClearBeforeEvent()
- func (slf *RankingList[CompetitorID, Score]) RegRankChangeEvent(handle game.RankChangeEventHandle[CompetitorID, Score])
- func (slf *RankingList[CompetitorID, Score]) RegRankClearBeforeEvent(handle game.RankClearBeforeEventHandle[CompetitorID, Score])
- func (slf *RankingList[CompetitorID, Score]) RemoveCompetitor(competitorId CompetitorID)
- func (slf *RankingList[CompetitorID, Score]) Size() int
- func (slf *RankingList[CompetitorID, Score]) UnmarshalJSON(bytes []byte) error
- type RankingListOption
- type Room
- func (slf *Room[PlayerID, Player]) ChangeOwner(id PlayerID)
- func (slf *Room[PlayerID, Player]) GetGuid() int64
- func (slf *Room[PlayerID, Player]) GetPlayer(id PlayerID) Player
- func (slf *Room[PlayerID, Player]) GetPlayerCount() int
- func (slf *Room[PlayerID, Player]) GetPlayerLimit() int
- func (slf *Room[PlayerID, Player]) GetPlayers() hash.MapReadonly[PlayerID, Player]
- func (slf *Room[PlayerID, Player]) IsExistPlayer(id PlayerID) bool
- func (slf *Room[PlayerID, Player]) IsOwner(id PlayerID) bool
- func (slf *Room[PlayerID, Player]) Join(player Player) error
- func (slf *Room[PlayerID, Player]) KickOut(id, target PlayerID, reason string) error
- func (slf *Room[PlayerID, Player]) Leave(id PlayerID)
- func (slf *Room[PlayerID, Player]) OnPlayerJoinRoomEvent(player Player)
- func (slf *Room[PlayerID, Player]) OnPlayerKickedOutEvent(executor, kicked PlayerID, reason string)
- func (slf *Room[PlayerID, Player]) OnPlayerLeaveRoomEvent(player Player)
- func (slf *Room[PlayerID, Player]) RegPlayerJoinRoomEvent(handle game.PlayerJoinRoomEventHandle[PlayerID, Player])
- func (slf *Room[PlayerID, Player]) RegPlayerKickedOutEvent(handle game.PlayerKickedOutEventHandle[PlayerID, Player])
- func (slf *Room[PlayerID, Player]) RegPlayerLeaveRoomEvent(handle game.PlayerLeaveRoomEventHandle[PlayerID, Player])
- type RoomManager
- type RoomOption
- func WithRoomKickPlayerCheckHandle[PlayerID comparable, Player game.Player[PlayerID]](handle func(room *Room[PlayerID, Player], id, target PlayerID) error) RoomOption[PlayerID, Player]
- func WithRoomNoMaster[PlayerID comparable, Player game.Player[PlayerID]]() RoomOption[PlayerID, Player]
- func WithRoomPlayerLimit[PlayerID comparable, Player game.Player[PlayerID]](playerLimit int) RoomOption[PlayerID, Player]
- func WithRoomSync[PlayerID comparable, Player game.Player[PlayerID]]() RoomOption[PlayerID, Player]
- type RoomSeat
- func (slf *RoomSeat[PlayerID, Player]) AddSeat(id PlayerID)
- func (slf *RoomSeat[PlayerID, Player]) AddSeatWithAssign(id PlayerID, seat int)
- func (slf *RoomSeat[PlayerID, Player]) GetFirstSeat() int
- func (slf *RoomSeat[PlayerID, Player]) GetNextSeat(seat int) int
- func (slf *RoomSeat[PlayerID, Player]) GetNextSeatVacancy(seat int) int
- func (slf *RoomSeat[PlayerID, Player]) GetPlayerIDWithSeat(seat int) (playerId PlayerID, err error)
- func (slf *RoomSeat[PlayerID, Player]) GetSeat(id PlayerID) (int, error)
- func (slf *RoomSeat[PlayerID, Player]) GetSeatInfo() []*PlayerID
- func (slf *RoomSeat[PlayerID, Player]) GetSeatInfoMap() map[int]PlayerID
- func (slf *RoomSeat[PlayerID, Player]) GetSeatInfoMapVacancy() map[int]*PlayerID
- func (slf *RoomSeat[PlayerID, Player]) GetSeatInfoWithPlayerIDMap() map[PlayerID]int
- func (slf *RoomSeat[PlayerID, Player]) RemovePlayerSeat(id PlayerID)
- func (slf *RoomSeat[PlayerID, Player]) RemoveSeat(seat int)
- func (slf *RoomSeat[PlayerID, Player]) SetSeat(id PlayerID, seat int) error
- type RoomSeatOption
- type World
- func (slf *World[PlayerID, Player]) AddActor(actor game.Actor)
- func (slf *World[PlayerID, Player]) GetActor(guid int64) game.Actor
- func (slf *World[PlayerID, Player]) GetActors() hash.MapReadonly[int64, game.Actor]
- func (slf *World[PlayerID, Player]) GetGuid() int64
- func (slf *World[PlayerID, Player]) GetPlayer(id PlayerID) Player
- func (slf *World[PlayerID, Player]) GetPlayerActor(id PlayerID, guid int64) game.Actor
- func (slf *World[PlayerID, Player]) GetPlayerActors(id PlayerID) hash.MapReadonly[int64, game.Actor]
- func (slf *World[PlayerID, Player]) GetPlayerLimit() int
- func (slf *World[PlayerID, Player]) GetPlayers() hash.MapReadonly[PlayerID, Player]
- func (slf *World[PlayerID, Player]) IsExistActor(guid int64) bool
- func (slf *World[PlayerID, Player]) IsExistPlayer(id PlayerID) bool
- func (slf *World[PlayerID, Player]) IsOwner(id PlayerID, guid int64) bool
- func (slf *World[PlayerID, Player]) Join(player Player) error
- func (slf *World[PlayerID, Player]) Leave(id PlayerID)
- func (slf *World[PlayerID, Player]) OnActorAnnihilationEvent(actor game.Actor)
- func (slf *World[PlayerID, Player]) OnActorGeneratedEvent(actor game.Actor)
- func (slf *World[PlayerID, Player]) OnActorOwnerChangeEvent(actor game.Actor, old, new PlayerID, isolated bool)
- func (slf *World[PlayerID, Player]) OnPlayerJoinWorldEvent(player Player)
- func (slf *World[PlayerID, Player]) OnPlayerLeaveWorldEvent(player Player)
- func (slf *World[PlayerID, Player]) OnWorldReleaseEvent()
- func (slf *World[PlayerID, Player]) OnWorldResetEvent()
- func (slf *World[PlayerID, Player]) RegActorAnnihilationEvent(handle game.ActorAnnihilationEventHandle[PlayerID, Player])
- func (slf *World[PlayerID, Player]) RegActorGeneratedEvent(handle game.ActorGeneratedEventHandle[PlayerID, Player])
- func (slf *World[PlayerID, Player]) RegActorOwnerChangeEvent(handle game.ActorOwnerChangeEventHandle[PlayerID, Player])
- func (slf *World[PlayerID, Player]) RegPlayerJoinWorldEvent(handle game.PlayerJoinWorldEventHandle[PlayerID, Player])
- func (slf *World[PlayerID, Player]) RegPlayerLeaveWorldEvent(handle game.PlayerLeaveWorldEventHandle[PlayerID, Player])
- func (slf *World[PlayerID, Player]) RegWorldReleaseEvent(handle game.WorldReleaseEventHandle[PlayerID, Player])
- func (slf *World[PlayerID, Player]) RegWorldResetEvent(handle game.WorldResetEventHandle[PlayerID, Player])
- func (slf *World[PlayerID, Player]) Release()
- func (slf *World[PlayerID, Player]) RemoveActor(guid int64)
- func (slf *World[PlayerID, Player]) RemoveActorOwner(guid int64)
- func (slf *World[PlayerID, Player]) Reset()
- func (slf *World[PlayerID, Player]) SetActorOwner(guid int64, id PlayerID)
- type WorldOption
Constants ¶
This section is empty.
Variables ¶
var ( ErrCannotAddNegativeOrZeroItem = errors.New("cannot add items with negative quantities or zero") ErrItemNotExist = errors.New("item not exist") ErrItemInsufficientQuantity = errors.New("item insufficient quantity") ErrItemContainerIsFull = errors.New("item container is full") ErrItemContainerNotExist = errors.New("item container not exist") )
var ( ErrRankingListNotExistCompetitor = errors.New("ranking list not exist competitor") ErrRankingListIndexErr = errors.New("ranking list index error") ErrRankingListNonexistentRanking = errors.New("nonexistent ranking") )
var ( ErrRoomPlayerLimit = errors.New("the number of players in the room has reached the upper limit") // 玩家数量达到上限 ErrRoomNoHasMaster = errors.New("room not has master, can't kick player") ErrRoomNotIsOwner = errors.New("not is room owner, can't kick player") )
var ( ErrWorldPlayerLimit = errors.New("the number of players in the world has reached the upper limit") // 玩家数量达到上限 ErrWorldReleased = errors.New("the world has been released") // 世界已被释放 )
var (
ErrRoomNotHasPlayer = errors.New("player not exist")
)
Functions ¶
This section is empty.
Types ¶
type AOI2D ¶
type AOI2D struct {
// contains filtered or unexported fields
}
func (*AOI2D) AddEntity ¶
func (slf *AOI2D) AddEntity(entity game.AOIEntity2D)
func (*AOI2D) DeleteEntity ¶
func (slf *AOI2D) DeleteEntity(entity game.AOIEntity2D)
func (*AOI2D) OnEntityJoinVisionEvent ¶
func (slf *AOI2D) OnEntityJoinVisionEvent(entity, target game.AOIEntity2D)
func (*AOI2D) OnEntityLeaveVisionEvent ¶
func (slf *AOI2D) OnEntityLeaveVisionEvent(entity, target game.AOIEntity2D)
func (*AOI2D) Refresh ¶
func (slf *AOI2D) Refresh(entity game.AOIEntity2D)
func (*AOI2D) RegEntityJoinVisionEvent ¶
func (slf *AOI2D) RegEntityJoinVisionEvent(handle game.EntityJoinVisionEventHandle)
func (*AOI2D) RegEntityLeaveVisionEvent ¶
func (slf *AOI2D) RegEntityLeaveVisionEvent(handle game.EntityLeaveVisionEventHandle)
func (*AOI2D) SetAreaSize ¶
type Attrs ¶
type Attrs struct {
// contains filtered or unexported fields
}
func (*Attrs) ChangeAttrFloat32 ¶
func (*Attrs) ChangeAttrFloat64 ¶
func (*Attrs) ChangeAttrInt ¶
func (*Attrs) ChangeAttrInt16 ¶
func (*Attrs) ChangeAttrInt32 ¶
func (*Attrs) ChangeAttrInt64 ¶
func (*Attrs) ChangeAttrInt8 ¶
func (*Attrs) ChangeAttrUint ¶
func (*Attrs) ChangeAttrUint16 ¶
func (*Attrs) ChangeAttrUint32 ¶
func (*Attrs) ChangeAttrUint64 ¶
func (*Attrs) ChangeAttrUint8 ¶
func (*Attrs) GetAttrFloat32 ¶
func (*Attrs) GetAttrFloat64 ¶
func (*Attrs) GetAttrInt ¶
func (*Attrs) GetAttrInt16 ¶
func (*Attrs) GetAttrInt32 ¶
func (*Attrs) GetAttrInt64 ¶
func (*Attrs) GetAttrInt8 ¶
func (*Attrs) GetAttrUint ¶
func (*Attrs) GetAttrUint16 ¶
func (*Attrs) GetAttrUint32 ¶
func (*Attrs) GetAttrUint64 ¶
func (*Attrs) GetAttrUint8 ¶
func (*Attrs) OnAttrChangeEvent ¶
func (*Attrs) OnAttrIdChangeEvent ¶
func (*Attrs) RegAttrChangeEvent ¶
func (slf *Attrs) RegAttrChangeEvent(handle game.AttrChangeEventHandle)
func (*Attrs) RegAttrIdChangeEvent ¶
func (slf *Attrs) RegAttrIdChangeEvent(id int, handle game.AttrChangeEventHandle)
func (*Attrs) SetAttrFloat32 ¶
func (*Attrs) SetAttrFloat64 ¶
func (*Attrs) SetAttrInt ¶
func (*Attrs) SetAttrInt16 ¶
func (*Attrs) SetAttrInt32 ¶
func (*Attrs) SetAttrInt64 ¶
func (*Attrs) SetAttrInt8 ¶
func (*Attrs) SetAttrUint ¶
func (*Attrs) SetAttrUint16 ¶
func (*Attrs) SetAttrUint32 ¶
func (*Attrs) SetAttrUint64 ¶
func (*Attrs) SetAttrUint8 ¶
type FSM ¶
type FSM[State comparable, Data any] struct { // contains filtered or unexported fields }
func NewFSM ¶
func NewFSM[State comparable, Data any](data Data) *FSM[State, Data]
func (*FSM[State, Data]) Unregister ¶
func (slf *FSM[State, Data]) Unregister(state State)
type FSMState ¶
type FSMState[State comparable, Data any] struct { // contains filtered or unexported fields }
func NewFSMState ¶
func NewFSMState[State comparable, Data any](state State, enter game.FSMStateEnterHandle[Data], update game.FSMStateUpdateHandle[Data], exit game.FSMStateExitHandle[Data]) *FSMState[State, Data]
type Gameplay ¶
func NewGameplay ¶
func NewGameplay() *Gameplay
func (*Gameplay) GetCurrentTime ¶
func (*Gameplay) OnGameplayReleaseEvent ¶
func (slf *Gameplay) OnGameplayReleaseEvent()
func (*Gameplay) OnGameplayStartEvent ¶
func (slf *Gameplay) OnGameplayStartEvent()
func (*Gameplay) OnGameplayTimeChangeEvent ¶
func (slf *Gameplay) OnGameplayTimeChangeEvent()
func (*Gameplay) RegGameplayReleaseEvent ¶
func (slf *Gameplay) RegGameplayReleaseEvent(handle game.GameplayReleaseEventHandle)
func (*Gameplay) RegGameplayStartEvent ¶
func (slf *Gameplay) RegGameplayStartEvent(handle game.GameplayStartEventHandle)
func (*Gameplay) RegGameplayTimeChangeEvent ¶
func (slf *Gameplay) RegGameplayTimeChangeEvent(handle game.GameplayTimeChangeEventHandle)
func (*Gameplay) SetTimeOffset ¶
type GameplayOver ¶
type GameplayOver struct {
// contains filtered or unexported fields
}
func NewGameplayOver ¶
func NewGameplayOver() *GameplayOver
func (*GameplayOver) GameOver ¶
func (slf *GameplayOver) GameOver()
func (*GameplayOver) OnGameplayOverEvent ¶
func (slf *GameplayOver) OnGameplayOverEvent()
func (*GameplayOver) RegGameplayOverEvent ¶
func (slf *GameplayOver) RegGameplayOverEvent(handle game.GameplayOverEventHandle)
type GameplayTime ¶
type GameplayTime struct { game.Gameplay game.GameplayOver // contains filtered or unexported fields }
func NewGameplayTime ¶
func NewGameplayTime(gameplay game.Gameplay, gameplayOver game.GameplayOver, options ...GameplayTimeOption) *GameplayTime
func (*GameplayTime) ChangeEndTime ¶
func (slf *GameplayTime) ChangeEndTime(d time.Duration)
func (*GameplayTime) GetEndTime ¶
func (slf *GameplayTime) GetEndTime() time.Time
func (*GameplayTime) Release ¶
func (slf *GameplayTime) Release()
func (*GameplayTime) SetEndTime ¶
func (slf *GameplayTime) SetEndTime(t time.Time)
type GameplayTimeOption ¶
type GameplayTimeOption func(time *GameplayTime)
func WithGameplayTimeTicker ¶
func WithGameplayTimeTicker(id int64, ticker *timer.Ticker) GameplayTimeOption
func WithGameplayTimeWheelSize ¶
func WithGameplayTimeWheelSize(size int) GameplayTimeOption
type Item ¶
type Item[ItemID comparable] struct { // contains filtered or unexported fields }
func NewItem ¶
func NewItem[ItemID comparable](id ItemID) *Item[ItemID]
type ItemContainer ¶
type ItemContainer[ItemID comparable, Item game.Item[ItemID]] struct { // contains filtered or unexported fields }
func NewItemContainer ¶
func NewItemContainer[ItemID comparable, Item game.Item[ItemID]](options ...ItemContainerOption[ItemID, Item]) *ItemContainer[ItemID, Item]
func (*ItemContainer[ItemID, Item]) AddItem ¶
func (slf *ItemContainer[ItemID, Item]) AddItem(item Item, count *huge.Int) (guid int64, err error)
func (*ItemContainer[ItemID, Item]) CheckAllowAdd ¶
func (slf *ItemContainer[ItemID, Item]) CheckAllowAdd(item Item, count *huge.Int) error
func (*ItemContainer[ItemID, Item]) CheckDeductItem ¶
func (slf *ItemContainer[ItemID, Item]) CheckDeductItem(guid int64, count *huge.Int) error
func (*ItemContainer[ItemID, Item]) Clear ¶
func (slf *ItemContainer[ItemID, Item]) Clear()
func (*ItemContainer[ItemID, Item]) DeductItem ¶
func (slf *ItemContainer[ItemID, Item]) DeductItem(guid int64, count *huge.Int) error
func (*ItemContainer[ItemID, Item]) ExistItem ¶
func (slf *ItemContainer[ItemID, Item]) ExistItem(guid int64) bool
func (*ItemContainer[ItemID, Item]) ExistItemWithID ¶
func (slf *ItemContainer[ItemID, Item]) ExistItemWithID(id ItemID) bool
func (*ItemContainer[ItemID, Item]) GetItem ¶
func (slf *ItemContainer[ItemID, Item]) GetItem(guid int64) (game.ItemContainerMember[ItemID, Item], error)
func (*ItemContainer[ItemID, Item]) GetItems ¶
func (slf *ItemContainer[ItemID, Item]) GetItems() []game.ItemContainerMember[ItemID, Item]
func (*ItemContainer[ItemID, Item]) GetItemsFull ¶
func (slf *ItemContainer[ItemID, Item]) GetItemsFull() []game.ItemContainerMember[ItemID, Item]
func (*ItemContainer[ItemID, Item]) GetItemsMap ¶
func (slf *ItemContainer[ItemID, Item]) GetItemsMap() map[int64]game.ItemContainerMember[ItemID, Item]
func (*ItemContainer[ItemID, Item]) GetSize ¶
func (slf *ItemContainer[ItemID, Item]) GetSize() int
func (*ItemContainer[ItemID, Item]) GetSizeLimit ¶
func (slf *ItemContainer[ItemID, Item]) GetSizeLimit() int
func (*ItemContainer[ItemID, Item]) Remove ¶
func (slf *ItemContainer[ItemID, Item]) Remove(guid int64)
func (*ItemContainer[ItemID, Item]) RemoveWithID ¶
func (slf *ItemContainer[ItemID, Item]) RemoveWithID(id ItemID)
func (*ItemContainer[ItemID, Item]) SetExpandSize ¶
func (slf *ItemContainer[ItemID, Item]) SetExpandSize(size int)
func (*ItemContainer[ItemID, Item]) TransferTo ¶
func (slf *ItemContainer[ItemID, Item]) TransferTo(guid int64, count *huge.Int, target game.ItemContainer[ItemID, Item]) error
type ItemContainerMember ¶
type ItemContainerMember[ItemID comparable, I game.Item[ItemID]] struct { // contains filtered or unexported fields }
func NewItemContainerMember ¶
func NewItemContainerMember[ItemID comparable, I game.Item[ItemID]](guid int64, item I) *ItemContainerMember[ItemID, I]
func (*ItemContainerMember[ItemID, I]) GetCount ¶
func (slf *ItemContainerMember[ItemID, I]) GetCount() *huge.Int
func (*ItemContainerMember[ItemID, I]) GetGUID ¶
func (slf *ItemContainerMember[ItemID, I]) GetGUID() int64
func (*ItemContainerMember[ItemID, I]) GetID ¶
func (slf *ItemContainerMember[ItemID, I]) GetID() ItemID
func (*ItemContainerMember[ItemID, I]) GetItem ¶
func (slf *ItemContainerMember[ItemID, I]) GetItem() I
type ItemContainerOption ¶
type ItemContainerOption[ItemID comparable, Item game.Item[ItemID]] func(container *ItemContainer[ItemID, Item])
func WithItemContainerSizeLimit ¶
func WithItemContainerSizeLimit[ItemID comparable, Item game.Item[ItemID]](sizeLimit int) ItemContainerOption[ItemID, Item]
WithItemContainerSizeLimit 通过特定的物品容器非堆叠数量上限创建物品容器
func WithItemContainerStackLimit ¶
func WithItemContainerStackLimit[ItemID comparable, Item game.Item[ItemID]](id ItemID, stackLimit *huge.Int) ItemContainerOption[ItemID, Item]
WithItemContainerStackLimit 通过设置特定物品堆叠数量创建容器
type Player ¶
type Player[ID comparable] struct { // contains filtered or unexported fields }
Player 游戏玩家
type RankingList ¶
type RankingList[CompetitorID comparable, Score generic.Ordered] struct { // contains filtered or unexported fields }
func NewRankingList ¶
func NewRankingList[CompetitorID comparable, Score generic.Ordered](options ...RankingListOption[CompetitorID, Score]) *RankingList[CompetitorID, Score]
NewRankingList 创建一个排名从0开始的排行榜
func (*RankingList[CompetitorID, Score]) Clear ¶
func (slf *RankingList[CompetitorID, Score]) Clear()
func (*RankingList[CompetitorID, Score]) Cmp ¶
func (slf *RankingList[CompetitorID, Score]) Cmp(s1, s2 Score) int
func (*RankingList[CompetitorID, Score]) Competitor ¶
func (slf *RankingList[CompetitorID, Score]) Competitor(competitorId CompetitorID, score Score)
func (*RankingList[CompetitorID, Score]) CompetitorIncrease ¶
func (slf *RankingList[CompetitorID, Score]) CompetitorIncrease(competitorId CompetitorID, score Score)
func (*RankingList[CompetitorID, Score]) GetAllCompetitor ¶
func (slf *RankingList[CompetitorID, Score]) GetAllCompetitor() []CompetitorID
func (*RankingList[CompetitorID, Score]) GetCompetitor ¶
func (slf *RankingList[CompetitorID, Score]) GetCompetitor(rank int) (competitorId CompetitorID, err error)
func (*RankingList[CompetitorID, Score]) GetCompetitorWithRange ¶
func (slf *RankingList[CompetitorID, Score]) GetCompetitorWithRange(start, end int) ([]CompetitorID, error)
func (*RankingList[CompetitorID, Score]) GetRank ¶
func (slf *RankingList[CompetitorID, Score]) GetRank(competitorId CompetitorID) (int, error)
func (*RankingList[CompetitorID, Score]) GetScore ¶
func (slf *RankingList[CompetitorID, Score]) GetScore(competitorId CompetitorID) (score Score, err error)
func (*RankingList[CompetitorID, Score]) MarshalJSON ¶
func (slf *RankingList[CompetitorID, Score]) MarshalJSON() ([]byte, error)
func (*RankingList[CompetitorID, Score]) OnRankChangeEvent ¶
func (slf *RankingList[CompetitorID, Score]) OnRankChangeEvent(competitorId CompetitorID, oldRank, newRank int, oldScore, newScore Score)
func (*RankingList[CompetitorID, Score]) OnRankClearBeforeEvent ¶
func (slf *RankingList[CompetitorID, Score]) OnRankClearBeforeEvent()
func (*RankingList[CompetitorID, Score]) RegRankChangeEvent ¶
func (slf *RankingList[CompetitorID, Score]) RegRankChangeEvent(handle game.RankChangeEventHandle[CompetitorID, Score])
func (*RankingList[CompetitorID, Score]) RegRankClearBeforeEvent ¶
func (slf *RankingList[CompetitorID, Score]) RegRankClearBeforeEvent(handle game.RankClearBeforeEventHandle[CompetitorID, Score])
func (*RankingList[CompetitorID, Score]) RemoveCompetitor ¶
func (slf *RankingList[CompetitorID, Score]) RemoveCompetitor(competitorId CompetitorID)
func (*RankingList[CompetitorID, Score]) Size ¶
func (slf *RankingList[CompetitorID, Score]) Size() int
func (*RankingList[CompetitorID, Score]) UnmarshalJSON ¶
func (slf *RankingList[CompetitorID, Score]) UnmarshalJSON(bytes []byte) error
type RankingListOption ¶
type RankingListOption[CompetitorID comparable, Score generic.Ordered] func(list *RankingList[CompetitorID, Score])
func WithRankingListASC ¶
func WithRankingListASC[CompetitorID comparable, Score generic.Ordered]() RankingListOption[CompetitorID, Score]
WithRankingListASC 通过升序的方式创建排行榜
- 默认情况下为降序
func WithRankingListCount ¶
func WithRankingListCount[CompetitorID comparable, Score generic.Ordered](rankCount int) RankingListOption[CompetitorID, Score]
WithRankingListCount 通过限制排行榜竞争者数量来创建排行榜
- 默认情况下允许100位竞争者
type Room ¶
type Room[PlayerID comparable, Player game.Player[PlayerID]] struct { // contains filtered or unexported fields }
Room 默认的内置游戏房间实现
- 实现了最大人数控制、房主、踢出玩家、玩家维护等功能
- 支持并发安全和非并发安全的模式
func NewRoom ¶
func NewRoom[PlayerID comparable, Player game.Player[PlayerID]](guid int64, options ...RoomOption[PlayerID, Player]) *Room[PlayerID, Player]
NewRoom 创建一个默认的内置游戏房间 Room
func (*Room[PlayerID, Player]) ChangeOwner ¶
func (slf *Room[PlayerID, Player]) ChangeOwner(id PlayerID)
ChangeOwner 改变房主
- 当房间为无主模式(WithRoomNoMaster)时,将不会发生任何变化
func (*Room[PlayerID, Player]) GetPlayer ¶
func (slf *Room[PlayerID, Player]) GetPlayer(id PlayerID) Player
GetPlayer 根据玩家id获取玩家
func (*Room[PlayerID, Player]) GetPlayerCount ¶
GetPlayerCount 获取玩家数量
func (*Room[PlayerID, Player]) GetPlayerLimit ¶
GetPlayerLimit 获取最大玩家上限
func (*Room[PlayerID, Player]) GetPlayers ¶
func (slf *Room[PlayerID, Player]) GetPlayers() hash.MapReadonly[PlayerID, Player]
GetPlayers 获取所有玩家
func (*Room[PlayerID, Player]) IsExistPlayer ¶
IsExistPlayer 房间内是否存在某玩家
func (*Room[PlayerID, Player]) IsOwner ¶
IsOwner 检查特定玩家是否是房主
- 当房间为无主模式(WithRoomNoMaster)时,将会始终返回false
func (*Room[PlayerID, Player]) KickOut ¶
KickOut 以某种原因踢出特定玩家
- 当设置了房间踢出玩家的检查处理函数(WithRoomKickPlayerCheckHandle)时,将会根据检查结果进行处理,即便是无主模式。其他情况如下
- 如果是无主模式(WithRoomNoMaster),将会返回错误
- 如果不是房主发起的踢出玩家,将会返回错误
func (*Room[PlayerID, Player]) Leave ¶
func (slf *Room[PlayerID, Player]) Leave(id PlayerID)
Leave 控制玩家离开房间
func (*Room[PlayerID, Player]) OnPlayerJoinRoomEvent ¶
func (slf *Room[PlayerID, Player]) OnPlayerJoinRoomEvent(player Player)
func (*Room[PlayerID, Player]) OnPlayerKickedOutEvent ¶
func (*Room[PlayerID, Player]) OnPlayerLeaveRoomEvent ¶
func (slf *Room[PlayerID, Player]) OnPlayerLeaveRoomEvent(player Player)
func (*Room[PlayerID, Player]) RegPlayerJoinRoomEvent ¶
func (slf *Room[PlayerID, Player]) RegPlayerJoinRoomEvent(handle game.PlayerJoinRoomEventHandle[PlayerID, Player])
RegPlayerJoinRoomEvent 玩家进入房间时将立即执行被注册的事件处理函数
func (*Room[PlayerID, Player]) RegPlayerKickedOutEvent ¶
func (slf *Room[PlayerID, Player]) RegPlayerKickedOutEvent(handle game.PlayerKickedOutEventHandle[PlayerID, Player])
RegPlayerKickedOutEvent 当玩家被踢出游戏时将立即执行被注册的事件处理函数
func (*Room[PlayerID, Player]) RegPlayerLeaveRoomEvent ¶
func (slf *Room[PlayerID, Player]) RegPlayerLeaveRoomEvent(handle game.PlayerLeaveRoomEventHandle[PlayerID, Player])
RegPlayerLeaveRoomEvent 玩家离开房间时将立即执行被注册的事件处理函数
type RoomManager ¶
type RoomManager[PlayerID comparable, Room game.Room[PlayerID, game.Player[PlayerID]]] struct { // contains filtered or unexported fields }
RoomManager 房间管理器
func NewRoomManager ¶
func NewRoomManager[PlayerID comparable, Room game.Room[PlayerID, game.Player[PlayerID]]]() *RoomManager[PlayerID, Room]
func (*RoomManager[PlayerID, Room]) AddRoom ¶
func (slf *RoomManager[PlayerID, Room]) AddRoom(room Room)
AddRoom 添加房间到房间管理器中
func (*RoomManager[PlayerID, Room]) CloseRoom ¶
func (slf *RoomManager[PlayerID, Room]) CloseRoom(guid int64)
CloseRoom 关闭特定guid的房间
func (*RoomManager[PlayerID, Room]) GenGuid ¶
func (slf *RoomManager[PlayerID, Room]) GenGuid() int64
GenGuid 生成一个新的房间guid
type RoomOption ¶
type RoomOption[PlayerID comparable, Player game.Player[PlayerID]] func(room *Room[PlayerID, Player])
RoomOption 房间构建可选项
func WithRoomKickPlayerCheckHandle ¶
func WithRoomKickPlayerCheckHandle[PlayerID comparable, Player game.Player[PlayerID]](handle func(room *Room[PlayerID, Player], id, target PlayerID) error) RoomOption[PlayerID, Player]
WithRoomKickPlayerCheckHandle 设置房间踢出玩家的检查处理函数
- 当没有设置该函数时,如果不是房主,将无法进行踢出
func WithRoomNoMaster ¶
func WithRoomNoMaster[PlayerID comparable, Player game.Player[PlayerID]]() RoomOption[PlayerID, Player]
WithRoomNoMaster 设置房间为无主的
func WithRoomPlayerLimit ¶
func WithRoomPlayerLimit[PlayerID comparable, Player game.Player[PlayerID]](playerLimit int) RoomOption[PlayerID, Player]
WithRoomPlayerLimit 限制房间的玩家数量上限
func WithRoomSync ¶
func WithRoomSync[PlayerID comparable, Player game.Player[PlayerID]]() RoomOption[PlayerID, Player]
WithRoomSync 通过线程安全的方式创建房间
type RoomSeat ¶
type RoomSeat[PlayerID comparable, Player game.Player[PlayerID]] struct { game.Room[PlayerID, Player] // contains filtered or unexported fields }
RoomSeat 包含座位号的默认内置房间实现,依赖于游戏房间(game.Room)实现
- 实现了对玩家座位号的管理,分别为自动管理(WithRoomSeatAutoManage)及手工管理,默认清空下为手工管理
func NewRoomSeat ¶
func NewRoomSeat[PlayerID comparable, Player game.Player[PlayerID]](room game.Room[PlayerID, Player], options ...RoomSeatOption[PlayerID, Player]) *RoomSeat[PlayerID, Player]
NewRoomSeat 基于特定游戏房间(game.Room)的实现创建一个支持座位号管理的房间实现(RoomSeat)
func (*RoomSeat[PlayerID, Player]) AddSeat ¶
func (slf *RoomSeat[PlayerID, Player]) AddSeat(id PlayerID)
AddSeat 为特定玩家添加座位
- 当座位存在空缺的时候,玩家将会优先在空缺位置坐下,否则将会在末位追加
func (*RoomSeat[PlayerID, Player]) AddSeatWithAssign ¶
AddSeatWithAssign 将玩家添加到特定的座位
- 如果位置已经有玩家,将会与其进行更换
func (*RoomSeat[PlayerID, Player]) GetFirstSeat ¶
GetFirstSeat 获取第一个未缺席的座位号
func (*RoomSeat[PlayerID, Player]) GetNextSeat ¶
GetNextSeat 获取特定座位号下一个未缺席的座位号
func (*RoomSeat[PlayerID, Player]) GetPlayerIDWithSeat ¶
GetPlayerIDWithSeat 获取特定座位号的玩家
func (*RoomSeat[PlayerID, Player]) GetSeatInfo ¶
func (slf *RoomSeat[PlayerID, Player]) GetSeatInfo() []*PlayerID
GetSeatInfo 获取所有座位号
- 在非补位模式(WithRoomSeatFillIn)下由于座位号可能存在缺席的情况,所以需要根据是否为空指针进行判断
func (*RoomSeat[PlayerID, Player]) GetSeatInfoMapVacancy ¶
GetSeatInfoMapVacancy 获取座位号及其对应的玩家信息
- 缺席情况将不会被忽略
func (*RoomSeat[PlayerID, Player]) GetSeatInfoWithPlayerIDMap ¶
GetSeatInfoWithPlayerIDMap 获取玩家及其座位号信息
func (*RoomSeat[PlayerID, Player]) RemovePlayerSeat ¶
func (slf *RoomSeat[PlayerID, Player]) RemovePlayerSeat(id PlayerID)
RemovePlayerSeat 删除玩家座位
- 受补位模式(WithRoomSeatFillIn)影响
type RoomSeatOption ¶
type RoomSeatOption[PlayerID comparable, Player game.Player[PlayerID]] func(seat *RoomSeat[PlayerID, Player])
func WithRoomSeatAutoManage ¶
func WithRoomSeatAutoManage[PlayerID comparable, Player game.Player[PlayerID]]() RoomSeatOption[PlayerID, Player]
WithRoomSeatAutoManage 通过自动管理的方式创建带有座位号的房间
- 默认情况下需要自行维护房间用户的座位号信息
- 自动管理模式下,将注册房间的 Room.RegPlayerJoinRoomEvent 和 Room.RegPlayerLeaveRoomEvent 事件以便玩家在加入或者离开时维护座位信息
func WithRoomSeatFillIn ¶
func WithRoomSeatFillIn[PlayerID comparable, Player game.Player[PlayerID]]() RoomSeatOption[PlayerID, Player]
WithRoomSeatFillIn 通过补位的方式创建带有座位号的房间
- 默认情况下玩家离开座位不会影响其他玩家
- 补位情况下,靠前的玩家离开座位将有后方玩家向前补位
type World ¶
type World[PlayerID comparable, Player game.Player[PlayerID]] struct { // contains filtered or unexported fields }
World 游戏世界的内置实现,实现了基本的游戏世界接口
func NewWorld ¶
func NewWorld[PlayerID comparable, Player game.Player[PlayerID]](guid int64, options ...WorldOption[PlayerID, Player]) *World[PlayerID, Player]
NewWorld 创建一个内置的游戏世界
func (*World[PlayerID, Player]) GetPlayer ¶
func (slf *World[PlayerID, Player]) GetPlayer(id PlayerID) Player
func (*World[PlayerID, Player]) GetPlayerActor ¶
func (*World[PlayerID, Player]) GetPlayerActors ¶
func (*World[PlayerID, Player]) GetPlayerLimit ¶
func (*World[PlayerID, Player]) GetPlayers ¶
func (slf *World[PlayerID, Player]) GetPlayers() hash.MapReadonly[PlayerID, Player]
func (*World[PlayerID, Player]) IsExistActor ¶
func (*World[PlayerID, Player]) IsExistPlayer ¶
func (*World[PlayerID, Player]) OnActorAnnihilationEvent ¶
func (*World[PlayerID, Player]) OnActorGeneratedEvent ¶
func (*World[PlayerID, Player]) OnActorOwnerChangeEvent ¶
func (*World[PlayerID, Player]) OnPlayerJoinWorldEvent ¶
func (slf *World[PlayerID, Player]) OnPlayerJoinWorldEvent(player Player)
func (*World[PlayerID, Player]) OnPlayerLeaveWorldEvent ¶
func (slf *World[PlayerID, Player]) OnPlayerLeaveWorldEvent(player Player)
func (*World[PlayerID, Player]) OnWorldReleaseEvent ¶
func (slf *World[PlayerID, Player]) OnWorldReleaseEvent()
func (*World[PlayerID, Player]) OnWorldResetEvent ¶
func (slf *World[PlayerID, Player]) OnWorldResetEvent()
func (*World[PlayerID, Player]) RegActorAnnihilationEvent ¶
func (slf *World[PlayerID, Player]) RegActorAnnihilationEvent(handle game.ActorAnnihilationEventHandle[PlayerID, Player])
func (*World[PlayerID, Player]) RegActorGeneratedEvent ¶
func (slf *World[PlayerID, Player]) RegActorGeneratedEvent(handle game.ActorGeneratedEventHandle[PlayerID, Player])
func (*World[PlayerID, Player]) RegActorOwnerChangeEvent ¶
func (slf *World[PlayerID, Player]) RegActorOwnerChangeEvent(handle game.ActorOwnerChangeEventHandle[PlayerID, Player])
func (*World[PlayerID, Player]) RegPlayerJoinWorldEvent ¶
func (slf *World[PlayerID, Player]) RegPlayerJoinWorldEvent(handle game.PlayerJoinWorldEventHandle[PlayerID, Player])
func (*World[PlayerID, Player]) RegPlayerLeaveWorldEvent ¶
func (slf *World[PlayerID, Player]) RegPlayerLeaveWorldEvent(handle game.PlayerLeaveWorldEventHandle[PlayerID, Player])
func (*World[PlayerID, Player]) RegWorldReleaseEvent ¶
func (slf *World[PlayerID, Player]) RegWorldReleaseEvent(handle game.WorldReleaseEventHandle[PlayerID, Player])
func (*World[PlayerID, Player]) RegWorldResetEvent ¶
func (slf *World[PlayerID, Player]) RegWorldResetEvent(handle game.WorldResetEventHandle[PlayerID, Player])
func (*World[PlayerID, Player]) RemoveActor ¶
func (*World[PlayerID, Player]) RemoveActorOwner ¶
func (*World[PlayerID, Player]) SetActorOwner ¶
type WorldOption ¶
type WorldOption[PlayerID comparable, Player game.Player[PlayerID]] func(world *World[PlayerID, Player])
WorldOption 世界构建可选项
func WithWorldPlayerLimit ¶
func WithWorldPlayerLimit[PlayerID comparable, Player game.Player[PlayerID]](playerLimit int) WorldOption[PlayerID, Player]
WithWorldPlayerLimit 限制世界的玩家数量上限
Source Files ¶
- actor.go
- aoi2d.go
- attrs.go
- doc.go
- fsm.go
- fsm_state.go
- gameplay.go
- gameplay_over.go
- gameplay_time.go
- gameplay_time_options.go
- item.go
- item_container.go
- item_container_errors.go
- item_container_member.go
- item_container_options.go
- item_container_sort.go
- player.go
- ranking_list.go
- ranking_list_errors.go
- ranking_list_options.go
- room.go
- room_errors.go
- room_manager.go
- room_options.go
- room_seat.go
- room_seat_errors.go
- room_seat_options.go
- world.go
- world_errors.go
- world_options.go