整理场景实体相关,优化同步

This commit is contained in:
huangxiaolei
2022-12-12 10:24:59 +08:00
parent 7fa4cd7f10
commit 62b08c2ac7
20 changed files with 847 additions and 1012 deletions

View File

@@ -7,18 +7,18 @@ import (
// 泛型通用转发器
type InvokeType interface {
type InvokeEntryType interface {
proto.CombatInvokeEntry | proto.AbilityInvokeEntry
}
type InvokeHandler[T InvokeType] struct {
type InvokeHandler[T InvokeEntryType] struct {
EntryListForwardAll []*T
EntryListForwardAllExceptCur []*T
EntryListForwardHost []*T
EntryListForwardServer []*T
}
func NewInvokeHandler[T InvokeType]() (r *InvokeHandler[T]) {
func NewInvokeHandler[T InvokeEntryType]() (r *InvokeHandler[T]) {
r = new(InvokeHandler[T])
r.InitInvokeHandler()
return r

View File

@@ -28,7 +28,7 @@ type Player struct {
NickName string `bson:"nickname"` // 玩家昵称
Signature string `bson:"signature"` // 玩家签名
HeadImage uint32 `bson:"headImage"` // 玩家头像
Birthday [2]uint8 `bson:"birthday"` // 生日
Birthday []uint8 `bson:"birthday"` // 生日
NameCard uint32 `bson:"nameCard"` // 当前名片
NameCardList []uint32 `bson:"nameCardList"` // 已解锁名片列表
FriendList map[uint32]bool `bson:"friendList"` // 好友uid列表

View File

@@ -6,8 +6,8 @@ import (
)
type Team struct {
Name string `bson:"name"`
AvatarIdList []uint32 `bson:"avatarIdList"`
Name string `bson:"name"`
AvatarIdList [4]uint32 `bson:"avatarIdList"`
}
func (t *Team) GetAvatarIdList() []uint32 {
@@ -21,6 +21,16 @@ func (t *Team) GetAvatarIdList() []uint32 {
return avatarIdList
}
func (t *Team) SetAvatarIdList(avatarIdList []uint32) {
t.AvatarIdList = [4]uint32{0, 0, 0, 0}
for index := range t.AvatarIdList {
if index >= len(avatarIdList) {
break
}
t.AvatarIdList[index] = avatarIdList[index]
}
}
type TeamInfo struct {
TeamList []*Team `bson:"teamList"`
CurrTeamIndex uint8 `bson:"currTeamIndex"`
@@ -32,10 +42,10 @@ type TeamInfo struct {
func NewTeamInfo() (r *TeamInfo) {
r = &TeamInfo{
TeamList: []*Team{
{Name: "冒险", AvatarIdList: make([]uint32, 4)},
{Name: "委托", AvatarIdList: make([]uint32, 4)},
{Name: "秘境", AvatarIdList: make([]uint32, 4)},
{Name: "联机", AvatarIdList: make([]uint32, 4)},
{Name: "冒险", AvatarIdList: [4]uint32{0, 0, 0, 0}},
{Name: "委托", AvatarIdList: [4]uint32{0, 0, 0, 0}},
{Name: "秘境", AvatarIdList: [4]uint32{0, 0, 0, 0}},
{Name: "联机", AvatarIdList: [4]uint32{0, 0, 0, 0}},
},
CurrTeamIndex: 0,
CurrAvatarIndex: 0,
@@ -90,22 +100,6 @@ func (t *TeamInfo) GetActiveTeam() *Team {
return t.GetTeamByIndex(t.CurrTeamIndex)
}
func (t *TeamInfo) ClearTeamAvatar(teamIndex uint8) {
team := t.GetTeamByIndex(teamIndex)
if team == nil {
return
}
team.AvatarIdList = make([]uint32, 4)
}
func (t *TeamInfo) SetTeamAvatar(teamIndex uint8, avatarIdList []uint32) {
team := t.GetTeamByIndex(teamIndex)
if team == nil {
return
}
team.AvatarIdList = avatarIdList
}
func (t *TeamInfo) GetActiveAvatarId() uint32 {
team := t.GetActiveTeam()
if team == nil {