Documentation
¶
Index ¶
- Constants
- type ArrayComponent
- type Bag
- type BagCountItem
- type BagUniqueItem
- type BaseInfo
- type InterfaceMap
- type LoopCheckA
- type LoopCheckB
- type Player
- func (this *Player) FireEvent(event any)
- func (this *Player) GetArray() *ArrayComponent
- func (this *Player) GetBag() *Bag
- func (this *Player) GetBaseInfo() *BaseInfo
- func (this *Player) GetInterfaceMap() *InterfaceMap
- func (this *Player) GetQuest() *Quest
- func (this *Player) GetSlice() *SliceComponent
- func (this *Player) GetStruct() *StructComponent
- func (this *Player) SaveCache(kvCache gentity.KvCache) error
- func (this *Player) TriggerPlayerEntryGame(evt *PlayerEntryGame)
- type PlayerEntryGame
- type Quest
- type SliceComponent
- type StructComponent
Constants ¶
View Source
const (
// 组件名
ComponentNameArray = "Array"
)
View Source
const (
// 组件名
ComponentNameBag = "Bag"
)
View Source
const (
// 组件名
ComponentNameBaseInfo = "BaseInfo"
)
View Source
const (
// 组件名
ComponentNameInterfaceMap = "InterfaceMap"
)
View Source
const (
// 组件名
ComponentNameQuest = "Quest"
)
View Source
const (
// 组件名
ComponentNameSlice = "Slice"
)
View Source
const (
// 组件名
ComponentNameStruct = "Struct"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayComponent ¶ added in v1.3.0
type ArrayComponent struct { gentity.DataComponent Array [10]int32 `db:"plain"` }
固定长度数组测试
type Bag ¶ added in v1.3.0
type Bag struct { gentity.BaseComponent BagCountItem *BagCountItem `child:"CountItem"` BagUniqueItem *BagUniqueItem `child:"UniqueItem"` // 假设一种特殊背包,用于测试gentity.SliceData TestUniqueItem *gentity.SliceData[*pb.UniqueItem] `child:"TestUniqueItem"` }
背包模块 演示通过组合模式,整合多个不同的子背包模块,提供更高一级的背包接口
type BagCountItem ¶ added in v1.2.0
有数量的物品背包
func (*BagCountItem) AddItem ¶ added in v1.2.0
func (this *BagCountItem) AddItem(itemCfgId, addCount int32) int32
func (*BagCountItem) DelItem ¶ added in v1.2.0
func (this *BagCountItem) DelItem(itemCfgId, delCount int32) int32
type BagUniqueItem ¶ added in v1.2.0
type BagUniqueItem struct { gentity.MapData[int64, *pb.UniqueItem] `db:""` }
不可叠加的物品背包
func (*BagUniqueItem) AddUniqueItem ¶ added in v1.2.0
func (this *BagUniqueItem) AddUniqueItem(uniqueItem *pb.UniqueItem) int32
func (*BagUniqueItem) DelUniqueItem ¶ added in v1.2.0
func (this *BagUniqueItem) DelUniqueItem(uniqueId int64) int32
type BaseInfo ¶ added in v1.3.0
type BaseInfo struct { gentity.DataComponent BaseInfo *pb.BaseInfo `db:"plain"` }
基本信息组件
func (*BaseInfo) SetLongFieldNameTest ¶ added in v1.3.0
func (*BaseInfo) TriggerLoopCheckA ¶ added in v1.3.0
func (this *BaseInfo) TriggerLoopCheckA(evt *LoopCheckA)
组件上的事件响应接口
func (*BaseInfo) TriggerLoopCheckB ¶ added in v1.3.0
func (this *BaseInfo) TriggerLoopCheckB(evt *LoopCheckB)
type InterfaceMap ¶ added in v1.3.0
type InterfaceMap struct { gentity.MapComponent // 动态的数据结构 map[string]Saveable InterfaceMap *gentity.MapData[string, gentity.Saveable] `db:""` }
动态数据组件
func (*InterfaceMap) LoadFromBytesMap ¶ added in v1.3.0
func (im *InterfaceMap) LoadFromBytesMap(bytesMap any) error
反序列化
type LoopCheckA ¶ added in v1.1.7
type LoopCheckA struct {
Num int32
}
type LoopCheckB ¶ added in v1.1.7
type LoopCheckB struct {
Name string
}
type Player ¶ added in v1.3.0
type Player struct { gentity.BaseEntity Name string `json:"Name"` // 玩家名 AccountId int64 `json:"AccountId"` // 账号id RegionId int32 `json:"RegionId"` // 区服id // contains filtered or unexported fields }
玩家实体
func (*Player) GetArray ¶ added in v1.3.0
func (this *Player) GetArray() *ArrayComponent
func (*Player) GetBaseInfo ¶ added in v1.3.0
func (*Player) GetInterfaceMap ¶ added in v1.3.0
func (this *Player) GetInterfaceMap() *InterfaceMap
func (*Player) GetSlice ¶ added in v1.3.0
func (this *Player) GetSlice() *SliceComponent
func (*Player) GetStruct ¶ added in v1.3.0
func (this *Player) GetStruct() *StructComponent
func (*Player) TriggerPlayerEntryGame ¶ added in v1.3.0
func (this *Player) TriggerPlayerEntryGame(evt *PlayerEntryGame)
entity上的事件响应接口
type PlayerEntryGame ¶ added in v1.1.6
事件示例
type Quest ¶ added in v1.3.0
type Quest struct { gentity.BaseComponent // 保存数据的子模块:已完成的任务 // 保存数据的子模块必须是导出字段(字段名大写开头) Finished *gentity.SliceData[int32] `child:"plain"` // 明文保存 // 保存数据的子模块:当前任务列表 Quests *gentity.MapData[int32, *pb.QuestData] `child:""` }
任务组件
func (*Quest) AddFinishId ¶ added in v1.3.0
func (*Quest) TriggerPlayerEntryGame ¶ added in v1.3.0
func (this *Quest) TriggerPlayerEntryGame(evt *PlayerEntryGame)
组件上的事件响应接口
type SliceComponent ¶ added in v1.3.0
type SliceComponent struct { gentity.DataComponent Data []*pb.QuestData `db:""` }
func (*SliceComponent) Add ¶ added in v1.3.0
func (this *SliceComponent) Add(data *pb.QuestData)
type StructComponent ¶ added in v1.3.0
type StructComponent struct { gentity.DataComponent Data pb.QuestData `db:""` }
func (*StructComponent) Set ¶ added in v1.3.0
func (this *StructComponent) Set(cfgId, progress int32)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.