整理代码,私有变量接口化访问

This commit is contained in:
flswld
2023-02-09 01:01:05 +08:00
parent 98c35380b1
commit 9d6e95a6b4
21 changed files with 661 additions and 375 deletions

View File

@@ -50,6 +50,10 @@ func NewCommandManager() *CommandManager {
return r return r
} }
func (c *CommandManager) GetCommandTextInput() chan *CommandMessage {
return c.commandTextInput
}
// SetSystem 设置GM指令聊天消息机器人 // SetSystem 设置GM指令聊天消息机器人
func (c *CommandManager) SetSystem(system *model.Player) { func (c *CommandManager) SetSystem(system *model.Player) {
c.system = system c.system = system

View File

@@ -219,19 +219,19 @@ func (g *GameManager) gameMainLoop() {
ROUTE_MANAGER.RouteHandle(netMsg) ROUTE_MANAGER.RouteHandle(netMsg)
end := time.Now().UnixNano() end := time.Now().UnixNano()
routeCost += end - start routeCost += end - start
case <-TICK_MANAGER.globalTick.C: case <-TICK_MANAGER.GetGlobalTick().C:
// 游戏服务器定时帧 // 游戏服务器定时帧
start := time.Now().UnixNano() start := time.Now().UnixNano()
TICK_MANAGER.OnGameServerTick() TICK_MANAGER.OnGameServerTick()
end := time.Now().UnixNano() end := time.Now().UnixNano()
tickCost += end - start tickCost += end - start
case localEvent := <-LOCAL_EVENT_MANAGER.localEventChan: case localEvent := <-LOCAL_EVENT_MANAGER.GetLocalEventChan():
// 处理本地事件 // 处理本地事件
start := time.Now().UnixNano() start := time.Now().UnixNano()
LOCAL_EVENT_MANAGER.LocalEventHandle(localEvent) LOCAL_EVENT_MANAGER.LocalEventHandle(localEvent)
end := time.Now().UnixNano() end := time.Now().UnixNano()
localEventCost += end - start localEventCost += end - start
case command := <-COMMAND_MANAGER.commandTextInput: case command := <-COMMAND_MANAGER.GetCommandTextInput():
// 处理传入的命令(普通玩家 GM命令) // 处理传入的命令(普通玩家 GM命令)
start := time.Now().UnixNano() start := time.Now().UnixNano()
COMMAND_MANAGER.HandleCommand(command) COMMAND_MANAGER.HandleCommand(command)
@@ -252,7 +252,7 @@ func (g *GameManager) Close() {
saveUserIdList = append(saveUserIdList, userId) saveUserIdList = append(saveUserIdList, userId)
} }
EXIT_SAVE_FIN_CHAN = make(chan bool) EXIT_SAVE_FIN_CHAN = make(chan bool)
LOCAL_EVENT_MANAGER.localEventChan <- &LocalEvent{ LOCAL_EVENT_MANAGER.GetLocalEventChan() <- &LocalEvent{
EventId: ExitRunUserCopyAndSave, EventId: ExitRunUserCopyAndSave,
Msg: saveUserIdList, Msg: saveUserIdList,
} }
@@ -319,8 +319,8 @@ func (g *GameManager) SendMsg(cmdId uint16, userId uint32, clientSeq uint32, pay
}) })
} }
// CommonRetError 通用返回错误码 // SendError 通用返回错误码
func (g *GameManager) CommonRetError(cmdId uint16, player *model.Player, rsp pb.Message, retCode ...proto.Retcode) { func (g *GameManager) SendError(cmdId uint16, player *model.Player, rsp pb.Message, retCode ...proto.Retcode) {
if rsp == nil { if rsp == nil {
return return
} }
@@ -340,8 +340,8 @@ func (g *GameManager) CommonRetError(cmdId uint16, player *model.Player, rsp pb.
g.SendMsg(cmdId, player.PlayerID, player.ClientSeq, rsp) g.SendMsg(cmdId, player.PlayerID, player.ClientSeq, rsp)
} }
// CommonRetSucc 通用返回成功 // SendSucc 通用返回成功
func (g *GameManager) CommonRetSucc(cmdId uint16, player *model.Player, rsp pb.Message) { func (g *GameManager) SendSucc(cmdId uint16, player *model.Player, rsp pb.Message) {
if rsp == nil { if rsp == nil {
return return
} }
@@ -371,7 +371,7 @@ func (g *GameManager) SendToWorldAEC(world *World, cmdId uint16, seq uint32, msg
// SendToWorldH 给世界房主发消息 // SendToWorldH 给世界房主发消息
func (g *GameManager) SendToWorldH(world *World, cmdId uint16, seq uint32, msg pb.Message) { func (g *GameManager) SendToWorldH(world *World, cmdId uint16, seq uint32, msg pb.Message) {
GAME_MANAGER.SendMsg(cmdId, world.owner.PlayerID, seq, msg) GAME_MANAGER.SendMsg(cmdId, world.GetOwner().PlayerID, seq, msg)
} }
func (g *GameManager) ReconnectPlayer(userId uint32) { func (g *GameManager) ReconnectPlayer(userId uint32) {

View File

@@ -39,6 +39,10 @@ func NewLocalEventManager() (r *LocalEventManager) {
return r return r
} }
func (l *LocalEventManager) GetLocalEventChan() chan *LocalEvent {
return l.localEventChan
}
type PlayerLastSaveTimeSortList []*model.Player type PlayerLastSaveTimeSortList []*model.Player
func (p PlayerLastSaveTimeSortList) Len() int { func (p PlayerLastSaveTimeSortList) Len() int {

View File

@@ -76,27 +76,27 @@ func (g *GameManager) AvatarPromoteGetRewardReq(player *model.Player, payloadMsg
avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.AvatarGuid)] avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.AvatarGuid)]
if !ok { if !ok {
logger.Error("avatar error, avatarGuid: %v", req.AvatarGuid) logger.Error("avatar error, avatarGuid: %v", req.AvatarGuid)
g.CommonRetError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR) g.SendError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR)
return return
} }
// 获取角色配置表 // 获取角色配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)] avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
if !ok { if !ok {
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId) logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
g.CommonRetError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{}) g.SendError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{})
return return
} }
// 角色是否获取过该突破等级的奖励 // 角色是否获取过该突破等级的奖励
if avatar.PromoteRewardMap[req.PromoteLevel] { if avatar.PromoteRewardMap[req.PromoteLevel] {
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId) logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
g.CommonRetError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{}, proto.Retcode_RET_REWARD_HAS_TAKEN) g.SendError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{}, proto.Retcode_RET_REWARD_HAS_TAKEN)
return return
} }
// 获取奖励配置表 // 获取奖励配置表
rewardConfig, ok := gdconf.CONF.RewardDataMap[int32(avatarDataConfig.PromoteRewardMap[req.PromoteLevel])] rewardConfig, ok := gdconf.CONF.RewardDataMap[int32(avatarDataConfig.PromoteRewardMap[req.PromoteLevel])]
if !ok { if !ok {
logger.Error("reward config error, rewardId: %v", avatarDataConfig.PromoteRewardMap[req.PromoteLevel]) logger.Error("reward config error, rewardId: %v", avatarDataConfig.PromoteRewardMap[req.PromoteLevel])
g.CommonRetError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{}) g.SendError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{})
return return
} }
// 设置该奖励为已被获取状态 // 设置该奖励为已被获取状态
@@ -127,41 +127,41 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.Guid)] avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.Guid)]
if !ok { if !ok {
logger.Error("avatar error, avatarGuid: %v", req.Guid) logger.Error("avatar error, avatarGuid: %v", req.Guid)
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR)
return return
} }
// 获取角色配置表 // 获取角色配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)] avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
if !ok { if !ok {
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId) logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{})
return return
} }
// 获取角色突破配置表 // 获取角色突破配置表
avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId] avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId]
if !ok { if !ok {
logger.Error("avatar promote config error, promoteId: %v", avatarDataConfig.PromoteId) logger.Error("avatar promote config error, promoteId: %v", avatarDataConfig.PromoteId)
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{})
return return
} }
// 获取角色突破等级的配置表 // 获取角色突破等级的配置表
avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)] avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)]
if !ok { if !ok {
logger.Error("avatar promote config error, promoteLevel: %v", avatar.Promote) logger.Error("avatar promote config error, promoteLevel: %v", avatar.Promote)
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{})
return return
} }
// 角色等级是否达到限制 // 角色等级是否达到限制
if avatar.Level < uint8(avatarPromoteConfig.LevelLimit) { if avatar.Level < uint8(avatarPromoteConfig.LevelLimit) {
logger.Error("avatar level le level limit, level: %v", avatar.Level) logger.Error("avatar level le level limit, level: %v", avatar.Level)
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_AVATAR_LEVEL_LESS_THAN) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_AVATAR_LEVEL_LESS_THAN)
return return
} }
// 获取角色突破下一级的配置表 // 获取角色突破下一级的配置表
avatarPromoteConfig, ok = avatarPromoteDataMap[int32(avatar.Promote+1)] avatarPromoteConfig, ok = avatarPromoteDataMap[int32(avatar.Promote+1)]
if !ok { if !ok {
logger.Error("avatar promote config error, next promoteLevel: %v", avatar.Promote+1) logger.Error("avatar promote config error, next promoteLevel: %v", avatar.Promote+1)
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_AVATAR_ON_MAX_BREAK_LEVEL) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_AVATAR_ON_MAX_BREAK_LEVEL)
return return
} }
// 将被消耗的物品列表 // 将被消耗的物品列表
@@ -184,16 +184,16 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
logger.Error("item count not enough, itemId: %v", item.ItemId) logger.Error("item count not enough, itemId: %v", item.ItemId)
// 摩拉的错误提示与材料不同 // 摩拉的错误提示与材料不同
if item.ItemId == constant.ItemConstantConst.SCOIN { if item.ItemId == constant.ItemConstantConst.SCOIN {
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
} }
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH)
return return
} }
} }
// 冒险等级是否符合要求 // 冒险等级是否符合要求
if player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] < uint32(avatarPromoteConfig.MinPlayerLevel) { if player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] < uint32(avatarPromoteConfig.MinPlayerLevel) {
logger.Error("player level not enough, level: %v", player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]) logger.Error("player level not enough, level: %v", player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL])
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_PLAYER_LEVEL_LESS_THAN) g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_PLAYER_LEVEL_LESS_THAN)
return return
} }
// 消耗突破材料和摩拉 // 消耗突破材料和摩拉
@@ -220,27 +220,27 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.AvatarGuid)] avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.AvatarGuid)]
if !ok { if !ok {
logger.Error("avatar error, avatarGuid: %v", req.AvatarGuid) logger.Error("avatar error, avatarGuid: %v", req.AvatarGuid)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR)
return return
} }
// 经验书数量是否足够 // 经验书数量是否足够
if player.GetItemCount(req.ItemId) < req.Count { if player.GetItemCount(req.ItemId) < req.Count {
logger.Error("item count not enough, itemId: %v", req.ItemId) logger.Error("item count not enough, itemId: %v", req.ItemId)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH)
return return
} }
// 获取经验书物品配置表 // 获取经验书物品配置表
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(req.ItemId)] itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(req.ItemId)]
if !ok { if !ok {
logger.Error("item data config error, itemId: %v", constant.ItemConstantConst.SCOIN) logger.Error("item data config error, itemId: %v", constant.ItemConstantConst.SCOIN)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 经验书将给予的经验数 // 经验书将给予的经验数
itemParam, err := strconv.Atoi(itemDataConfig.Use1Param1) itemParam, err := strconv.Atoi(itemDataConfig.Use1Param1)
if err != nil { if err != nil {
logger.Error("parse item param error: %v", err) logger.Error("parse item param error: %v", err)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
return return
} }
// 角色获得的经验 // 角色获得的经验
@@ -248,34 +248,34 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
// 摩拉数量是否足够 // 摩拉数量是否足够
if player.GetItemCount(constant.ItemConstantConst.SCOIN) < expCount/5 { if player.GetItemCount(constant.ItemConstantConst.SCOIN) < expCount/5 {
logger.Error("item count not enough, itemId: %v", constant.ItemConstantConst.SCOIN) logger.Error("item count not enough, itemId: %v", constant.ItemConstantConst.SCOIN)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
return return
} }
// 获取角色配置表 // 获取角色配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)] avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
if !ok { if !ok {
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId) logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
return return
} }
// 获取角色突破配置表 // 获取角色突破配置表
avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId] avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId]
if !ok { if !ok {
logger.Error("avatar promote config error, promoteId: %v", avatarDataConfig.PromoteId) logger.Error("avatar promote config error, promoteId: %v", avatarDataConfig.PromoteId)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
return return
} }
// 获取角色突破等级对应的配置表 // 获取角色突破等级对应的配置表
avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)] avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)]
if !ok { if !ok {
logger.Error("avatar promote config error, promoteLevel: %v", avatar.Promote) logger.Error("avatar promote config error, promoteLevel: %v", avatar.Promote)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
return return
} }
// 角色等级是否达到限制 // 角色等级是否达到限制
if avatar.Level >= uint8(avatarPromoteConfig.LevelLimit) { if avatar.Level >= uint8(avatarPromoteConfig.LevelLimit) {
logger.Error("avatar level ge level limit, level: %v", avatar.Level) logger.Error("avatar level ge level limit, level: %v", avatar.Level)
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_AVATAR_BREAK_LEVEL_LESS_THAN) g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_AVATAR_BREAK_LEVEL_LESS_THAN)
return return
} }
// 消耗升级材料以及摩拉 // 消耗升级材料以及摩拉
@@ -387,13 +387,13 @@ func (g *GameManager) WearEquipReq(player *model.Player, payloadMsg pb.Message)
avatar, ok := player.GameObjectGuidMap[avatarGuid].(*model.Avatar) avatar, ok := player.GameObjectGuidMap[avatarGuid].(*model.Avatar)
if !ok { if !ok {
logger.Error("avatar error, avatarGuid: %v", avatarGuid) logger.Error("avatar error, avatarGuid: %v", avatarGuid)
g.CommonRetError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR) g.SendError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR)
return return
} }
weapon, ok := player.GameObjectGuidMap[equipGuid].(*model.Weapon) weapon, ok := player.GameObjectGuidMap[equipGuid].(*model.Weapon)
if !ok { if !ok {
logger.Error("equip error, equipGuid: %v", equipGuid) logger.Error("equip error, equipGuid: %v", equipGuid)
g.CommonRetError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{}) g.SendError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{})
return return
} }
g.WearUserAvatarEquip(player.PlayerID, avatar.AvatarId, weapon.WeaponId) g.WearUserAvatarEquip(player.PlayerID, avatar.AvatarId, weapon.WeaponId)
@@ -433,8 +433,8 @@ func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weapon
weakWorldAvatar := world.GetPlayerWorldAvatar(player, weakAvatarId) weakWorldAvatar := world.GetPlayerWorldAvatar(player, weakAvatarId)
if weakWorldAvatar != nil { if weakWorldAvatar != nil {
weakWorldAvatar.weaponEntityId = scene.CreateEntityWeapon() weakWorldAvatar.SetWeaponEntityId(scene.CreateEntityWeapon())
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, weakWorldAvatar.weaponEntityId) avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, weakWorldAvatar.GetWeaponEntityId())
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify) g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
} else { } else {
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, 0) avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, 0)
@@ -451,8 +451,8 @@ func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weapon
worldAvatar := world.GetPlayerWorldAvatar(player, avatarId) worldAvatar := world.GetPlayerWorldAvatar(player, avatarId)
if worldAvatar != nil { if worldAvatar != nil {
worldAvatar.weaponEntityId = scene.CreateEntityWeapon() worldAvatar.SetWeaponEntityId(scene.CreateEntityWeapon())
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, worldAvatar.weaponEntityId) avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, worldAvatar.GetWeaponEntityId())
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify) g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
} else { } else {
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, 0) avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, 0)
@@ -487,7 +487,7 @@ func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb
avatarChangeCostumeNotify := new(proto.AvatarChangeCostumeNotify) avatarChangeCostumeNotify := new(proto.AvatarChangeCostumeNotify)
avatarChangeCostumeNotify.EntityInfo = g.PacketSceneEntityInfoAvatar(scene, player, avatar.AvatarId) avatarChangeCostumeNotify.EntityInfo = g.PacketSceneEntityInfoAvatar(scene, player, avatar.AvatarId)
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.AvatarChangeCostumeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarChangeCostumeNotify) g.SendMsg(cmd.AvatarChangeCostumeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarChangeCostumeNotify)
} }
@@ -524,7 +524,7 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
AvatarGuid: avatarGuid, AvatarGuid: avatarGuid,
FlycloakId: flycloakId, FlycloakId: flycloakId,
} }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.AvatarFlycloakChangeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarFlycloakChangeNotify) g.SendMsg(cmd.AvatarFlycloakChangeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarFlycloakChangeNotify)
} }

View File

@@ -31,7 +31,7 @@ func (g *GameManager) PullRecentChatReq(player *model.Player, payloadMsg pb.Mess
} }
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer { if world.GetMultiplayer() {
chatList := world.GetChatList() chatList := world.GetChatList()
count := len(chatList) count := len(chatList)
if count > 10 { if count > 10 {
@@ -239,7 +239,7 @@ func (g *GameManager) PlayerChatReq(player *model.Player, payloadMsg pb.Message)
ChannelId: channelId, ChannelId: channelId,
ChatInfo: sendChatInfo, ChatInfo: sendChatInfo,
} }
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.GetAllPlayer() {
g.SendMsg(cmd.PlayerChatNotify, worldPlayer.PlayerID, player.ClientSeq, playerChatNotify) g.SendMsg(cmd.PlayerChatNotify, worldPlayer.PlayerID, player.ClientSeq, playerChatNotify)
} }

View File

@@ -157,12 +157,12 @@ func (g *GameManager) ServerAppidBindNotify(userId uint32, fightAppId string, jo
MsgType: mq.MsgTypeFight, MsgType: mq.MsgTypeFight,
EventId: mq.AddFightRoutine, EventId: mq.AddFightRoutine,
FightMsg: &mq.FightMsg{ FightMsg: &mq.FightMsg{
FightRoutineId: world.id, FightRoutineId: world.GetId(),
GateServerAppId: player.GateAppId, GateServerAppId: player.GateAppId,
}, },
}) })
world.AddPlayer(player, player.SceneId) world.AddPlayer(player, player.SceneId)
player.WorldId = world.id player.WorldId = world.GetId()
// 进入场景 // 进入场景
player.SceneJump = true player.SceneJump = true
player.SceneLoadState = model.SceneNone player.SceneLoadState = model.SceneNone

View File

@@ -29,7 +29,7 @@ func DoForward[IET model.InvokeEntryType](player *model.Player, req pb.Message,
for _, fieldName := range copyFieldList { for _, fieldName := range copyFieldList {
reflection.CopyStructField(ntf, req, fieldName) reflection.CopyStructField(ntf, req, fieldName)
} }
for _, v := range world.playerMap { for _, v := range world.GetAllPlayer() {
GAME_MANAGER.SendMsg(cmdId, v.PlayerID, player.ClientSeq, ntf) GAME_MANAGER.SendMsg(cmdId, v.PlayerID, player.ClientSeq, ntf)
} }
} }
@@ -84,8 +84,8 @@ func (g *GameManager) MassiveEntityElementOpBatchNotify(player *model.Player, pa
return return
} }
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
ntf.OpIdx = scene.meeoIndex ntf.OpIdx = scene.GetMeeoIndex()
scene.meeoIndex++ scene.SetMeeoIndex(scene.GetMeeoIndex() + 1)
g.SendToWorldA(world, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, ntf) g.SendToWorldA(world, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, ntf)
} }
@@ -137,20 +137,21 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
attackerId := attackResult.AttackerId attackerId := attackResult.AttackerId
_ = attackerId _ = attackerId
currHp := float32(0) currHp := float32(0)
if target.fightProp != nil { fightProp := target.GetFightProp()
currHp = target.fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] if fightProp != nil {
currHp = fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)]
currHp -= damage currHp -= damage
if currHp < 0 { if currHp < 0 {
currHp = 0 currHp = 0
} }
target.fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] = currHp fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] = currHp
} }
entityFightPropUpdateNotify := &proto.EntityFightPropUpdateNotify{ entityFightPropUpdateNotify := &proto.EntityFightPropUpdateNotify{
FightPropMap: target.fightProp, FightPropMap: fightProp,
EntityId: target.id, EntityId: target.GetId(),
} }
g.SendToWorldA(world, cmd.EntityFightPropUpdateNotify, player.ClientSeq, entityFightPropUpdateNotify) g.SendToWorldA(world, cmd.EntityFightPropUpdateNotify, player.ClientSeq, entityFightPropUpdateNotify)
if currHp == 0 && target.avatarEntity == nil { if currHp == 0 && target.GetAvatarEntity() == nil {
scene.SetEntityLifeState(target, constant.LifeStateConst.LIFE_DEAD, proto.PlayerDieType_PLAYER_DIE_GM) scene.SetEntityLifeState(target, constant.LifeStateConst.LIFE_DEAD, proto.PlayerDieType_PLAYER_DIE_GM)
} }
combatData, err := pb.Marshal(hitInfo) combatData, err := pb.Marshal(hitInfo)
@@ -186,7 +187,7 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
if sceneEntity == nil { if sceneEntity == nil {
continue continue
} }
if sceneEntity.avatarEntity != nil { if sceneEntity.GetAvatarEntity() != nil {
// 玩家实体在移动 // 玩家实体在移动
g.AoiPlayerMove(player, player.Pos, &model.Vector{ g.AoiPlayerMove(player, player.Pos, &model.Vector{
X: float64(motionInfo.Pos.X), X: float64(motionInfo.Pos.X),
@@ -206,23 +207,26 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
} else { } else {
// 非玩家实体在移动 // 非玩家实体在移动
// 更新场景实体的位置信息 // 更新场景实体的位置信息
sceneEntity.pos.X = float64(motionInfo.Pos.X) pos := sceneEntity.GetPos()
sceneEntity.pos.Y = float64(motionInfo.Pos.Y) pos.X = float64(motionInfo.Pos.X)
sceneEntity.pos.Z = float64(motionInfo.Pos.Z) pos.Y = float64(motionInfo.Pos.Y)
sceneEntity.rot.X = float64(motionInfo.Rot.X) pos.Z = float64(motionInfo.Pos.Z)
sceneEntity.rot.Y = float64(motionInfo.Rot.Y) rot := sceneEntity.GetRot()
sceneEntity.rot.Z = float64(motionInfo.Rot.Z) rot.X = float64(motionInfo.Rot.X)
rot.Y = float64(motionInfo.Rot.Y)
rot.Z = float64(motionInfo.Rot.Z)
// 载具耐力消耗 // 载具耐力消耗
if sceneEntity.gadgetEntity != nil && sceneEntity.gadgetEntity.gadgetVehicleEntity != nil { gadgetEntity := sceneEntity.GetGadgetEntity()
if gadgetEntity != nil && gadgetEntity.GetGadgetVehicleEntity() != nil {
// 处理耐力消耗 // 处理耐力消耗
g.ImmediateStamina(player, motionInfo.State) g.ImmediateStamina(player, motionInfo.State)
// 处理载具销毁请求 // 处理载具销毁请求
g.VehicleDestroyMotion(player, sceneEntity, motionInfo.State) g.VehicleDestroyMotion(player, sceneEntity, motionInfo.State)
} }
} }
sceneEntity.moveState = uint16(motionInfo.State) sceneEntity.SetMoveState(uint16(motionInfo.State))
sceneEntity.lastMoveSceneTimeMs = entityMoveInfo.SceneTime sceneEntity.SetLastMoveSceneTimeMs(entityMoveInfo.SceneTime)
sceneEntity.lastMoveReliableSeq = entityMoveInfo.ReliableSeq sceneEntity.SetLastMoveReliableSeq(entityMoveInfo.ReliableSeq)
player.CombatInvokeHandler.AddEntry(entry.ForwardType, entry) player.CombatInvokeHandler.AddEntry(entry.ForwardType, entry)
case proto.CombatTypeArgument_COMBAT_ANIMATOR_STATE_CHANGED: case proto.CombatTypeArgument_COMBAT_ANIMATOR_STATE_CHANGED:
@@ -253,7 +257,8 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
} }
func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector, newPos *model.Vector) { func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector, newPos *model.Vector) {
aoiManager, exist := WORLD_MANAGER.sceneBlockAoiMap[player.SceneId] sceneBlockAoiMap := WORLD_MANAGER.GetSceneBlockAoiMap()
aoiManager, exist := sceneBlockAoiMap[player.SceneId]
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
if exist { if exist {
@@ -287,8 +292,8 @@ func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector,
if entity == nil { if entity == nil {
continue continue
} }
scene.DestroyEntity(entity.id) scene.DestroyEntity(entity.GetId())
delEntityIdList = append(delEntityIdList, entity.id) delEntityIdList = append(delEntityIdList, entity.GetId())
} }
addEntityIdList := make([]uint32, 0) addEntityIdList := make([]uint32, 0)
for newObjectId, newObject := range newObjectMap { for newObjectId, newObject := range newObjectMap {
@@ -411,7 +416,9 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
if abilityMetaAddAbility.Ability == nil { if abilityMetaAddAbility.Ability == nil {
continue continue
} }
worldAvatar.abilityList = append(worldAvatar.abilityList, abilityMetaAddAbility.Ability) abilityList := worldAvatar.GetAbilityList()
abilityList = append(abilityList, abilityMetaAddAbility.Ability)
worldAvatar.SetAbilityList(abilityList)
case proto.AbilityInvokeArgument_ABILITY_META_MODIFIER_CHANGE: case proto.AbilityInvokeArgument_ABILITY_META_MODIFIER_CHANGE:
abilityMetaModifierChange := new(proto.AbilityMetaModifierChange) abilityMetaModifierChange := new(proto.AbilityMetaModifierChange)
if config.CONF.Hk4e.ClientProtoProxyEnable { if config.CONF.Hk4e.ClientProtoProxyEnable {
@@ -451,7 +458,9 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
if worldAvatar == nil { if worldAvatar == nil {
continue continue
} }
worldAvatar.modifierList = append(worldAvatar.modifierList, abilityAppliedModifier) modifierList := worldAvatar.GetModifierList()
modifierList = append(modifierList, abilityAppliedModifier)
worldAvatar.SetModifierList(modifierList)
default: default:
} }
} }

View File

@@ -71,13 +71,13 @@ func (g *GameManager) GCGAskDuelReq(player *model.Player, payloadMsg pb.Message)
// 获取玩家所在的游戏 // 获取玩家所在的游戏
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid] game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
if !ok { if !ok {
g.CommonRetError(cmd.GCGAskDuelRsp, player, &proto.GCGAskDuelRsp{}, proto.Retcode_RET_GCG_GAME_NOT_RUNNING) g.SendError(cmd.GCGAskDuelRsp, player, &proto.GCGAskDuelRsp{}, proto.Retcode_RET_GCG_GAME_NOT_RUNNING)
return return
} }
// 获取玩家的操控者对象 // 获取玩家的操控者对象
gameController := game.GetControllerByUserId(player.PlayerID) gameController := game.GetControllerByUserId(player.PlayerID)
if gameController == nil { if gameController == nil {
g.CommonRetError(cmd.GCGAskDuelRsp, player, &proto.GCGAskDuelRsp{}, proto.Retcode_RET_GCG_NOT_IN_GCG_DUNGEON) g.SendError(cmd.GCGAskDuelRsp, player, &proto.GCGAskDuelRsp{}, proto.Retcode_RET_GCG_NOT_IN_GCG_DUNGEON)
return return
} }
@@ -265,13 +265,13 @@ func (g *GameManager) GCGInitFinishReq(player *model.Player, payloadMsg pb.Messa
// 获取玩家所在的游戏 // 获取玩家所在的游戏
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid] game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
if !ok { if !ok {
g.CommonRetError(cmd.GCGInitFinishRsp, player, &proto.GCGInitFinishRsp{}, proto.Retcode_RET_GCG_GAME_NOT_RUNNING) g.SendError(cmd.GCGInitFinishRsp, player, &proto.GCGInitFinishRsp{}, proto.Retcode_RET_GCG_GAME_NOT_RUNNING)
return return
} }
// 获取玩家的操控者对象 // 获取玩家的操控者对象
gameController := game.GetControllerByUserId(player.PlayerID) gameController := game.GetControllerByUserId(player.PlayerID)
if gameController == nil { if gameController == nil {
g.CommonRetError(cmd.GCGInitFinishRsp, player, &proto.GCGInitFinishRsp{}, proto.Retcode_RET_GCG_NOT_IN_GCG_DUNGEON) g.SendError(cmd.GCGInitFinishRsp, player, &proto.GCGInitFinishRsp{}, proto.Retcode_RET_GCG_NOT_IN_GCG_DUNGEON)
return return
} }
@@ -291,13 +291,13 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
// 获取玩家所在的游戏 // 获取玩家所在的游戏
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid] game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
if !ok { if !ok {
g.CommonRetError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_GAME_NOT_RUNNING) g.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_GAME_NOT_RUNNING)
return return
} }
// 获取玩家的操控者对象 // 获取玩家的操控者对象
gameController := game.GetControllerByUserId(player.PlayerID) gameController := game.GetControllerByUserId(player.PlayerID)
if gameController == nil { if gameController == nil {
g.CommonRetError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_NOT_IN_GCG_DUNGEON) g.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_NOT_IN_GCG_DUNGEON)
return return
} }
@@ -308,7 +308,7 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
// 操作者是否拥有该卡牌 // 操作者是否拥有该卡牌
cardInfo := gameController.GetCharCardByGuid(op.CardGuid) cardInfo := gameController.GetCharCardByGuid(op.CardGuid)
if cardInfo == nil { if cardInfo == nil {
GAME_MANAGER.CommonRetError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_SELECT_HAND_CARD_GUID_ERROR) GAME_MANAGER.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_SELECT_HAND_CARD_GUID_ERROR)
return return
} }
// 操控者选择角色牌 // 操控者选择角色牌
@@ -318,13 +318,13 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
op := req.Op.GetOpReroll() op := req.Op.GetOpReroll()
diceSideList, ok := game.roundInfo.diceSideMap[gameController.controllerId] diceSideList, ok := game.roundInfo.diceSideMap[gameController.controllerId]
if !ok { if !ok {
g.CommonRetError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_DICE_INDEX_INVALID) g.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_DICE_INDEX_INVALID)
return return
} }
// 判断骰子索引是否有效 // 判断骰子索引是否有效
for _, diceIndex := range op.DiceIndexList { for _, diceIndex := range op.DiceIndexList {
if diceIndex > uint32(len(diceSideList)) { if diceIndex > uint32(len(diceSideList)) {
g.CommonRetError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_DICE_INDEX_INVALID) g.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_DICE_INDEX_INVALID)
return return
} }
} }
@@ -335,13 +335,13 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
op := req.Op.GetOpAttack() op := req.Op.GetOpAttack()
diceSideList, ok := game.roundInfo.diceSideMap[gameController.controllerId] diceSideList, ok := game.roundInfo.diceSideMap[gameController.controllerId]
if !ok { if !ok {
g.CommonRetError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_DICE_INDEX_INVALID) g.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_DICE_INDEX_INVALID)
return return
} }
// 判断骰子索引是否有效 // 判断骰子索引是否有效
for _, diceIndex := range op.CostDiceIndexList { for _, diceIndex := range op.CostDiceIndexList {
if diceIndex > uint32(len(diceSideList)) { if diceIndex > uint32(len(diceSideList)) {
g.CommonRetError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_DICE_INDEX_INVALID) g.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_DICE_INDEX_INVALID)
return return
} }
} }

View File

@@ -19,12 +19,12 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M
scenePointConfig, exist := gdconf.CONF.ScenePointMap[int32(req.SceneId)] scenePointConfig, exist := gdconf.CONF.ScenePointMap[int32(req.SceneId)]
if !exist { if !exist {
g.CommonRetError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}) g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
return return
} }
pointConfig, exist := scenePointConfig.PointMap[int32(req.PointId)] pointConfig, exist := scenePointConfig.PointMap[int32(req.PointId)]
if !exist { if !exist {
g.CommonRetError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}) g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
return return
} }

View File

@@ -93,7 +93,7 @@ func (g *GameManager) JoinOtherWorld(player *model.Player, hostPlayer *model.Pla
playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_OTHER) playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_OTHER)
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerID, player.ClientSeq, playerEnterSceneNotify) g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerID, player.ClientSeq, playerEnterSceneNotify)
} else { } else {
hostWorld.waitEnterPlayerMap[player.PlayerID] = time.Now().UnixMilli() hostWorld.AddWaitPlayer(player.PlayerID)
} }
} }
@@ -103,17 +103,17 @@ func (g *GameManager) PlayerGetForceQuitBanInfoReq(player *model.Player, payload
logger.Debug("user get world exit ban info, uid: %v", player.PlayerID) logger.Debug("user get world exit ban info, uid: %v", player.PlayerID)
ok := true ok := true
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.GetAllPlayer() {
if worldPlayer.SceneLoadState != model.SceneEnterDone { if worldPlayer.SceneLoadState != model.SceneEnterDone {
ok = false ok = false
} }
} }
if !ok { if !ok {
g.CommonRetError(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER) g.SendError(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
return return
} }
g.CommonRetSucc(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{}) g.SendSucc(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{})
} }
func (g *GameManager) BackMyWorldReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) BackMyWorldReq(player *model.Player, payloadMsg pb.Message) {
@@ -122,10 +122,10 @@ func (g *GameManager) BackMyWorldReq(player *model.Player, payloadMsg pb.Message
ok := g.UserLeaveWorld(player) ok := g.UserLeaveWorld(player)
if !ok { if !ok {
g.CommonRetError(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER) g.SendError(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
return return
} }
g.CommonRetSucc(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{}) g.SendSucc(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{})
} }
func (g *GameManager) ChangeWorldToSingleModeReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) ChangeWorldToSingleModeReq(player *model.Player, payloadMsg pb.Message) {
@@ -134,18 +134,18 @@ func (g *GameManager) ChangeWorldToSingleModeReq(player *model.Player, payloadMs
ok := g.UserLeaveWorld(player) ok := g.UserLeaveWorld(player)
if !ok { if !ok {
g.CommonRetError(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER) g.SendError(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
return return
} }
g.CommonRetSucc(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{}) g.SendSucc(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{})
} }
func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Message) {
logger.Debug("user kick player, uid: %v", player.PlayerID) logger.Debug("user kick player, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.SceneKickPlayerReq) req := payloadMsg.(*proto.SceneKickPlayerReq)
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if player.PlayerID != world.owner.PlayerID { if player.PlayerID != world.GetOwner().PlayerID {
g.CommonRetError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{}) g.SendError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{})
return return
} }
targetUid := req.TargetUid targetUid := req.TargetUid
@@ -156,7 +156,7 @@ func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Mes
} }
ok := g.UserLeaveWorld(targetPlayer) ok := g.UserLeaveWorld(targetPlayer)
if !ok { if !ok {
g.CommonRetError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER) g.SendError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
return return
} }
@@ -164,7 +164,7 @@ func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Mes
TargetUid: targetUid, TargetUid: targetUid,
KickerUid: player.PlayerID, KickerUid: player.PlayerID,
} }
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.GetAllPlayer() {
g.SendMsg(cmd.SceneKickPlayerNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneKickPlayerNotify) g.SendMsg(cmd.SceneKickPlayerNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneKickPlayerNotify)
} }
@@ -185,7 +185,7 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, player.PlayerID, player.ClientSeq, playerApplyEnterMpResultNotify) g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, player.PlayerID, player.ClientSeq, playerApplyEnterMpResultNotify)
} }
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer { if world.GetMultiplayer() {
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP) applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP)
return return
} }
@@ -224,13 +224,13 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
}) })
return return
} }
if WORLD_MANAGER.multiplayerWorldNum >= MAX_MULTIPLAYER_WORLD_NUM { if WORLD_MANAGER.GetMultiplayerWorldNum() >= MAX_MULTIPLAYER_WORLD_NUM {
// 超过本服务器最大多人世界数量限制 // 超过本服务器最大多人世界数量限制
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_MAX_PLAYER) applyFailNotify(proto.PlayerApplyEnterMpResultNotify_MAX_PLAYER)
return return
} }
targetWorld := WORLD_MANAGER.GetWorldByID(targetPlayer.WorldId) targetWorld := WORLD_MANAGER.GetWorldByID(targetPlayer.WorldId)
if targetWorld.multiplayer && targetWorld.owner.PlayerID != targetPlayer.PlayerID { if targetWorld.GetMultiplayer() && targetWorld.GetOwner().PlayerID != targetPlayer.PlayerID {
// 向同一世界内的非房主玩家申请时直接拒绝 // 向同一世界内的非房主玩家申请时直接拒绝
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_NOT_IN_PLAYER_WORLD) applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_NOT_IN_PLAYER_WORLD)
return return
@@ -295,7 +295,7 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
} }
otherPlayerWorld := WORLD_MANAGER.GetWorldByID(otherPlayer.WorldId) otherPlayerWorld := WORLD_MANAGER.GetWorldByID(otherPlayer.WorldId)
if otherPlayerWorld.multiplayer { if otherPlayerWorld.GetMultiplayer() {
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{ playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
TargetUid: hostPlayer.PlayerID, TargetUid: hostPlayer.PlayerID,
TargetNickname: hostPlayer.NickName, TargetNickname: hostPlayer.NickName,
@@ -317,7 +317,7 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
func (g *GameManager) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32) { func (g *GameManager) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32) {
world := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId) world := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
if world.multiplayer { if world.GetMultiplayer() {
return return
} }
world.ChangeToMultiplayer() world.ChangeToMultiplayer()
@@ -328,8 +328,8 @@ func (g *GameManager) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32
// 是否多人游戏 // 是否多人游戏
worldDataNotify.WorldPropMap[2] = &proto.PropValue{ worldDataNotify.WorldPropMap[2] = &proto.PropValue{
Type: 2, Type: 2,
Val: object.ConvBoolToInt64(world.multiplayer), Val: object.ConvBoolToInt64(world.GetMultiplayer()),
Value: &proto.PropValue_Ival{Ival: object.ConvBoolToInt64(world.multiplayer)}, Value: &proto.PropValue_Ival{Ival: object.ConvBoolToInt64(world.GetMultiplayer())},
} }
g.SendMsg(cmd.WorldDataNotify, hostPlayer.PlayerID, hostPlayer.ClientSeq, worldDataNotify) g.SendMsg(cmd.WorldDataNotify, hostPlayer.PlayerID, hostPlayer.ClientSeq, worldDataNotify)
@@ -360,10 +360,10 @@ func (g *GameManager) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32
func (g *GameManager) UserLeaveWorld(player *model.Player) bool { func (g *GameManager) UserLeaveWorld(player *model.Player) bool {
oldWorld := WORLD_MANAGER.GetWorldByID(player.WorldId) oldWorld := WORLD_MANAGER.GetWorldByID(player.WorldId)
if !oldWorld.multiplayer { if !oldWorld.GetMultiplayer() {
return false return false
} }
for _, worldPlayer := range oldWorld.playerMap { for _, worldPlayer := range oldWorld.GetAllPlayer() {
if worldPlayer.SceneLoadState != model.SceneEnterDone { if worldPlayer.SceneLoadState != model.SceneEnterDone {
return false return false
} }
@@ -376,22 +376,22 @@ func (g *GameManager) UserWorldAddPlayer(world *World, player *model.Player) {
if !WORLD_MANAGER.IsBigWorld(world) && world.GetWorldPlayerNum() >= 4 { if !WORLD_MANAGER.IsBigWorld(world) && world.GetWorldPlayerNum() >= 4 {
return return
} }
_, exist := world.playerMap[player.PlayerID] _, exist := world.GetAllPlayer()[player.PlayerID]
if exist { if exist {
return return
} }
world.AddPlayer(player, player.SceneId) world.AddPlayer(player, player.SceneId)
player.WorldId = world.id player.WorldId = world.GetId()
if world.GetWorldPlayerNum() > 1 { if world.GetWorldPlayerNum() > 1 {
g.UpdateWorldPlayerInfo(world, player) g.UpdateWorldPlayerInfo(world, player)
} }
} }
func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player) { func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player) {
if world.multiplayer && player.PlayerID == world.owner.PlayerID { if world.GetMultiplayer() && player.PlayerID == world.GetOwner().PlayerID {
// 多人世界房主离开剔除所有其他玩家 // 多人世界房主离开剔除所有其他玩家
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.GetAllPlayer() {
if worldPlayer.PlayerID == world.owner.PlayerID { if worldPlayer.PlayerID == world.GetOwner().PlayerID {
continue continue
} }
if ok := g.UserLeaveWorld(worldPlayer); !ok { if ok := g.UserLeaveWorld(worldPlayer); !ok {
@@ -408,7 +408,7 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
delTeamEntityNotify := g.PacketDelTeamEntityNotify(scene, player) delTeamEntityNotify := g.PacketDelTeamEntityNotify(scene, player)
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify) g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify)
if world.multiplayer { if world.GetMultiplayer() {
playerQuitFromMpNotify := &proto.PlayerQuitFromMpNotify{ playerQuitFromMpNotify := &proto.PlayerQuitFromMpNotify{
Reason: proto.PlayerQuitFromMpNotify_BACK_TO_MY_WORLD, Reason: proto.PlayerQuitFromMpNotify_BACK_TO_MY_WORLD,
} }
@@ -420,25 +420,25 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
world.RemovePlayer(player) world.RemovePlayer(player)
player.WorldId = 0 player.WorldId = 0
if world.owner.PlayerID == player.PlayerID { if world.GetOwner().PlayerID == player.PlayerID {
// 房主离开销毁世界 // 房主离开销毁世界
WORLD_MANAGER.DestroyWorld(world.id) WORLD_MANAGER.DestroyWorld(world.GetId())
MESSAGE_QUEUE.SendToFight(world.owner.FightAppId, &mq.NetMsg{ MESSAGE_QUEUE.SendToFight(world.GetOwner().FightAppId, &mq.NetMsg{
MsgType: mq.MsgTypeFight, MsgType: mq.MsgTypeFight,
EventId: mq.DelFightRoutine, EventId: mq.DelFightRoutine,
FightMsg: &mq.FightMsg{ FightMsg: &mq.FightMsg{
FightRoutineId: world.id, FightRoutineId: world.GetId(),
}, },
}) })
return return
} }
if world.multiplayer && world.GetWorldPlayerNum() > 0 { if world.GetMultiplayer() && world.GetWorldPlayerNum() > 0 {
g.UpdateWorldPlayerInfo(world, player) g.UpdateWorldPlayerInfo(world, player)
} }
} }
func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *model.Player) { func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *model.Player) {
for _, worldPlayer := range hostWorld.playerMap { for _, worldPlayer := range hostWorld.GetAllPlayer() {
if worldPlayer.PlayerID == excludePlayer.PlayerID { if worldPlayer.PlayerID == excludePlayer.PlayerID {
continue continue
} }
@@ -454,7 +454,7 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0), PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
PlayerUidList: make([]uint32, 0), PlayerUidList: make([]uint32, 0),
} }
for _, subWorldPlayer := range hostWorld.playerMap { for _, subWorldPlayer := range hostWorld.GetAllPlayer() {
onlinePlayerInfo := &proto.OnlinePlayerInfo{ onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: subWorldPlayer.PlayerID, Uid: subWorldPlayer.PlayerID,
Nickname: subWorldPlayer.NickName, Nickname: subWorldPlayer.NickName,
@@ -479,7 +479,7 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{ scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{
PlayerInfoList: make([]*proto.ScenePlayerInfo, 0), PlayerInfoList: make([]*proto.ScenePlayerInfo, 0),
} }
for _, worldPlayer := range hostWorld.playerMap { for _, worldPlayer := range hostWorld.GetAllPlayer() {
onlinePlayerInfo := &proto.OnlinePlayerInfo{ onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID, Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName, Nickname: worldPlayer.NickName,
@@ -507,8 +507,8 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
SceneId: worldPlayer.SceneId, SceneId: worldPlayer.SceneId,
TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0), TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0),
} }
if hostWorld.multiplayer { if hostWorld.GetMultiplayer() {
for _, worldPlayer := range hostWorld.playerMap { for _, worldPlayer := range hostWorld.GetAllPlayer() {
if worldPlayer.PlayerID == worldPlayer.PlayerID { if worldPlayer.PlayerID == worldPlayer.PlayerID {
continue continue
} }
@@ -554,13 +554,13 @@ func (g *GameManager) ServerUserMpReq(userMpInfo *mq.UserMpInfo, gsAppId string)
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP) applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP)
return return
} }
if WORLD_MANAGER.multiplayerWorldNum >= MAX_MULTIPLAYER_WORLD_NUM { if WORLD_MANAGER.GetMultiplayerWorldNum() >= MAX_MULTIPLAYER_WORLD_NUM {
// 超过本服务器最大多人世界数量限制 // 超过本服务器最大多人世界数量限制
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_MAX_PLAYER) applyFailNotify(proto.PlayerApplyEnterMpResultNotify_MAX_PLAYER)
return return
} }
hostWorld := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId) hostWorld := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
if hostWorld.multiplayer && hostWorld.owner.PlayerID != hostPlayer.PlayerID { if hostWorld.GetMultiplayer() && hostWorld.GetOwner().PlayerID != hostPlayer.PlayerID {
// 向同一世界内的非房主玩家申请时直接拒绝 // 向同一世界内的非房主玩家申请时直接拒绝
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_NOT_IN_PLAYER_WORLD) applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_NOT_IN_PLAYER_WORLD)
return return
@@ -612,7 +612,7 @@ func (g *GameManager) ServerUserMpReq(userMpInfo *mq.UserMpInfo, gsAppId string)
return return
} }
applyPlayerWorld := WORLD_MANAGER.GetWorldByID(applyPlayer.WorldId) applyPlayerWorld := WORLD_MANAGER.GetWorldByID(applyPlayer.WorldId)
if applyPlayerWorld.multiplayer { if applyPlayerWorld.GetMultiplayer() {
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{ playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
TargetUid: userMpInfo.HostUserId, TargetUid: userMpInfo.HostUserId,
TargetNickname: userMpInfo.HostNickname, TargetNickname: userMpInfo.HostNickname,

View File

@@ -28,7 +28,7 @@ func (g *GameManager) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Mes
enterScenePeerNotify := &proto.EnterScenePeerNotify{ enterScenePeerNotify := &proto.EnterScenePeerNotify{
DestSceneId: player.SceneId, DestSceneId: player.SceneId,
PeerId: world.GetPlayerPeerId(player), PeerId: world.GetPlayerPeerId(player),
HostPeerId: world.GetPlayerPeerId(world.owner), HostPeerId: world.GetPlayerPeerId(world.GetOwner()),
EnterSceneToken: player.EnterSceneToken, EnterSceneToken: player.EnterSceneToken,
} }
g.SendMsg(cmd.EnterScenePeerNotify, player.PlayerID, player.ClientSeq, enterScenePeerNotify) g.SendMsg(cmd.EnterScenePeerNotify, player.PlayerID, player.ClientSeq, enterScenePeerNotify)
@@ -54,7 +54,7 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0), PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
PlayerUidList: make([]uint32, 0), PlayerUidList: make([]uint32, 0),
} }
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.GetAllPlayer() {
onlinePlayerInfo := &proto.OnlinePlayerInfo{ onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID, Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName, Nickname: worldPlayer.NickName,
@@ -76,14 +76,14 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
// 世界等级 // 世界等级
worldDataNotify.WorldPropMap[1] = &proto.PropValue{ worldDataNotify.WorldPropMap[1] = &proto.PropValue{
Type: 1, Type: 1,
Val: int64(world.worldLevel), Val: int64(world.GetWorldLevel()),
Value: &proto.PropValue_Ival{Ival: int64(world.worldLevel)}, Value: &proto.PropValue_Ival{Ival: int64(world.GetWorldLevel())},
} }
// 是否多人游戏 // 是否多人游戏
worldDataNotify.WorldPropMap[2] = &proto.PropValue{ worldDataNotify.WorldPropMap[2] = &proto.PropValue{
Type: 2, Type: 2,
Val: object.ConvBoolToInt64(world.multiplayer), Val: object.ConvBoolToInt64(world.GetMultiplayer()),
Value: &proto.PropValue_Ival{Ival: object.ConvBoolToInt64(world.multiplayer)}, Value: &proto.PropValue_Ival{Ival: object.ConvBoolToInt64(world.GetMultiplayer())},
} }
g.SendMsg(cmd.WorldDataNotify, player.PlayerID, player.ClientSeq, worldDataNotify) g.SendMsg(cmd.WorldDataNotify, player.PlayerID, player.ClientSeq, worldDataNotify)
@@ -110,8 +110,8 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
g.SendMsg(cmd.SceneForceUnlockNotify, player.PlayerID, player.ClientSeq, new(proto.SceneForceUnlockNotify)) g.SendMsg(cmd.SceneForceUnlockNotify, player.PlayerID, player.ClientSeq, new(proto.SceneForceUnlockNotify))
hostPlayerNotify := &proto.HostPlayerNotify{ hostPlayerNotify := &proto.HostPlayerNotify{
HostUid: world.owner.PlayerID, HostUid: world.GetOwner().PlayerID,
HostPeerId: world.GetPlayerPeerId(world.owner), HostPeerId: world.GetPlayerPeerId(world.GetOwner()),
} }
g.SendMsg(cmd.HostPlayerNotify, player.PlayerID, player.ClientSeq, hostPlayerNotify) g.SendMsg(cmd.HostPlayerNotify, player.PlayerID, player.ClientSeq, hostPlayerNotify)
@@ -122,7 +122,7 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
g.SendMsg(cmd.SceneTimeNotify, player.PlayerID, player.ClientSeq, sceneTimeNotify) g.SendMsg(cmd.SceneTimeNotify, player.PlayerID, player.ClientSeq, sceneTimeNotify)
playerGameTimeNotify := &proto.PlayerGameTimeNotify{ playerGameTimeNotify := &proto.PlayerGameTimeNotify{
GameTime: scene.gameTime, GameTime: scene.GetGameTime(),
Uid: player.PlayerID, Uid: player.PlayerID,
} }
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerID, player.ClientSeq, playerGameTimeNotify) g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerID, player.ClientSeq, playerGameTimeNotify)
@@ -138,24 +138,24 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
AbilityControlBlock: new(proto.AbilityControlBlock), AbilityControlBlock: new(proto.AbilityControlBlock),
}, },
MpLevelEntityInfo: &proto.MPLevelEntityInfo{ MpLevelEntityInfo: &proto.MPLevelEntityInfo{
EntityId: WORLD_MANAGER.GetWorldByID(player.WorldId).mpLevelEntityId, EntityId: WORLD_MANAGER.GetWorldByID(player.WorldId).GetMpLevelEntityId(),
AuthorityPeerId: world.GetPlayerPeerId(player), AuthorityPeerId: world.GetPlayerPeerId(player),
AbilityInfo: empty, AbilityInfo: empty,
}, },
AvatarEnterInfo: make([]*proto.AvatarEnterSceneInfo, 0), AvatarEnterInfo: make([]*proto.AvatarEnterSceneInfo, 0),
} }
for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) { for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) {
avatar := player.AvatarMap[worldAvatar.avatarId] avatar := player.AvatarMap[worldAvatar.GetAvatarId()]
avatarEnterSceneInfo := &proto.AvatarEnterSceneInfo{ avatarEnterSceneInfo := &proto.AvatarEnterSceneInfo{
AvatarGuid: avatar.Guid, AvatarGuid: avatar.Guid,
AvatarEntityId: world.GetPlayerWorldAvatarEntityId(player, worldAvatar.avatarId), AvatarEntityId: world.GetPlayerWorldAvatarEntityId(player, worldAvatar.GetAvatarId()),
WeaponGuid: avatar.EquipWeapon.Guid, WeaponGuid: avatar.EquipWeapon.Guid,
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(player, worldAvatar.avatarId), WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(player, worldAvatar.GetAvatarId()),
AvatarAbilityInfo: &proto.AbilitySyncStateInfo{ AvatarAbilityInfo: &proto.AbilitySyncStateInfo{
IsInited: len(worldAvatar.abilityList) != 0, IsInited: len(worldAvatar.GetAbilityList()) != 0,
DynamicValueMap: nil, DynamicValueMap: nil,
AppliedAbilities: worldAvatar.abilityList, AppliedAbilities: worldAvatar.GetAbilityList(),
AppliedModifiers: worldAvatar.modifierList, AppliedModifiers: worldAvatar.GetModifierList(),
MixinRecoverInfos: nil, MixinRecoverInfos: nil,
SgvDynamicValueMap: nil, SgvDynamicValueMap: nil,
}, },
@@ -175,7 +175,7 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{ scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{
PlayerInfoList: make([]*proto.ScenePlayerInfo, 0), PlayerInfoList: make([]*proto.ScenePlayerInfo, 0),
} }
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.GetAllPlayer() {
onlinePlayerInfo := &proto.OnlinePlayerInfo{ onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID, Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName, Nickname: worldPlayer.NickName,
@@ -203,8 +203,8 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
SceneId: player.SceneId, SceneId: player.SceneId,
TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0), TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0),
} }
if world.multiplayer { if world.GetMultiplayer() {
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.GetAllPlayer() {
if worldPlayer.PlayerID == player.PlayerID { if worldPlayer.PlayerID == player.PlayerID {
continue continue
} }
@@ -241,12 +241,12 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
if world.multiplayer && world.IsPlayerFirstEnter(player) { if world.GetMultiplayer() && world.IsPlayerFirstEnter(player) {
guestPostEnterSceneNotify := &proto.GuestPostEnterSceneNotify{ guestPostEnterSceneNotify := &proto.GuestPostEnterSceneNotify{
SceneId: player.SceneId, SceneId: player.SceneId,
Uid: player.PlayerID, Uid: player.PlayerID,
} }
g.SendMsg(cmd.GuestPostEnterSceneNotify, world.owner.PlayerID, world.owner.ClientSeq, guestPostEnterSceneNotify) g.SendMsg(cmd.GuestPostEnterSceneNotify, world.GetOwner().PlayerID, world.GetOwner().ClientSeq, guestPostEnterSceneNotify)
} }
var visionType = proto.VisionType_VISION_NONE var visionType = proto.VisionType_VISION_NONE
@@ -260,7 +260,7 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
activeAvatarEntityId := world.GetPlayerWorldAvatarEntityId(player, activeAvatarId) activeAvatarEntityId := world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)
g.AddSceneEntityNotify(player, visionType, []uint32{activeAvatarEntityId}, true, false) g.AddSceneEntityNotify(player, visionType, []uint32{activeAvatarEntityId}, true, false)
aoiManager, exist := WORLD_MANAGER.sceneBlockAoiMap[scene.id] aoiManager, exist := WORLD_MANAGER.GetSceneBlockAoiMap()[scene.GetId()]
if exist { if exist {
objectList := aoiManager.GetObjectListByPos(float32(player.Pos.X), 0.0, float32(player.Pos.Z)) objectList := aoiManager.GetObjectListByPos(float32(player.Pos.X), 0.0, float32(player.Pos.Z))
for objectId, entityConfig := range objectList { for objectId, entityConfig := range objectList {
@@ -275,10 +275,10 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
entityMap := scene.GetAllEntity() entityMap := scene.GetAllEntity()
entityIdList := make([]uint32, 0) entityIdList := make([]uint32, 0)
for _, entity := range entityMap { for _, entity := range entityMap {
if entity.id == activeAvatarEntityId { if entity.GetId() == activeAvatarEntityId {
continue continue
} }
entityIdList = append(entityIdList, entity.id) entityIdList = append(entityIdList, entity.GetId())
} }
g.AddSceneEntityNotify(player, visionType, entityIdList, false, false) g.AddSceneEntityNotify(player, visionType, entityIdList, false, false)
@@ -294,11 +294,11 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
g.SendMsg(cmd.EnterSceneDoneRsp, player.PlayerID, player.ClientSeq, enterSceneDoneRsp) g.SendMsg(cmd.EnterSceneDoneRsp, player.PlayerID, player.ClientSeq, enterSceneDoneRsp)
player.SceneLoadState = model.SceneEnterDone player.SceneLoadState = model.SceneEnterDone
world.PlayerEnter(player) world.PlayerEnter(player.PlayerID)
for otherPlayerId := range world.waitEnterPlayerMap { for _, otherPlayerId := range world.GetAllWaitPlayer() {
// 房主第一次进入多人世界场景完成 开始通知等待列表中的玩家进入场景 // 房主第一次进入多人世界场景完成 开始通知等待列表中的玩家进入场景
delete(world.waitEnterPlayerMap, otherPlayerId) world.RemoveWaitPlayer(otherPlayerId)
otherPlayer := USER_MANAGER.GetOnlineUser(otherPlayerId) otherPlayer := USER_MANAGER.GetOnlineUser(otherPlayerId)
if otherPlayer == nil { if otherPlayer == nil {
logger.Error("player is nil, uid: %v", otherPlayerId) logger.Error("player is nil, uid: %v", otherPlayerId)
@@ -325,16 +325,16 @@ func (g *GameManager) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Mess
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
scene.ChangeGameTime(gameTime) scene.ChangeGameTime(gameTime)
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.GetAllPlayer() {
playerGameTimeNotify := &proto.PlayerGameTimeNotify{ playerGameTimeNotify := &proto.PlayerGameTimeNotify{
GameTime: scene.gameTime, GameTime: scene.GetGameTime(),
Uid: scenePlayer.PlayerID, Uid: scenePlayer.PlayerID,
} }
g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, playerGameTimeNotify) g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, playerGameTimeNotify)
} }
changeGameTimeRsp := &proto.ChangeGameTimeRsp{ changeGameTimeRsp := &proto.ChangeGameTimeRsp{
CurGameTime: scene.gameTime, CurGameTime: scene.GetGameTime(),
} }
g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp) g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp)
} }
@@ -503,7 +503,7 @@ func (g *GameManager) AddSceneEntityNotifyBroadcast(player *model.Player, scene
AppearType: visionType, AppearType: visionType,
EntityList: entityList, EntityList: entityList,
} }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.GetAllPlayer() {
if aec && scenePlayer.PlayerID == player.PlayerID { if aec && scenePlayer.PlayerID == player.PlayerID {
continue continue
} }
@@ -528,7 +528,7 @@ func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType
EntityList: entityIdList, EntityList: entityIdList,
DisappearType: visionType, DisappearType: visionType,
} }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify) g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
logger.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v", logger.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v",
scenePlayer.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList)) scenePlayer.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList))
@@ -548,35 +548,36 @@ func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType prot
} }
entityList := make([]*proto.SceneEntityInfo, 0) entityList := make([]*proto.SceneEntityInfo, 0)
for _, entityId := range entityIdList[begin:end] { for _, entityId := range entityIdList[begin:end] {
entity, exist := scene.entityMap[entityId] entityMap := scene.GetAllEntity()
entity, exist := entityMap[entityId]
if !exist { if !exist {
logger.Error("get entity is nil, entityId: %v", entityId) logger.Error("get entity is nil, entityId: %v", entityId)
continue continue
} }
switch entity.entityType { switch entity.GetEntityType() {
case uint32(proto.ProtEntityType_PROT_ENTITY_AVATAR): case uint32(proto.ProtEntityType_PROT_ENTITY_AVATAR):
if visionType == proto.VisionType_VISION_MEET && entity.avatarEntity.uid == player.PlayerID { if visionType == proto.VisionType_VISION_MEET && entity.GetAvatarEntity().GetUid() == player.PlayerID {
continue continue
} }
scenePlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid) scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
if scenePlayer == nil { if scenePlayer == nil {
logger.Error("get scene player is nil, world id: %v, scene id: %v", world.id, scene.id) logger.Error("get scene player is nil, world id: %v, scene id: %v", world.GetId(), scene.GetId())
continue continue
} }
if entity.avatarEntity.avatarId != world.GetPlayerActiveAvatarId(scenePlayer) { if entity.GetAvatarEntity().GetAvatarId() != world.GetPlayerActiveAvatarId(scenePlayer) {
continue continue
} }
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer)) sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
entityList = append(entityList, sceneEntityInfoAvatar) entityList = append(entityList, sceneEntityInfoAvatar)
case uint32(proto.ProtEntityType_PROT_ENTITY_WEAPON): case uint32(proto.ProtEntityType_PROT_ENTITY_WEAPON):
case uint32(proto.ProtEntityType_PROT_ENTITY_MONSTER): case uint32(proto.ProtEntityType_PROT_ENTITY_MONSTER):
sceneEntityInfoMonster := g.PacketSceneEntityInfoMonster(scene, entity.id) sceneEntityInfoMonster := g.PacketSceneEntityInfoMonster(scene, entity.GetId())
entityList = append(entityList, sceneEntityInfoMonster) entityList = append(entityList, sceneEntityInfoMonster)
case uint32(proto.ProtEntityType_PROT_ENTITY_NPC): case uint32(proto.ProtEntityType_PROT_ENTITY_NPC):
sceneEntityInfoNpc := g.PacketSceneEntityInfoNpc(scene, entity.id) sceneEntityInfoNpc := g.PacketSceneEntityInfoNpc(scene, entity.GetId())
entityList = append(entityList, sceneEntityInfoNpc) entityList = append(entityList, sceneEntityInfoNpc)
case uint32(proto.ProtEntityType_PROT_ENTITY_GADGET): case uint32(proto.ProtEntityType_PROT_ENTITY_GADGET):
sceneEntityInfoGadget := g.PacketSceneEntityInfoGadget(scene, entity.id) sceneEntityInfoGadget := g.PacketSceneEntityInfoGadget(scene, entity.GetId())
entityList = append(entityList, sceneEntityInfoGadget) entityList = append(entityList, sceneEntityInfoGadget)
} }
} }
@@ -589,13 +590,12 @@ func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType prot
} }
func (g *GameManager) EntityFightPropUpdateNotifyBroadcast(scene *Scene, entity *Entity, fightPropId uint32) { func (g *GameManager) EntityFightPropUpdateNotifyBroadcast(scene *Scene, entity *Entity, fightPropId uint32) {
for _, player := range scene.playerMap { for _, player := range scene.GetAllPlayer() {
// PacketEntityFightPropUpdateNotify // PacketEntityFightPropUpdateNotify
entityFightPropUpdateNotify := new(proto.EntityFightPropUpdateNotify) g.SendMsg(cmd.EntityFightPropUpdateNotify, player.PlayerID, player.ClientSeq, &proto.EntityFightPropUpdateNotify{
entityFightPropUpdateNotify.EntityId = entity.id FightPropMap: entity.GetFightProp(),
entityFightPropUpdateNotify.FightPropMap = make(map[uint32]float32) EntityId: entity.GetId(),
entityFightPropUpdateNotify.FightPropMap[fightPropId] = entity.fightProp[fightPropId] })
g.SendMsg(cmd.EntityFightPropUpdateNotify, player.PlayerID, player.ClientSeq, entityFightPropUpdateNotify)
} }
} }
@@ -646,33 +646,33 @@ func (g *GameManager) PacketFightPropMapToPbFightPropList(fightPropMap map[uint3
} }
func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Player, avatarId uint32) *proto.SceneEntityInfo { func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Player, avatarId uint32) *proto.SceneEntityInfo {
entity := scene.GetEntity(scene.world.GetPlayerWorldAvatarEntityId(player, avatarId)) entity := scene.GetEntity(scene.GetWorld().GetPlayerWorldAvatarEntityId(player, avatarId))
if entity == nil { if entity == nil {
return new(proto.SceneEntityInfo) return new(proto.SceneEntityInfo)
} }
pos := &proto.Vector{ pos := &proto.Vector{
X: float32(entity.pos.X), X: float32(entity.GetPos().X),
Y: float32(entity.pos.Y), Y: float32(entity.GetPos().Y),
Z: float32(entity.pos.Z), Z: float32(entity.GetPos().Z),
} }
worldAvatar := scene.world.GetWorldAvatarByEntityId(entity.id) worldAvatar := scene.GetWorld().GetWorldAvatarByEntityId(entity.GetId())
avatar, ok := player.AvatarMap[worldAvatar.avatarId] avatar, ok := player.AvatarMap[worldAvatar.GetAvatarId()]
if !ok { if !ok {
logger.Error("avatar error, avatarId: %v", worldAvatar.avatarId) logger.Error("avatar error, avatarId: %v", worldAvatar.GetAvatarId())
return new(proto.SceneEntityInfo) return new(proto.SceneEntityInfo)
} }
sceneEntityInfo := &proto.SceneEntityInfo{ sceneEntityInfo := &proto.SceneEntityInfo{
EntityType: proto.ProtEntityType_PROT_ENTITY_AVATAR, EntityType: proto.ProtEntityType_PROT_ENTITY_AVATAR,
EntityId: entity.id, EntityId: entity.GetId(),
MotionInfo: &proto.MotionInfo{ MotionInfo: &proto.MotionInfo{
Pos: pos, Pos: pos,
Rot: &proto.Vector{ Rot: &proto.Vector{
X: float32(entity.rot.X), X: float32(entity.GetRot().X),
Y: float32(entity.rot.Y), Y: float32(entity.GetRot().Y),
Z: float32(entity.rot.Z), Z: float32(entity.GetRot().Z),
}, },
Speed: &proto.Vector{}, Speed: &proto.Vector{},
State: proto.MotionState(entity.moveState), State: proto.MotionState(entity.GetMoveState()),
}, },
PropList: []*proto.PropPair{ PropList: []*proto.PropPair{
{ {
@@ -720,10 +720,10 @@ func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Pl
EntityClientData: new(proto.EntityClientData), EntityClientData: new(proto.EntityClientData),
EntityAuthorityInfo: &proto.EntityAuthorityInfo{ EntityAuthorityInfo: &proto.EntityAuthorityInfo{
AbilityInfo: &proto.AbilitySyncStateInfo{ AbilityInfo: &proto.AbilitySyncStateInfo{
IsInited: len(worldAvatar.abilityList) != 0, IsInited: len(worldAvatar.GetAbilityList()) != 0,
DynamicValueMap: nil, DynamicValueMap: nil,
AppliedAbilities: worldAvatar.abilityList, AppliedAbilities: worldAvatar.GetAbilityList(),
AppliedModifiers: worldAvatar.modifierList, AppliedModifiers: worldAvatar.GetModifierList(),
MixinRecoverInfos: nil, MixinRecoverInfos: nil,
SgvDynamicValueMap: nil, SgvDynamicValueMap: nil,
}, },
@@ -734,8 +734,8 @@ func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Pl
}, },
BornPos: pos, BornPos: pos,
}, },
LastMoveSceneTimeMs: entity.lastMoveSceneTimeMs, LastMoveSceneTimeMs: entity.GetLastMoveSceneTimeMs(),
LastMoveReliableSeq: entity.lastMoveReliableSeq, LastMoveReliableSeq: entity.GetLastMoveReliableSeq(),
} }
return sceneEntityInfo return sceneEntityInfo
} }
@@ -746,30 +746,30 @@ func (g *GameManager) PacketSceneEntityInfoMonster(scene *Scene, entityId uint32
return new(proto.SceneEntityInfo) return new(proto.SceneEntityInfo)
} }
pos := &proto.Vector{ pos := &proto.Vector{
X: float32(entity.pos.X), X: float32(entity.GetPos().X),
Y: float32(entity.pos.Y), Y: float32(entity.GetPos().Y),
Z: float32(entity.pos.Z), Z: float32(entity.GetPos().Z),
} }
sceneEntityInfo := &proto.SceneEntityInfo{ sceneEntityInfo := &proto.SceneEntityInfo{
EntityType: proto.ProtEntityType_PROT_ENTITY_MONSTER, EntityType: proto.ProtEntityType_PROT_ENTITY_MONSTER,
EntityId: entity.id, EntityId: entity.GetId(),
MotionInfo: &proto.MotionInfo{ MotionInfo: &proto.MotionInfo{
Pos: pos, Pos: pos,
Rot: &proto.Vector{ Rot: &proto.Vector{
X: float32(entity.rot.X), X: float32(entity.GetRot().X),
Y: float32(entity.rot.Y), Y: float32(entity.GetRot().Y),
Z: float32(entity.rot.Z), Z: float32(entity.GetRot().Z),
}, },
Speed: &proto.Vector{}, Speed: &proto.Vector{},
State: proto.MotionState(entity.moveState), State: proto.MotionState(entity.GetMoveState()),
}, },
PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{ PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
Value: &proto.PropValue_Ival{Ival: int64(entity.level)}, Value: &proto.PropValue_Ival{Ival: int64(entity.GetLevel())},
Val: int64(entity.level), Val: int64(entity.GetLevel()),
}}}, }}},
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.fightProp), FightPropList: g.PacketFightPropMapToPbFightPropList(entity.GetFightProp()),
LifeState: uint32(entity.lifeState), LifeState: uint32(entity.GetLifeState()),
AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0), AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0),
Entity: &proto.SceneEntityInfo_Monster{ Entity: &proto.SceneEntityInfo_Monster{
Monster: g.PacketSceneMonsterInfo(entity), Monster: g.PacketSceneMonsterInfo(entity),
@@ -794,33 +794,33 @@ func (g *GameManager) PacketSceneEntityInfoNpc(scene *Scene, entityId uint32) *p
return new(proto.SceneEntityInfo) return new(proto.SceneEntityInfo)
} }
pos := &proto.Vector{ pos := &proto.Vector{
X: float32(entity.pos.X), X: float32(entity.GetPos().X),
Y: float32(entity.pos.Y), Y: float32(entity.GetPos().Y),
Z: float32(entity.pos.Z), Z: float32(entity.GetPos().Z),
} }
sceneEntityInfo := &proto.SceneEntityInfo{ sceneEntityInfo := &proto.SceneEntityInfo{
EntityType: proto.ProtEntityType_PROT_ENTITY_NPC, EntityType: proto.ProtEntityType_PROT_ENTITY_NPC,
EntityId: entity.id, EntityId: entity.GetId(),
MotionInfo: &proto.MotionInfo{ MotionInfo: &proto.MotionInfo{
Pos: pos, Pos: pos,
Rot: &proto.Vector{ Rot: &proto.Vector{
X: float32(entity.rot.X), X: float32(entity.GetRot().X),
Y: float32(entity.rot.Y), Y: float32(entity.GetRot().Y),
Z: float32(entity.rot.Z), Z: float32(entity.GetRot().Z),
}, },
Speed: &proto.Vector{}, Speed: &proto.Vector{},
State: proto.MotionState(entity.moveState), State: proto.MotionState(entity.GetMoveState()),
}, },
PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{ PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
Value: &proto.PropValue_Ival{Ival: int64(entity.level)}, Value: &proto.PropValue_Ival{Ival: int64(entity.GetLevel())},
Val: int64(entity.level), Val: int64(entity.GetLevel()),
}}}, }}},
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.fightProp), FightPropList: g.PacketFightPropMapToPbFightPropList(entity.GetFightProp()),
LifeState: uint32(entity.lifeState), LifeState: uint32(entity.GetLifeState()),
AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0), AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0),
Entity: &proto.SceneEntityInfo_Npc{ Entity: &proto.SceneEntityInfo_Npc{
Npc: g.PacketSceneNpcInfo(entity.npcEntity), Npc: g.PacketSceneNpcInfo(entity.GetNpcEntity()),
}, },
EntityClientData: new(proto.EntityClientData), EntityClientData: new(proto.EntityClientData),
EntityAuthorityInfo: &proto.EntityAuthorityInfo{ EntityAuthorityInfo: &proto.EntityAuthorityInfo{
@@ -842,30 +842,30 @@ func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32)
return new(proto.SceneEntityInfo) return new(proto.SceneEntityInfo)
} }
pos := &proto.Vector{ pos := &proto.Vector{
X: float32(entity.pos.X), X: float32(entity.GetPos().X),
Y: float32(entity.pos.Y), Y: float32(entity.GetPos().Y),
Z: float32(entity.pos.Z), Z: float32(entity.GetPos().Z),
} }
sceneEntityInfo := &proto.SceneEntityInfo{ sceneEntityInfo := &proto.SceneEntityInfo{
EntityType: proto.ProtEntityType_PROT_ENTITY_GADGET, EntityType: proto.ProtEntityType_PROT_ENTITY_GADGET,
EntityId: entity.id, EntityId: entity.GetId(),
MotionInfo: &proto.MotionInfo{ MotionInfo: &proto.MotionInfo{
Pos: pos, Pos: pos,
Rot: &proto.Vector{ Rot: &proto.Vector{
X: float32(entity.rot.X), X: float32(entity.GetRot().X),
Y: float32(entity.rot.Y), Y: float32(entity.GetRot().Y),
Z: float32(entity.rot.Z), Z: float32(entity.GetRot().Z),
}, },
Speed: &proto.Vector{}, Speed: &proto.Vector{},
State: proto.MotionState(entity.moveState), State: proto.MotionState(entity.GetMoveState()),
}, },
PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{ PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
Value: &proto.PropValue_Ival{Ival: int64(1)}, Value: &proto.PropValue_Ival{Ival: int64(1)},
Val: int64(1), Val: int64(1),
}}}, }}},
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.fightProp), FightPropList: g.PacketFightPropMapToPbFightPropList(entity.GetFightProp()),
LifeState: uint32(entity.lifeState), LifeState: uint32(entity.GetLifeState()),
AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0), AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0),
EntityClientData: new(proto.EntityClientData), EntityClientData: new(proto.EntityClientData),
EntityAuthorityInfo: &proto.EntityAuthorityInfo{ EntityAuthorityInfo: &proto.EntityAuthorityInfo{
@@ -878,7 +878,8 @@ func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32)
BornPos: pos, BornPos: pos,
}, },
} }
switch entity.gadgetEntity.gadgetType { gadgetEntity := entity.GetGadgetEntity()
switch gadgetEntity.GetGadgetType() {
case GADGET_TYPE_NORMAL: case GADGET_TYPE_NORMAL:
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{ sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
Gadget: g.PacketSceneGadgetInfoNormal(entity), Gadget: g.PacketSceneGadgetInfoNormal(entity),
@@ -889,11 +890,11 @@ func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32)
} }
case GADGET_TYPE_CLIENT: case GADGET_TYPE_CLIENT:
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{ sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
Gadget: g.PacketSceneGadgetInfoClient(entity.gadgetEntity.gadgetClientEntity), Gadget: g.PacketSceneGadgetInfoClient(gadgetEntity.GetGadgetClientEntity()),
} }
case GADGET_TYPE_VEHICLE: case GADGET_TYPE_VEHICLE:
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{ sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
Gadget: g.PacketSceneGadgetInfoVehicle(entity.gadgetEntity.gadgetVehicleEntity), Gadget: g.PacketSceneGadgetInfoVehicle(gadgetEntity.GetGadgetVehicleEntity()),
} }
} }
return sceneEntityInfo return sceneEntityInfo
@@ -915,7 +916,7 @@ func (g *GameManager) PacketSceneAvatarInfo(scene *Scene, player *model.Player,
EquipIdList: equipIdList, EquipIdList: equipIdList,
SkillDepotId: player.AvatarMap[avatarId].SkillDepotId, SkillDepotId: player.AvatarMap[avatarId].SkillDepotId,
Weapon: &proto.SceneWeaponInfo{ Weapon: &proto.SceneWeaponInfo{
EntityId: scene.world.GetPlayerWorldAvatarWeaponEntityId(player, avatarId), EntityId: scene.GetWorld().GetPlayerWorldAvatarWeaponEntityId(player, avatarId),
GadgetId: uint32(gdconf.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId), GadgetId: uint32(gdconf.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId),
ItemId: weapon.ItemId, ItemId: weapon.ItemId,
Guid: weapon.Guid, Guid: weapon.Guid,
@@ -937,7 +938,7 @@ func (g *GameManager) PacketSceneAvatarInfo(scene *Scene, player *model.Player,
func (g *GameManager) PacketSceneMonsterInfo(entity *Entity) *proto.SceneMonsterInfo { func (g *GameManager) PacketSceneMonsterInfo(entity *Entity) *proto.SceneMonsterInfo {
sceneMonsterInfo := &proto.SceneMonsterInfo{ sceneMonsterInfo := &proto.SceneMonsterInfo{
MonsterId: entity.monsterEntity.monsterId, MonsterId: entity.GetMonsterEntity().GetMonsterId(),
AuthorityPeerId: 1, AuthorityPeerId: 1,
BornType: proto.MonsterBornType_MONSTER_BORN_DEFAULT, BornType: proto.MonsterBornType_MONSTER_BORN_DEFAULT,
// BlockId: 3001, // BlockId: 3001,
@@ -958,10 +959,11 @@ func (g *GameManager) PacketSceneNpcInfo(entity *NpcEntity) *proto.SceneNpcInfo
} }
func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGadgetInfo { func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGadgetInfo {
gadgetEntity := entity.GetGadgetEntity()
sceneGadgetInfo := &proto.SceneGadgetInfo{ sceneGadgetInfo := &proto.SceneGadgetInfo{
GadgetId: entity.gadgetEntity.gadgetId, GadgetId: gadgetEntity.GetGadgetId(),
GroupId: 0, GroupId: 0,
ConfigId: entity.configId, ConfigId: entity.GetConfigId(),
GadgetState: 0, GadgetState: 0,
IsEnableInteract: true, IsEnableInteract: true,
AuthorityPeerId: 1, AuthorityPeerId: 1,
@@ -970,15 +972,17 @@ func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGa
} }
func (g *GameManager) PacketSceneGadgetInfoGather(entity *Entity) *proto.SceneGadgetInfo { func (g *GameManager) PacketSceneGadgetInfoGather(entity *Entity) *proto.SceneGadgetInfo {
gather, ok := gdconf.CONF.GatherDataMap[int32(entity.gadgetEntity.gadgetGatherEntity.gatherId)] gadgetEntity := entity.GetGadgetEntity()
gatherEntity := gadgetEntity.GetGadgetGatherEntity()
gather, ok := gdconf.CONF.GatherDataMap[int32(gatherEntity.GetGatherId())]
if !ok { if !ok {
logger.Error("gather data error, gatherId: %v", entity.gadgetEntity.gadgetGatherEntity.gatherId) logger.Error("gather data error, gatherId: %v", gatherEntity.GetGatherId())
return new(proto.SceneGadgetInfo) return new(proto.SceneGadgetInfo)
} }
sceneGadgetInfo := &proto.SceneGadgetInfo{ sceneGadgetInfo := &proto.SceneGadgetInfo{
GadgetId: entity.gadgetEntity.gadgetId, GadgetId: gadgetEntity.GetGadgetId(),
GroupId: 0, GroupId: 0,
ConfigId: entity.configId, ConfigId: entity.GetConfigId(),
GadgetState: 0, GadgetState: 0,
IsEnableInteract: true, IsEnableInteract: true,
AuthorityPeerId: 1, AuthorityPeerId: 1,
@@ -994,33 +998,33 @@ func (g *GameManager) PacketSceneGadgetInfoGather(entity *Entity) *proto.SceneGa
func (g *GameManager) PacketSceneGadgetInfoClient(gadgetClientEntity *GadgetClientEntity) *proto.SceneGadgetInfo { func (g *GameManager) PacketSceneGadgetInfoClient(gadgetClientEntity *GadgetClientEntity) *proto.SceneGadgetInfo {
sceneGadgetInfo := &proto.SceneGadgetInfo{ sceneGadgetInfo := &proto.SceneGadgetInfo{
GadgetId: gadgetClientEntity.configId, GadgetId: gadgetClientEntity.GetConfigId(),
OwnerEntityId: gadgetClientEntity.ownerEntityId, OwnerEntityId: gadgetClientEntity.GetOwnerEntityId(),
AuthorityPeerId: 1, AuthorityPeerId: 1,
IsEnableInteract: true, IsEnableInteract: true,
Content: &proto.SceneGadgetInfo_ClientGadget{ Content: &proto.SceneGadgetInfo_ClientGadget{
ClientGadget: &proto.ClientGadgetInfo{ ClientGadget: &proto.ClientGadgetInfo{
CampId: gadgetClientEntity.campId, CampId: gadgetClientEntity.GetCampId(),
CampType: gadgetClientEntity.campType, CampType: gadgetClientEntity.GetCampType(),
OwnerEntityId: gadgetClientEntity.ownerEntityId, OwnerEntityId: gadgetClientEntity.GetOwnerEntityId(),
TargetEntityId: gadgetClientEntity.targetEntityId, TargetEntityId: gadgetClientEntity.GetTargetEntityId(),
}, },
}, },
PropOwnerEntityId: gadgetClientEntity.propOwnerEntityId, PropOwnerEntityId: gadgetClientEntity.GetPropOwnerEntityId(),
} }
return sceneGadgetInfo return sceneGadgetInfo
} }
func (g *GameManager) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVehicleEntity) *proto.SceneGadgetInfo { func (g *GameManager) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVehicleEntity) *proto.SceneGadgetInfo {
sceneGadgetInfo := &proto.SceneGadgetInfo{ sceneGadgetInfo := &proto.SceneGadgetInfo{
GadgetId: gadgetVehicleEntity.vehicleId, GadgetId: gadgetVehicleEntity.GetVehicleId(),
AuthorityPeerId: WORLD_MANAGER.GetWorldByID(gadgetVehicleEntity.owner.WorldId).GetPlayerPeerId(gadgetVehicleEntity.owner), AuthorityPeerId: WORLD_MANAGER.GetWorldByID(gadgetVehicleEntity.GetOwner().WorldId).GetPlayerPeerId(gadgetVehicleEntity.GetOwner()),
IsEnableInteract: true, IsEnableInteract: true,
Content: &proto.SceneGadgetInfo_VehicleInfo{ Content: &proto.SceneGadgetInfo_VehicleInfo{
VehicleInfo: &proto.VehicleInfo{ VehicleInfo: &proto.VehicleInfo{
MemberList: make([]*proto.VehicleMember, 0, len(gadgetVehicleEntity.memberMap)), MemberList: make([]*proto.VehicleMember, 0, len(gadgetVehicleEntity.GetMemberMap())),
OwnerUid: gadgetVehicleEntity.owner.PlayerID, OwnerUid: gadgetVehicleEntity.GetOwner().PlayerID,
CurStamina: gadgetVehicleEntity.curStamina, CurStamina: gadgetVehicleEntity.GetCurStamina(),
}, },
}, },
} }
@@ -1030,7 +1034,7 @@ func (g *GameManager) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVe
func (g *GameManager) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify { func (g *GameManager) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify {
delTeamEntityNotify := &proto.DelTeamEntityNotify{ delTeamEntityNotify := &proto.DelTeamEntityNotify{
SceneId: player.SceneId, SceneId: player.SceneId,
DelEntityIdList: []uint32{scene.world.GetPlayerTeamEntityId(player)}, DelEntityIdList: []uint32{scene.GetWorld().GetPlayerTeamEntityId(player)},
} }
return delTeamEntityNotify return delTeamEntityNotify
} }

View File

@@ -23,7 +23,7 @@ func (g *GameManager) GetPlayerSocialDetailReq(player *model.Player, payloadMsg
targetPlayer, _, _ := USER_MANAGER.LoadGlobalPlayer(targetUid) targetPlayer, _, _ := USER_MANAGER.LoadGlobalPlayer(targetUid)
if targetPlayer == nil { if targetPlayer == nil {
g.CommonRetError(cmd.GetPlayerSocialDetailRsp, player, &proto.GetPlayerSocialDetailRsp{}, proto.Retcode_RET_PLAYER_NOT_EXIST) g.SendError(cmd.GetPlayerSocialDetailRsp, player, &proto.GetPlayerSocialDetailRsp{}, proto.Retcode_RET_PLAYER_NOT_EXIST)
return return
} }
_, exist := player.FriendList[targetPlayer.PlayerID] _, exist := player.FriendList[targetPlayer.PlayerID]
@@ -50,7 +50,7 @@ func (g *GameManager) SetPlayerBirthdayReq(player *model.Player, payloadMsg pb.M
logger.Debug("user set birthday, uid: %v", player.PlayerID) logger.Debug("user set birthday, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.SetPlayerBirthdayReq) req := payloadMsg.(*proto.SetPlayerBirthdayReq)
if player.Birthday[0] != 0 || player.Birthday[1] != 0 { if player.Birthday[0] != 0 || player.Birthday[1] != 0 {
g.CommonRetError(cmd.SetPlayerBirthdayRsp, player, &proto.SetPlayerBirthdayRsp{}) g.SendError(cmd.SetPlayerBirthdayRsp, player, &proto.SetPlayerBirthdayRsp{})
return return
} }
birthday := req.Birthday birthday := req.Birthday
@@ -440,7 +440,7 @@ func (g *GameManager) GetOnlinePlayerInfoReq(player *model.Player, payloadMsg pb
targetPlayer, online, _ := USER_MANAGER.LoadGlobalPlayer(targetUid.TargetUid) targetPlayer, online, _ := USER_MANAGER.LoadGlobalPlayer(targetUid.TargetUid)
if targetPlayer == nil || !online { if targetPlayer == nil || !online {
g.CommonRetError(cmd.GetOnlinePlayerInfoRsp, player, &proto.GetOnlinePlayerInfoRsp{}, proto.Retcode_RET_PLAYER_NOT_ONLINE) g.SendError(cmd.GetOnlinePlayerInfoRsp, player, &proto.GetOnlinePlayerInfoRsp{}, proto.Retcode_RET_PLAYER_NOT_ONLINE)
return return
} }

View File

@@ -52,7 +52,7 @@ func (g *GameManager) HandleAbilityStamina(player *model.Player, entry *proto.Ab
} }
// 查找是不是属于该角色实体的ability id // 查找是不是属于该角色实体的ability id
abilityNameHashCode := uint32(0) abilityNameHashCode := uint32(0)
for _, ability := range worldAvatar.abilityList { for _, ability := range worldAvatar.GetAbilityList() {
if ability.InstancedAbilityId == entry.Head.InstancedAbilityId { if ability.InstancedAbilityId == entry.Head.InstancedAbilityId {
// logger.Error("%v", ability) // logger.Error("%v", ability)
abilityNameHashCode = ability.AbilityName.GetHash() abilityNameHashCode = ability.AbilityName.GetHash()
@@ -107,7 +107,7 @@ func (g *GameManager) SceneAvatarStaminaStepReq(player *model.Player, payloadMsg
angleRevise = int32(req.Rot.X - 360.0) angleRevise = int32(req.Rot.X - 360.0)
} else { } else {
logger.Error("invalid rot x angle: %v, uid: %v", req.Rot.X, player.PlayerID) logger.Error("invalid rot x angle: %v, uid: %v", req.Rot.X, player.PlayerID)
g.CommonRetError(cmd.SceneAvatarStaminaStepRsp, player, &proto.SceneAvatarStaminaStepRsp{}) g.SendError(cmd.SceneAvatarStaminaStepRsp, player, &proto.SceneAvatarStaminaStepRsp{})
return return
} }
// 攀爬耐力修正曲线 // 攀爬耐力修正曲线
@@ -191,9 +191,9 @@ func (g *GameManager) SkillSustainStamina(player *model.Player, isSwim bool) {
return return
} }
// 获取现行角色的配置表 // 获取现行角色的配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.avatarId)] avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
if !ok { if !ok {
logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.avatarId) logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.GetAvatarId())
return return
} }
@@ -230,9 +230,9 @@ func (g *GameManager) ChargedAttackStamina(player *model.Player, worldAvatar *Wo
return return
} }
// 获取现行角色的配置表 // 获取现行角色的配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.avatarId)] avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
if !ok { if !ok {
logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.avatarId) logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.GetAvatarId())
return return
} }
@@ -307,11 +307,12 @@ func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
return return
} }
// 确保实体类型是否为载具 // 确保实体类型是否为载具
if entity.gadgetEntity == nil || entity.gadgetEntity.gadgetVehicleEntity == nil { gadgetEntity := entity.GetGadgetEntity()
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
return return
} }
// 判断玩家处于载具中 // 判断玩家处于载具中
if g.IsPlayerInVehicle(player, entity.gadgetEntity.gadgetVehicleEntity) { if g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
// 角色回复耐力 // 角色回复耐力
g.UpdatePlayerStamina(player, constant.StaminaCostConst.IN_SKIFF) g.UpdatePlayerStamina(player, constant.StaminaCostConst.IN_SKIFF)
} else { } else {
@@ -333,7 +334,8 @@ func (g *GameManager) SustainStaminaHandler(player *model.Player) {
// 获取玩家处于的载具实体 // 获取玩家处于的载具实体
entity := scene.GetEntity(player.VehicleInfo.InVehicleEntityId) entity := scene.GetEntity(player.VehicleInfo.InVehicleEntityId)
// 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力 // 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力
if entity != nil && (entity.gadgetEntity != nil && entity.gadgetEntity.gadgetVehicleEntity != nil) && g.IsPlayerInVehicle(player, entity.gadgetEntity.gadgetVehicleEntity) { gadgetEntity := entity.GetGadgetEntity()
if entity != nil && (gadgetEntity != nil && gadgetEntity.GetGadgetVehicleEntity() != nil) && g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
// 更新载具耐力 // 更新载具耐力
g.UpdateVehicleStamina(player, entity, player.StaminaInfo.CostStamina) g.UpdateVehicleStamina(player, entity, player.StaminaInfo.CostStamina)
} else { } else {
@@ -382,9 +384,10 @@ func (g *GameManager) UpdateVehicleStamina(player *model.Player, vehicleEntity *
// 因为载具的耐力需要换算 // 因为载具的耐力需要换算
// 这里先*100后面要用的时候再换算 为了确保精度 // 这里先*100后面要用的时候再换算 为了确保精度
// 最大耐力值 // 最大耐力值
maxStamina := int32(vehicleEntity.gadgetEntity.gadgetVehicleEntity.maxStamina * 100) gadgetEntity := vehicleEntity.GetGadgetEntity()
maxStamina := int32(gadgetEntity.GetGadgetVehicleEntity().GetMaxStamina() * 100)
// 现行耐力值 // 现行耐力值
curStamina := int32(vehicleEntity.gadgetEntity.gadgetVehicleEntity.curStamina * 100) curStamina := int32(gadgetEntity.GetGadgetVehicleEntity().GetCurStamina() * 100)
// 将被变更的耐力 // 将被变更的耐力
stamina := g.GetChangeStamina(curStamina, maxStamina, staminaCost) stamina := g.GetChangeStamina(curStamina, maxStamina, staminaCost)
@@ -449,9 +452,9 @@ func (g *GameManager) DrownBackHandler(player *model.Player) {
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player)) activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player))
avatarEntity := scene.GetEntity(activeAvatar.avatarEntityId) avatarEntity := scene.GetEntity(activeAvatar.GetAvatarEntityId())
if avatarEntity == nil { if avatarEntity == nil {
logger.Error("avatar entity is nil, entityId: %v", activeAvatar.avatarEntityId) logger.Error("avatar entity is nil, entityId: %v", activeAvatar.GetAvatarEntityId())
return return
} }
@@ -514,9 +517,9 @@ func (g *GameManager) HandleDrown(player *model.Player, stamina uint32) {
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player)) activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player))
avatarEntity := scene.GetEntity(activeAvatar.avatarEntityId) avatarEntity := scene.GetEntity(activeAvatar.GetAvatarEntityId())
if avatarEntity == nil { if avatarEntity == nil {
logger.Error("avatar entity is nil, entityId: %v", activeAvatar.avatarEntityId) logger.Error("avatar entity is nil, entityId: %v", activeAvatar.GetAvatarEntityId())
return return
} }
@@ -533,12 +536,13 @@ func (g *GameManager) HandleDrown(player *model.Player, stamina uint32) {
// SetVehicleStamina 设置载具耐力 // SetVehicleStamina 设置载具耐力
func (g *GameManager) SetVehicleStamina(player *model.Player, vehicleEntity *Entity, stamina float32) { func (g *GameManager) SetVehicleStamina(player *model.Player, vehicleEntity *Entity, stamina float32) {
// 设置载具的耐力 // 设置载具的耐力
vehicleEntity.gadgetEntity.gadgetVehicleEntity.curStamina = stamina gadgetEntity := vehicleEntity.GetGadgetEntity()
gadgetEntity.GetGadgetVehicleEntity().SetCurStamina(stamina)
// logger.Debug("vehicle stamina set, stamina: %v", stamina) // logger.Debug("vehicle stamina set, stamina: %v", stamina)
// PacketVehicleStaminaNotify // PacketVehicleStaminaNotify
vehicleStaminaNotify := new(proto.VehicleStaminaNotify) vehicleStaminaNotify := new(proto.VehicleStaminaNotify)
vehicleStaminaNotify.EntityId = vehicleEntity.id vehicleStaminaNotify.EntityId = vehicleEntity.GetId()
vehicleStaminaNotify.CurStamina = stamina vehicleStaminaNotify.CurStamina = stamina
g.SendMsg(cmd.VehicleStaminaNotify, player.PlayerID, player.ClientSeq, vehicleStaminaNotify) g.SendMsg(cmd.VehicleStaminaNotify, player.PlayerID, player.ClientSeq, vehicleStaminaNotify)
} }

View File

@@ -29,7 +29,7 @@ func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Messag
logger.Error("can not find the target avatar in team, uid: %v, targetAvatarId: %v", player.PlayerID, targetAvatarId) logger.Error("can not find the target avatar in team, uid: %v, targetAvatarId: %v", player.PlayerID, targetAvatarId)
return return
} }
if !world.multiplayer { if !world.GetMultiplayer() {
player.TeamConfig.CurrAvatarIndex = uint8(newAvatarIndex) player.TeamConfig.CurrAvatarIndex = uint8(newAvatarIndex)
} }
world.SetPlayerAvatarIndex(player, newAvatarIndex) world.SetPlayerAvatarIndex(player, newAvatarIndex)
@@ -39,13 +39,13 @@ func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Messag
logger.Error("can not find old avatar entity, entity id: %v", oldAvatarEntityId) logger.Error("can not find old avatar entity, entity id: %v", oldAvatarEntityId)
return return
} }
oldAvatarEntity.moveState = uint16(proto.MotionState_MOTION_STANDBY) oldAvatarEntity.SetMoveState(uint16(proto.MotionState_MOTION_STANDBY))
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{ sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
DisappearType: proto.VisionType_VISION_REPLACE, DisappearType: proto.VisionType_VISION_REPLACE,
EntityList: []uint32{oldAvatarEntity.id}, EntityList: []uint32{oldAvatarEntity.GetId()},
} }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify) g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
} }
@@ -53,10 +53,10 @@ func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Messag
newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarId) newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarId)
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{ sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
AppearType: proto.VisionType_VISION_REPLACE, AppearType: proto.VisionType_VISION_REPLACE,
Param: oldAvatarEntity.id, Param: oldAvatarEntity.GetId(),
EntityList: []*proto.SceneEntityInfo{newAvatarEntity}, EntityList: []*proto.SceneEntityInfo{newAvatarEntity},
} }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify) g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify)
} }
@@ -70,19 +70,19 @@ func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Mes
logger.Debug("user change team avatar, uid: %v", player.PlayerID) logger.Debug("user change team avatar, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.SetUpAvatarTeamReq) req := payloadMsg.(*proto.SetUpAvatarTeamReq)
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer { if world.GetMultiplayer() {
g.CommonRetError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{}) g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
return return
} }
teamId := req.TeamId teamId := req.TeamId
if teamId <= 0 || teamId >= 5 { if teamId <= 0 || teamId >= 5 {
g.CommonRetError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{}) g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
return return
} }
avatarGuidList := req.AvatarTeamGuidList avatarGuidList := req.AvatarTeamGuidList
selfTeam := teamId == uint32(player.TeamConfig.GetActiveTeamId()) selfTeam := teamId == uint32(player.TeamConfig.GetActiveTeamId())
if (selfTeam && len(avatarGuidList) == 0) || len(avatarGuidList) > 4 { if (selfTeam && len(avatarGuidList) == 0) || len(avatarGuidList) > 4 {
g.CommonRetError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{}) g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
return return
} }
avatarIdList := make([]uint32, 0) avatarIdList := make([]uint32, 0)
@@ -139,8 +139,8 @@ func (g *GameManager) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb
req := payloadMsg.(*proto.ChooseCurAvatarTeamReq) req := payloadMsg.(*proto.ChooseCurAvatarTeamReq)
teamId := req.TeamId teamId := req.TeamId
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer { if world.GetMultiplayer() {
g.CommonRetError(cmd.ChooseCurAvatarTeamRsp, player, &proto.ChooseCurAvatarTeamRsp{}) g.SendError(cmd.ChooseCurAvatarTeamRsp, player, &proto.ChooseCurAvatarTeamRsp{})
return return
} }
team := player.TeamConfig.GetTeamByIndex(uint8(teamId) - 1) team := player.TeamConfig.GetTeamByIndex(uint8(teamId) - 1)
@@ -169,8 +169,8 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
req := payloadMsg.(*proto.ChangeMpTeamAvatarReq) req := payloadMsg.(*proto.ChangeMpTeamAvatarReq)
avatarGuidList := req.AvatarGuidList avatarGuidList := req.AvatarGuidList
world := WORLD_MANAGER.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if !world.multiplayer || len(avatarGuidList) == 0 || len(avatarGuidList) > 4 { if !world.GetMultiplayer() || len(avatarGuidList) == 0 || len(avatarGuidList) > 4 {
g.CommonRetError(cmd.ChangeMpTeamAvatarRsp, player, &proto.ChangeMpTeamAvatarRsp{}) g.SendError(cmd.ChangeMpTeamAvatarRsp, player, &proto.ChangeMpTeamAvatarRsp{})
return return
} }
avatarIdList := make([]uint32, 0) avatarIdList := make([]uint32, 0)
@@ -187,7 +187,7 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
newAvatarIndex := world.GetPlayerAvatarIndexByAvatarId(player, currAvatarId) newAvatarIndex := world.GetPlayerAvatarIndexByAvatarId(player, currAvatarId)
world.SetPlayerAvatarIndex(player, newAvatarIndex) world.SetPlayerAvatarIndex(player, newAvatarIndex)
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.GetAllPlayer() {
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world) sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify) g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify)
} }
@@ -201,17 +201,17 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeamUpdateNotify { func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeamUpdateNotify {
sceneTeamUpdateNotify := &proto.SceneTeamUpdateNotify{ sceneTeamUpdateNotify := &proto.SceneTeamUpdateNotify{
IsInMp: world.multiplayer, IsInMp: world.GetMultiplayer(),
} }
empty := new(proto.AbilitySyncStateInfo) empty := new(proto.AbilitySyncStateInfo)
for _, worldAvatar := range world.GetWorldAvatarList() { for _, worldAvatar := range world.GetWorldAvatarList() {
worldPlayer := USER_MANAGER.GetOnlineUser(worldAvatar.uid) worldPlayer := USER_MANAGER.GetOnlineUser(worldAvatar.GetUid())
if worldPlayer == nil { if worldPlayer == nil {
logger.Error("player is nil, uid: %v", worldAvatar.uid) logger.Error("player is nil, uid: %v", worldAvatar.GetUid())
continue continue
} }
worldPlayerScene := world.GetSceneById(worldPlayer.SceneId) worldPlayerScene := world.GetSceneById(worldPlayer.SceneId)
worldPlayerAvatar := worldPlayer.AvatarMap[worldAvatar.avatarId] worldPlayerAvatar := worldPlayer.AvatarMap[worldAvatar.GetAvatarId()]
equipIdList := make([]uint32, 0) equipIdList := make([]uint32, 0)
weapon := worldPlayerAvatar.EquipWeapon weapon := worldPlayerAvatar.EquipWeapon
equipIdList = append(equipIdList, weapon.ItemId) equipIdList = append(equipIdList, weapon.ItemId)
@@ -222,29 +222,29 @@ func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeam
PlayerUid: worldPlayer.PlayerID, PlayerUid: worldPlayer.PlayerID,
AvatarGuid: worldPlayerAvatar.Guid, AvatarGuid: worldPlayerAvatar.Guid,
SceneId: worldPlayer.SceneId, SceneId: worldPlayer.SceneId,
EntityId: world.GetPlayerWorldAvatarEntityId(worldPlayer, worldAvatar.avatarId), EntityId: world.GetPlayerWorldAvatarEntityId(worldPlayer, worldAvatar.GetAvatarId()),
SceneEntityInfo: g.PacketSceneEntityInfoAvatar(worldPlayerScene, worldPlayer, worldAvatar.avatarId), SceneEntityInfo: g.PacketSceneEntityInfoAvatar(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId()),
WeaponGuid: worldPlayerAvatar.EquipWeapon.Guid, WeaponGuid: worldPlayerAvatar.EquipWeapon.Guid,
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(worldPlayer, worldAvatar.avatarId), WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(worldPlayer, worldAvatar.GetAvatarId()),
IsPlayerCurAvatar: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.avatarId, IsPlayerCurAvatar: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.GetAvatarId(),
IsOnScene: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.avatarId, IsOnScene: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.GetAvatarId(),
AvatarAbilityInfo: &proto.AbilitySyncStateInfo{ AvatarAbilityInfo: &proto.AbilitySyncStateInfo{
IsInited: len(worldAvatar.abilityList) != 0, IsInited: len(worldAvatar.GetAbilityList()) != 0,
DynamicValueMap: nil, DynamicValueMap: nil,
AppliedAbilities: worldAvatar.abilityList, AppliedAbilities: worldAvatar.GetAbilityList(),
AppliedModifiers: worldAvatar.modifierList, AppliedModifiers: worldAvatar.GetModifierList(),
MixinRecoverInfos: nil, MixinRecoverInfos: nil,
SgvDynamicValueMap: nil, SgvDynamicValueMap: nil,
}, },
WeaponAbilityInfo: empty, WeaponAbilityInfo: empty,
AbilityControlBlock: new(proto.AbilityControlBlock), AbilityControlBlock: new(proto.AbilityControlBlock),
} }
if world.multiplayer { if world.GetMultiplayer() {
sceneTeamAvatar.AvatarInfo = g.PacketAvatarInfo(worldPlayerAvatar) sceneTeamAvatar.AvatarInfo = g.PacketAvatarInfo(worldPlayerAvatar)
sceneTeamAvatar.SceneAvatarInfo = g.PacketSceneAvatarInfo(worldPlayerScene, worldPlayer, worldAvatar.avatarId) sceneTeamAvatar.SceneAvatarInfo = g.PacketSceneAvatarInfo(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId())
} }
// add AbilityControlBlock // add AbilityControlBlock
avatarDataConfig := gdconf.CONF.AvatarDataMap[int32(worldAvatar.avatarId)] avatarDataConfig := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
acb := sceneTeamAvatar.AbilityControlBlock acb := sceneTeamAvatar.AbilityControlBlock
embryoId := 0 embryoId := 0
// add avatar abilities // add avatar abilities

View File

@@ -18,7 +18,8 @@ func (g *GameManager) VehicleDestroyMotion(player *model.Player, entity *Entity,
// 状态等于 MOTION_STATE_DESTROY_VEHICLE 代表请求销毁 // 状态等于 MOTION_STATE_DESTROY_VEHICLE 代表请求销毁
if state == proto.MotionState_MOTION_DESTROY_VEHICLE { if state == proto.MotionState_MOTION_DESTROY_VEHICLE {
g.DestroyVehicleEntity(player, scene, entity.gadgetEntity.gadgetVehicleEntity.vehicleId, entity.id) gadgetEntity := entity.GetGadgetEntity()
g.DestroyVehicleEntity(player, scene, gadgetEntity.GetGadgetVehicleEntity().GetVehicleId(), entity.GetId())
} }
} }
@@ -32,7 +33,7 @@ func (g *GameManager) CreateVehicleReq(player *model.Player, payloadMsg pb.Messa
// 创建载具冷却时间 // 创建载具冷却时间
createVehicleCd := int64(5000) // TODO 冷却时间读取配置表 createVehicleCd := int64(5000) // TODO 冷却时间读取配置表
if time.Now().UnixMilli()-player.VehicleInfo.LastCreateTime < createVehicleCd { if time.Now().UnixMilli()-player.VehicleInfo.LastCreateTime < createVehicleCd {
g.CommonRetError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_CREATE_VEHICLE_IN_CD) g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_CREATE_VEHICLE_IN_CD)
return return
} }
@@ -52,7 +53,7 @@ func (g *GameManager) CreateVehicleReq(player *model.Player, payloadMsg pb.Messa
entityId := scene.CreateEntityGadgetVehicle(player.PlayerID, pos, rot, req.VehicleId) entityId := scene.CreateEntityGadgetVehicle(player.PlayerID, pos, rot, req.VehicleId)
if entityId == 0 { if entityId == 0 {
logger.Error("vehicle entityId is 0, uid: %v", player.PlayerID) logger.Error("vehicle entityId is 0, uid: %v", player.PlayerID)
g.CommonRetError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}) g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{})
return return
} }
GAME_MANAGER.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false) GAME_MANAGER.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
@@ -73,7 +74,7 @@ func (g *GameManager) IsPlayerInVehicle(player *model.Player, gadgetVehicleEntit
if gadgetVehicleEntity == nil { if gadgetVehicleEntity == nil {
return false return false
} }
for _, p := range gadgetVehicleEntity.memberMap { for _, p := range gadgetVehicleEntity.GetMemberMap() {
if p == player { if p == player {
return true return true
} }
@@ -88,51 +89,53 @@ func (g *GameManager) DestroyVehicleEntity(player *model.Player, scene *Scene, v
return return
} }
// 确保实体类型是否为载具 // 确保实体类型是否为载具
if entity.gadgetEntity == nil || entity.gadgetEntity.gadgetVehicleEntity == nil { gadgetEntity := entity.GetGadgetEntity()
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
return return
} }
// 目前原神仅有一种载具 多载具目前理论上是兼容了 到时候有问题再改 // 目前原神仅有一种载具 多载具目前理论上是兼容了 到时候有问题再改
// 确保载具Id为将要创建的 (每种载具允许存在1个) // 确保载具Id为将要创建的 (每种载具允许存在1个)
if entity.gadgetEntity.gadgetVehicleEntity.vehicleId != vehicleId { if gadgetEntity.GetGadgetVehicleEntity().GetVehicleId() != vehicleId {
return return
} }
// 该载具是否为此玩家的 // 该载具是否为此玩家的
if entity.gadgetEntity.gadgetVehicleEntity.owner != player { if gadgetEntity.GetGadgetVehicleEntity().GetOwner() != player {
return return
} }
// 如果玩家正在载具中 // 如果玩家正在载具中
if g.IsPlayerInVehicle(player, entity.gadgetEntity.gadgetVehicleEntity) { if g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
// 离开载具 // 离开载具
g.ExitVehicle(player, entity, player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid) g.ExitVehicle(player, entity, player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid)
} }
// 删除已创建的载具 // 删除已创建的载具
scene.DestroyEntity(entity.id) scene.DestroyEntity(entity.GetId())
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.id}) g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.GetId()})
} }
// EnterVehicle 进入载具 // EnterVehicle 进入载具
func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uint64) { func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
maxSlot := 1 // TODO 读取配置表 maxSlot := 1 // TODO 读取配置表
// 判断载具是否已满 // 判断载具是否已满
if len(entity.gadgetEntity.gadgetVehicleEntity.memberMap) >= maxSlot { gadgetEntity := entity.GetGadgetEntity()
g.CommonRetError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_VEHICLE_SLOT_OCCUPIED) if len(gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()) >= maxSlot {
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_VEHICLE_SLOT_OCCUPIED)
return return
} }
// 找出载具空闲的位置 // 找出载具空闲的位置
var freePos uint32 var freePos uint32
for i := uint32(0); i < uint32(maxSlot); i++ { for i := uint32(0); i < uint32(maxSlot); i++ {
p := entity.gadgetEntity.gadgetVehicleEntity.memberMap[i] p := gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()[i]
// 玩家如果已进入载具重复记录不进行报错 // 玩家如果已进入载具重复记录不进行报错
if p == player || p == nil { if p == player || p == nil {
// 载具成员记录玩家 // 载具成员记录玩家
entity.gadgetEntity.gadgetVehicleEntity.memberMap[i] = player gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()[i] = player
freePos = i freePos = i
} }
} }
// 记录玩家所在的载具信息 // 记录玩家所在的载具信息
player.VehicleInfo.InVehicleEntityId = entity.id player.VehicleInfo.InVehicleEntityId = entity.GetId()
// PacketVehicleInteractRsp // PacketVehicleInteractRsp
vehicleInteractRsp := &proto.VehicleInteractRsp{ vehicleInteractRsp := &proto.VehicleInteractRsp{
@@ -142,7 +145,7 @@ func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarG
AvatarGuid: avatarGuid, AvatarGuid: avatarGuid,
Pos: freePos, // 应该是多人坐船时的位置? Pos: freePos, // 应该是多人坐船时的位置?
}, },
EntityId: entity.id, EntityId: entity.GetId(),
} }
g.SendMsg(cmd.VehicleInteractRsp, player.PlayerID, player.ClientSeq, vehicleInteractRsp) g.SendMsg(cmd.VehicleInteractRsp, player.PlayerID, player.ClientSeq, vehicleInteractRsp)
} }
@@ -150,17 +153,19 @@ func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarG
// ExitVehicle 离开载具 // ExitVehicle 离开载具
func (g *GameManager) ExitVehicle(player *model.Player, entity *Entity, avatarGuid uint64) { func (g *GameManager) ExitVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
// 玩家是否进入载具 // 玩家是否进入载具
if !g.IsPlayerInVehicle(player, entity.gadgetEntity.gadgetVehicleEntity) { gadgetEntity := entity.GetGadgetEntity()
if !g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
logger.Error("vehicle not has player, uid: %v", player.PlayerID) logger.Error("vehicle not has player, uid: %v", player.PlayerID)
g.CommonRetError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_NOT_IN_VEHICLE) g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_NOT_IN_VEHICLE)
return return
} }
// 载具成员删除玩家 // 载具成员删除玩家
var memberPos uint32 var memberPos uint32
for pos, p := range entity.gadgetEntity.gadgetVehicleEntity.memberMap { memberMap := gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()
for pos, p := range memberMap {
if p == player { if p == player {
memberPos = pos memberPos = pos
delete(entity.gadgetEntity.gadgetVehicleEntity.memberMap, pos) delete(memberMap, pos)
} }
} }
// 清除记录的所在载具信息 // 清除记录的所在载具信息
@@ -174,7 +179,7 @@ func (g *GameManager) ExitVehicle(player *model.Player, entity *Entity, avatarGu
AvatarGuid: avatarGuid, AvatarGuid: avatarGuid,
Pos: memberPos, // 应该是多人坐船时的位置? Pos: memberPos, // 应该是多人坐船时的位置?
}, },
EntityId: entity.id, EntityId: entity.GetId(),
} }
g.SendMsg(cmd.VehicleInteractRsp, player.PlayerID, player.ClientSeq, vehicleInteractRsp) g.SendMsg(cmd.VehicleInteractRsp, player.PlayerID, player.ClientSeq, vehicleInteractRsp)
} }
@@ -190,13 +195,14 @@ func (g *GameManager) VehicleInteractReq(player *model.Player, payloadMsg pb.Mes
entity := scene.GetEntity(req.EntityId) entity := scene.GetEntity(req.EntityId)
if entity == nil { if entity == nil {
logger.Error("vehicle entity is nil, entityId: %v", req.EntityId) logger.Error("vehicle entity is nil, entityId: %v", req.EntityId)
g.CommonRetError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_ENTITY_NOT_EXIST) g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_ENTITY_NOT_EXIST)
return return
} }
// 判断实体类型是否为载具 // 判断实体类型是否为载具
if entity.gadgetEntity == nil || entity.gadgetEntity.gadgetVehicleEntity == nil { gadgetEntity := entity.GetGadgetEntity()
logger.Error("vehicle entity error, entityType: %v", entity.entityType) if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
g.CommonRetError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_GADGET_NOT_VEHICLE) logger.Error("vehicle entity error, entityType: %v", entity.GetEntityType())
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_GADGET_NOT_VEHICLE)
return return
} }

View File

@@ -119,34 +119,34 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
// 确保精炼的武器与精炼材料不是同一个 // 确保精炼的武器与精炼材料不是同一个
if req.TargetWeaponGuid == req.ItemGuid { if req.TargetWeaponGuid == req.ItemGuid {
logger.Error("weapon awaken guid equal, guid: %v", req.TargetWeaponGuid) logger.Error("weapon awaken guid equal, guid: %v", req.TargetWeaponGuid)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_INVALID_TARGET) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_INVALID_TARGET)
return return
} }
// 是否拥有武器 // 是否拥有武器
weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)] weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)]
if !ok { if !ok {
logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid) logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 获取武器物品配置表 // 获取武器物品配置表
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)] weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if !ok { if !ok {
logger.Error("weapon config error, itemId: %v", weapon.ItemId) logger.Error("weapon config error, itemId: %v", weapon.ItemId)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 摩拉数量是否足够 // 摩拉数量是否足够
if player.GetItemCount(constant.ItemConstantConst.SCOIN) < weaponConfig.AwakenCoinCostList[weapon.Refinement] { if player.GetItemCount(constant.ItemConstantConst.SCOIN) < weaponConfig.AwakenCoinCostList[weapon.Refinement] {
logger.Error("item count not enough, itemId: %v", constant.ItemConstantConst.SCOIN) logger.Error("item count not enough, itemId: %v", constant.ItemConstantConst.SCOIN)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
return return
} }
// 武器精炼等级是否不超过限制 // 武器精炼等级是否不超过限制
// 暂时精炼等级是写死的 应该最大精炼等级就是5级 // 暂时精炼等级是写死的 应该最大精炼等级就是5级
if weapon.Refinement >= 4 { if weapon.Refinement >= 4 {
logger.Error("weapon refinement ge 4, refinement: %v", weapon.Refinement) logger.Error("weapon refinement ge 4, refinement: %v", weapon.Refinement)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_AWAKEN_LEVEL_MAX) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_AWAKEN_LEVEL_MAX)
return return
} }
// 获取精炼材料物品配置表 // 获取精炼材料物品配置表
@@ -154,7 +154,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(player.GetItemIdByItemAndWeaponGuid(req.ItemGuid))] itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(player.GetItemIdByItemAndWeaponGuid(req.ItemGuid))]
if !ok { if !ok {
logger.Error("item data config error, itemGuid: %v", req.ItemGuid) logger.Error("item data config error, itemGuid: %v", req.ItemGuid)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 根据精炼材料的类型做不同操作 // 根据精炼材料的类型做不同操作
@@ -165,13 +165,13 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
foodWeapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.ItemGuid)] foodWeapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.ItemGuid)]
if !ok { if !ok {
logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid) logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 确保被精炼武器没有被任何角色装备 // 确保被精炼武器没有被任何角色装备
if foodWeapon.AvatarId != 0 { if foodWeapon.AvatarId != 0 {
logger.Error("food weapon has been wear, weaponGuid: %v", req.ItemGuid) logger.Error("food weapon has been wear, weaponGuid: %v", req.ItemGuid)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_EQUIP_HAS_BEEN_WEARED) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_EQUIP_HAS_BEEN_WEARED)
return return
} }
// 消耗作为精炼材料的武器 // 消耗作为精炼材料的武器
@@ -182,13 +182,13 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
item, ok := player.ItemMap[player.GetItemIdByGuid(req.ItemGuid)] item, ok := player.ItemMap[player.GetItemIdByGuid(req.ItemGuid)]
if !ok { if !ok {
logger.Error("item error, itemGuid: %v", req.ItemGuid) logger.Error("item error, itemGuid: %v", req.ItemGuid)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 武器的精炼材料是否为这个 // 武器的精炼材料是否为这个
if item.ItemId != uint32(weaponConfig.AwakenMaterial) { if item.ItemId != uint32(weaponConfig.AwakenMaterial) {
logger.Error("awaken material item error, itemId: %v", item.ItemId) logger.Error("awaken material item error, itemId: %v", item.ItemId)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_INVALID_TARGET) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_INVALID_TARGET)
return return
} }
// 消耗作为精炼材料的道具 // 消耗作为精炼材料的道具
@@ -200,7 +200,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
}) })
default: default:
logger.Error("weapon awaken item type error, itemType: %v", itemDataConfig.Type) logger.Error("weapon awaken item type error, itemType: %v", itemDataConfig.Type)
g.CommonRetError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}) g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{})
return return
} }
// 消耗摩拉 // 消耗摩拉
@@ -252,41 +252,41 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)] weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)]
if !ok { if !ok {
logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid) logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid)
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 获取武器配置表 // 获取武器配置表
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)] weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if !ok { if !ok {
logger.Error("weapon config error, itemId: %v", weapon.ItemId) logger.Error("weapon config error, itemId: %v", weapon.ItemId)
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{})
return return
} }
// 获取武器突破配置表 // 获取武器突破配置表
weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId] weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId]
if !ok { if !ok {
logger.Error("weapon promote config error, promoteId: %v", weaponConfig.PromoteId) logger.Error("weapon promote config error, promoteId: %v", weaponConfig.PromoteId)
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{})
return return
} }
// 获取武器突破等级的配置表 // 获取武器突破等级的配置表
weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)] weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)]
if !ok { if !ok {
logger.Error("weapon promote config error, promoteLevel: %v", weapon.Promote) logger.Error("weapon promote config error, promoteLevel: %v", weapon.Promote)
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{})
return return
} }
// 武器等级是否达到限制 // 武器等级是否达到限制
if weapon.Level < uint8(weaponPromoteConfig.LevelLimit) { if weapon.Level < uint8(weaponPromoteConfig.LevelLimit) {
logger.Error("weapon level le level limit, level: %v", weapon.Level) logger.Error("weapon level le level limit, level: %v", weapon.Level)
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_WEAPON_LEVEL_INVALID) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_WEAPON_LEVEL_INVALID)
return return
} }
// 获取武器突破下一级的配置表 // 获取武器突破下一级的配置表
weaponPromoteConfig, ok = weaponPromoteDataMap[int32(weapon.Promote+1)] weaponPromoteConfig, ok = weaponPromoteDataMap[int32(weapon.Promote+1)]
if !ok { if !ok {
logger.Error("weapon promote config error, next promoteLevel: %v", weapon.Promote+1) logger.Error("weapon promote config error, next promoteLevel: %v", weapon.Promote+1)
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_WEAPON_PROMOTE_LEVEL_EXCEED_LIMIT) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_WEAPON_PROMOTE_LEVEL_EXCEED_LIMIT)
return return
} }
// 将被消耗的物品列表 // 将被消耗的物品列表
@@ -309,16 +309,16 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
logger.Error("item count not enough, itemId: %v", item.ItemId) logger.Error("item count not enough, itemId: %v", item.ItemId)
// 摩拉的错误提示与材料不同 // 摩拉的错误提示与材料不同
if item.ItemId == constant.ItemConstantConst.SCOIN { if item.ItemId == constant.ItemConstantConst.SCOIN {
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
} }
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH)
return return
} }
} }
// 冒险等级是否符合要求 // 冒险等级是否符合要求
if player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] < uint32(weaponPromoteConfig.MinPlayerLevel) { if player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] < uint32(weaponPromoteConfig.MinPlayerLevel) {
logger.Error("player level not enough, level: %v", player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]) logger.Error("player level not enough, level: %v", player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL])
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_PLAYER_LEVEL_LESS_THAN) g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_PLAYER_LEVEL_LESS_THAN)
return return
} }
// 消耗突破材料和摩拉 // 消耗突破材料和摩拉
@@ -533,34 +533,34 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)] weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)]
if !ok { if !ok {
logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid) logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid)
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 获取武器配置表 // 获取武器配置表
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)] weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if !ok { if !ok {
logger.Error("weapon config error, itemId: %v", weapon.ItemId) logger.Error("weapon config error, itemId: %v", weapon.ItemId)
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
return return
} }
// 获取武器突破配置表 // 获取武器突破配置表
weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId] weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId]
if !ok { if !ok {
logger.Error("weapon promote config error, promoteId: %v", weaponConfig.PromoteId) logger.Error("weapon promote config error, promoteId: %v", weaponConfig.PromoteId)
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
return return
} }
// 获取武器突破等级对应的配置表 // 获取武器突破等级对应的配置表
weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)] weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)]
if !ok { if !ok {
logger.Error("weapon promote config error, promoteLevel: %v", weapon.Promote) logger.Error("weapon promote config error, promoteLevel: %v", weapon.Promote)
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
return return
} }
// 武器等级是否达到限制 // 武器等级是否达到限制
if weapon.Level >= uint8(weaponPromoteConfig.LevelLimit) { if weapon.Level >= uint8(weaponPromoteConfig.LevelLimit) {
logger.Error("weapon level ge level limit, level: %v", weapon.Level) logger.Error("weapon level ge level limit, level: %v", weapon.Level)
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_WEAPON_PROMOTE_LEVEL_EXCEED_LIMIT) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_WEAPON_PROMOTE_LEVEL_EXCEED_LIMIT)
return return
} }
// 将被消耗的物品列表 // 将被消耗的物品列表
@@ -576,7 +576,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
expCount, coinCost, success := g.CalcWeaponUpgradeExpAndCoin(player, req.ItemParamList, req.FoodWeaponGuidList) expCount, coinCost, success := g.CalcWeaponUpgradeExpAndCoin(player, req.ItemParamList, req.FoodWeaponGuidList)
if !success { if !success {
logger.Error("calc weapon upgrade exp and coin error, uid: %v", player.PlayerID) logger.Error("calc weapon upgrade exp and coin error, uid: %v", player.PlayerID)
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
return return
} }
// 消耗列表添加摩拉的消耗 // 消耗列表添加摩拉的消耗
@@ -590,9 +590,9 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
logger.Error("item count not enough, itemId: %v", item.ItemId) logger.Error("item count not enough, itemId: %v", item.ItemId)
// 摩拉的错误提示与材料不同 // 摩拉的错误提示与材料不同
if item.ItemId == constant.ItemConstantConst.SCOIN { if item.ItemId == constant.ItemConstantConst.SCOIN {
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
} }
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH)
return return
} }
} }
@@ -602,7 +602,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
foodWeapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(weaponGuid)] foodWeapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(weaponGuid)]
if !ok { if !ok {
logger.Error("food weapon error, weaponGuid: %v", weaponGuid) logger.Error("food weapon error, weaponGuid: %v", weaponGuid)
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
} }
costWeaponIdList = append(costWeaponIdList, foodWeapon.WeaponId) costWeaponIdList = append(costWeaponIdList, foodWeapon.WeaponId)
} }
@@ -617,7 +617,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
weaponLevel, weaponExp, returnItemList, success := g.CalcWeaponUpgrade(weapon, expCount) weaponLevel, weaponExp, returnItemList, success := g.CalcWeaponUpgrade(weapon, expCount)
if !success { if !success {
logger.Error("calc weapon upgrade error, uid: %v", player.PlayerID) logger.Error("calc weapon upgrade error, uid: %v", player.PlayerID)
g.CommonRetError(cmd.CalcWeaponUpgradeReturnItemsRsp, player, &proto.CalcWeaponUpgradeReturnItemsRsp{}) g.SendError(cmd.CalcWeaponUpgradeReturnItemsRsp, player, &proto.CalcWeaponUpgradeReturnItemsRsp{})
return return
} }
@@ -663,21 +663,21 @@ func (g *GameManager) CalcWeaponUpgradeReturnItemsReq(player *model.Player, payl
weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)] weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)]
if !ok { if !ok {
logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid) logger.Error("weapon error, weaponGuid: %v", req.TargetWeaponGuid)
g.CommonRetError(cmd.CalcWeaponUpgradeReturnItemsRsp, player, &proto.CalcWeaponUpgradeReturnItemsRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST) g.SendError(cmd.CalcWeaponUpgradeReturnItemsRsp, player, &proto.CalcWeaponUpgradeReturnItemsRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return return
} }
// 计算使用材料强化武器后将会获得的经验数 // 计算使用材料强化武器后将会获得的经验数
expCount, _, success := g.CalcWeaponUpgradeExpAndCoin(player, req.ItemParamList, req.FoodWeaponGuidList) expCount, _, success := g.CalcWeaponUpgradeExpAndCoin(player, req.ItemParamList, req.FoodWeaponGuidList)
if !success { if !success {
logger.Error("calc weapon upgrade exp and coin error, uid: %v", player.PlayerID) logger.Error("calc weapon upgrade exp and coin error, uid: %v", player.PlayerID)
g.CommonRetError(cmd.CalcWeaponUpgradeReturnItemsRsp, player, &proto.CalcWeaponUpgradeReturnItemsRsp{}) g.SendError(cmd.CalcWeaponUpgradeReturnItemsRsp, player, &proto.CalcWeaponUpgradeReturnItemsRsp{})
return return
} }
// 计算武器使用材料升级后的等级经验以及返回的矿石 // 计算武器使用材料升级后的等级经验以及返回的矿石
_, _, returnItemList, success := g.CalcWeaponUpgrade(weapon, expCount) _, _, returnItemList, success := g.CalcWeaponUpgrade(weapon, expCount)
if !success { if !success {
logger.Error("calc weapon upgrade error, weaponGuid: %v", req.TargetWeaponGuid) logger.Error("calc weapon upgrade error, weaponGuid: %v", req.TargetWeaponGuid)
g.CommonRetError(cmd.CalcWeaponUpgradeReturnItemsRsp, player, &proto.CalcWeaponUpgradeReturnItemsRsp{}) g.SendError(cmd.CalcWeaponUpgradeReturnItemsRsp, player, &proto.CalcWeaponUpgradeReturnItemsRsp{})
return return
} }

View File

@@ -44,6 +44,10 @@ func NewTickManager() (r *TickManager) {
return r return r
} }
func (t *TickManager) GetGlobalTick() *time.Ticker {
return t.globalTick
}
// 每个玩家自己的tick // 每个玩家自己的tick
// CreateUserGlobalTick 创建玩家tick对象 // CreateUserGlobalTick 创建玩家tick对象

View File

@@ -256,5 +256,5 @@ func (g *GameManager) VideoPlayerUpdate(rgb bool) {
} }
} }
} }
GAME_MANAGER.AddSceneEntityNotify(world.owner, proto.VisionType_VISION_BORN, SCREEN_ENTITY_ID_LIST, true, false) GAME_MANAGER.AddSceneEntityNotify(world.GetOwner(), proto.VisionType_VISION_BORN, SCREEN_ENTITY_ID_LIST, true, false)
} }

View File

@@ -213,6 +213,14 @@ func (w *WorldManager) IsBigWorld(world *World) bool {
return (world.id == w.aiWorld.id) && (w.aiWorld.owner.PlayerID == BigWorldAiUid) return (world.id == w.aiWorld.id) && (w.aiWorld.owner.PlayerID == BigWorldAiUid)
} }
func (w *WorldManager) GetSceneBlockAoiMap() map[uint32]*alg.AoiManager {
return w.sceneBlockAoiMap
}
func (w *WorldManager) GetMultiplayerWorldNum() uint32 {
return w.multiplayerWorldNum
}
// 世界数据结构 // 世界数据结构
type World struct { type World struct {
@@ -231,6 +239,14 @@ type World struct {
peerList []*model.Player // 玩家编号列表 peerList []*model.Player // 玩家编号列表
} }
func (w *World) GetId() uint32 {
return w.id
}
func (w *World) GetOwner() *model.Player {
return w.owner
}
func (w *World) GetAllPlayer() map[uint32]*model.Player { func (w *World) GetAllPlayer() map[uint32]*model.Player {
return w.playerMap return w.playerMap
} }
@@ -239,6 +255,18 @@ func (w *World) GetAllScene() map[uint32]*Scene {
return w.sceneMap return w.sceneMap
} }
func (w *World) GetWorldLevel() uint8 {
return w.worldLevel
}
func (w *World) GetMultiplayer() bool {
return w.multiplayer
}
func (w *World) GetMpLevelEntityId() uint32 {
return w.mpLevelEntityId
}
func (w *World) GetNextWorldEntityId(entityType uint16) uint32 { func (w *World) GetNextWorldEntityId(entityType uint16) uint32 {
for { for {
w.entityIdCounter++ w.entityIdCounter++
@@ -353,6 +381,42 @@ type WorldAvatar struct {
modifierList []*proto.AbilityAppliedModifier modifierList []*proto.AbilityAppliedModifier
} }
func (w *WorldAvatar) GetUid() uint32 {
return w.uid
}
func (w *WorldAvatar) GetAvatarId() uint32 {
return w.avatarId
}
func (w *WorldAvatar) GetAvatarEntityId() uint32 {
return w.avatarEntityId
}
func (w *WorldAvatar) GetWeaponEntityId() uint32 {
return w.weaponEntityId
}
func (w *WorldAvatar) SetWeaponEntityId(weaponEntityId uint32) {
w.weaponEntityId = weaponEntityId
}
func (w *WorldAvatar) GetAbilityList() []*proto.AbilityAppliedAbility {
return w.abilityList
}
func (w *WorldAvatar) SetAbilityList(abilityList []*proto.AbilityAppliedAbility) {
w.abilityList = abilityList
}
func (w *WorldAvatar) GetModifierList() []*proto.AbilityAppliedModifier {
return w.modifierList
}
func (w *WorldAvatar) SetModifierList(modifierList []*proto.AbilityAppliedModifier) {
w.modifierList = modifierList
}
// GetWorldAvatarList 获取世界队伍的全部角色列表 // GetWorldAvatarList 获取世界队伍的全部角色列表
func (w *World) GetWorldAvatarList() []*WorldAvatar { func (w *World) GetWorldAvatarList() []*WorldAvatar {
worldAvatarList := make([]*WorldAvatar, 0) worldAvatarList := make([]*WorldAvatar, 0)
@@ -643,8 +707,24 @@ func (w *World) IsPlayerFirstEnter(player *model.Player) bool {
} }
} }
func (w *World) PlayerEnter(player *model.Player) { func (w *World) PlayerEnter(uid uint32) {
w.playerFirstEnterMap[player.PlayerID] = time.Now().UnixMilli() w.playerFirstEnterMap[uid] = time.Now().UnixMilli()
}
func (w *World) AddWaitPlayer(uid uint32) {
w.waitEnterPlayerMap[uid] = time.Now().UnixMilli()
}
func (w *World) GetAllWaitPlayer() []uint32 {
uidList := make([]uint32, 0)
for uid := range w.waitEnterPlayerMap {
uidList = append(uidList, uid)
}
return uidList
}
func (w *World) RemoveWaitPlayer(uid uint32) {
delete(w.waitEnterPlayerMap, uid)
} }
func (w *World) CreateScene(sceneId uint32) *Scene { func (w *World) CreateScene(sceneId uint32) *Scene {
@@ -683,6 +763,14 @@ type Scene struct {
meeoIndex uint32 // 客户端风元素染色同步协议的计数器 meeoIndex uint32 // 客户端风元素染色同步协议的计数器
} }
func (s *Scene) GetId() uint32 {
return s.id
}
func (s *Scene) GetWorld() *World {
return s.world
}
func (s *Scene) GetAllPlayer() map[uint32]*model.Player { func (s *Scene) GetAllPlayer() map[uint32]*model.Player {
return s.playerMap return s.playerMap
} }
@@ -691,15 +779,39 @@ func (s *Scene) GetAllEntity() map[uint32]*Entity {
return s.entityMap return s.entityMap
} }
func (s *Scene) GetGameTime() uint32 {
return s.gameTime
}
func (s *Scene) GetMeeoIndex() uint32 {
return s.meeoIndex
}
func (s *Scene) SetMeeoIndex(meeoIndex uint32) {
s.meeoIndex = meeoIndex
}
type AvatarEntity struct { type AvatarEntity struct {
uid uint32 uid uint32
avatarId uint32 avatarId uint32
} }
func (a *AvatarEntity) GetUid() uint32 {
return a.uid
}
func (a *AvatarEntity) GetAvatarId() uint32 {
return a.avatarId
}
type MonsterEntity struct { type MonsterEntity struct {
monsterId uint32 monsterId uint32
} }
func (m *MonsterEntity) GetMonsterId() uint32 {
return m.monsterId
}
type NpcEntity struct { type NpcEntity struct {
NpcId uint32 NpcId uint32
RoomId uint32 RoomId uint32
@@ -723,10 +835,38 @@ type GadgetClientEntity struct {
propOwnerEntityId uint32 propOwnerEntityId uint32
} }
func (g *GadgetClientEntity) GetConfigId() uint32 {
return g.configId
}
func (g *GadgetClientEntity) GetCampId() uint32 {
return g.campId
}
func (g *GadgetClientEntity) GetCampType() uint32 {
return g.campType
}
func (g *GadgetClientEntity) GetOwnerEntityId() uint32 {
return g.ownerEntityId
}
func (g *GadgetClientEntity) GetTargetEntityId() uint32 {
return g.targetEntityId
}
func (g *GadgetClientEntity) GetPropOwnerEntityId() uint32 {
return g.propOwnerEntityId
}
type GadgetGatherEntity struct { type GadgetGatherEntity struct {
gatherId uint32 gatherId uint32
} }
func (g *GadgetGatherEntity) GetGatherId() uint32 {
return g.gatherId
}
type GadgetVehicleEntity struct { type GadgetVehicleEntity struct {
vehicleId uint32 vehicleId uint32
owner *model.Player owner *model.Player
@@ -735,6 +875,30 @@ type GadgetVehicleEntity struct {
memberMap map[uint32]*model.Player // uint32 = pos memberMap map[uint32]*model.Player // uint32 = pos
} }
func (g *GadgetVehicleEntity) GetVehicleId() uint32 {
return g.vehicleId
}
func (g *GadgetVehicleEntity) GetOwner() *model.Player {
return g.owner
}
func (g *GadgetVehicleEntity) GetMaxStamina() float32 {
return g.maxStamina
}
func (g *GadgetVehicleEntity) GetCurStamina() float32 {
return g.curStamina
}
func (g *GadgetVehicleEntity) SetCurStamina(curStamina float32) {
g.curStamina = curStamina
}
func (g *GadgetVehicleEntity) GetMemberMap() map[uint32]*model.Player {
return g.memberMap
}
type GadgetEntity struct { type GadgetEntity struct {
gadgetType int gadgetType int
gadgetId uint32 gadgetId uint32
@@ -743,6 +907,26 @@ type GadgetEntity struct {
gadgetVehicleEntity *GadgetVehicleEntity gadgetVehicleEntity *GadgetVehicleEntity
} }
func (g *GadgetEntity) GetGadgetType() int {
return g.gadgetType
}
func (g *GadgetEntity) GetGadgetId() uint32 {
return g.gadgetId
}
func (g *GadgetEntity) GetGadgetClientEntity() *GadgetClientEntity {
return g.gadgetClientEntity
}
func (g *GadgetEntity) GetGadgetGatherEntity() *GadgetGatherEntity {
return g.gadgetGatherEntity
}
func (g *GadgetEntity) GetGadgetVehicleEntity() *GadgetVehicleEntity {
return g.gadgetVehicleEntity
}
// 场景实体数据结构 // 场景实体数据结构
type Entity struct { type Entity struct {
@@ -765,6 +949,78 @@ type Entity struct {
objectId int64 objectId int64
} }
func (e *Entity) GetId() uint32 {
return e.id
}
func (e *Entity) GetLifeState() uint16 {
return e.lifeState
}
func (e *Entity) GetPos() *model.Vector {
return e.pos
}
func (e *Entity) GetRot() *model.Vector {
return e.rot
}
func (e *Entity) GetMoveState() uint16 {
return e.moveState
}
func (e *Entity) SetMoveState(moveState uint16) {
e.moveState = moveState
}
func (e *Entity) GetLastMoveSceneTimeMs() uint32 {
return e.lastMoveSceneTimeMs
}
func (e *Entity) SetLastMoveSceneTimeMs(lastMoveSceneTimeMs uint32) {
e.lastMoveSceneTimeMs = lastMoveSceneTimeMs
}
func (e *Entity) GetLastMoveReliableSeq() uint32 {
return e.lastMoveReliableSeq
}
func (e *Entity) SetLastMoveReliableSeq(lastMoveReliableSeq uint32) {
e.lastMoveReliableSeq = lastMoveReliableSeq
}
func (e *Entity) GetFightProp() map[uint32]float32 {
return e.fightProp
}
func (e *Entity) GetEntityType() uint32 {
return e.entityType
}
func (e *Entity) GetLevel() uint8 {
return e.level
}
func (e *Entity) GetAvatarEntity() *AvatarEntity {
return e.avatarEntity
}
func (e *Entity) GetMonsterEntity() *MonsterEntity {
return e.monsterEntity
}
func (e *Entity) GetNpcEntity() *NpcEntity {
return e.npcEntity
}
func (e *Entity) GetGadgetEntity() *GadgetEntity {
return e.gadgetEntity
}
func (e *Entity) GetConfigId() uint32 {
return e.configId
}
type Attack struct { type Attack struct {
combatInvokeEntry *proto.CombatInvokeEntry combatInvokeEntry *proto.CombatInvokeEntry
uid uint32 uid uint32
@@ -913,7 +1169,6 @@ func (s *Scene) CreateEntityWeapon() uint32 {
lastMoveReliableSeq: 0, lastMoveReliableSeq: 0,
fightProp: nil, fightProp: nil,
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_WEAPON), entityType: uint32(proto.ProtEntityType_PROT_ENTITY_WEAPON),
level: 0,
} }
s.CreateEntity(entity, 0) s.CreateEntity(entity, 0)
return entity.id return entity.id
@@ -977,7 +1232,6 @@ func (s *Scene) CreateEntityNpc(pos, rot *model.Vector, npcId, roomId, parentQue
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1), uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
}, },
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_NPC), entityType: uint32(proto.ProtEntityType_PROT_ENTITY_NPC),
level: 0,
npcEntity: &NpcEntity{ npcEntity: &NpcEntity{
NpcId: npcId, NpcId: npcId,
RoomId: roomId, RoomId: roomId,
@@ -1012,7 +1266,6 @@ func (s *Scene) CreateEntityGadgetNormal(pos, rot *model.Vector, gadgetId uint32
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1), uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
}, },
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET), entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
level: 0,
gadgetEntity: &GadgetEntity{ gadgetEntity: &GadgetEntity{
gadgetId: gadgetId, gadgetId: gadgetId,
gadgetType: GADGET_TYPE_NORMAL, gadgetType: GADGET_TYPE_NORMAL,
@@ -1045,7 +1298,6 @@ func (s *Scene) CreateEntityGadgetGather(pos, rot *model.Vector, gadgetId uint32
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1), uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
}, },
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET), entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
level: 0,
gadgetEntity: &GadgetEntity{ gadgetEntity: &GadgetEntity{
gadgetId: gadgetId, gadgetId: gadgetId,
gadgetType: GADGET_TYPE_GATHER, gadgetType: GADGET_TYPE_GATHER,
@@ -1076,7 +1328,6 @@ func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId uint32
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1), uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
}, },
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET), entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
level: 0,
gadgetEntity: &GadgetEntity{ gadgetEntity: &GadgetEntity{
gadgetType: GADGET_TYPE_CLIENT, gadgetType: GADGET_TYPE_CLIENT,
gadgetClientEntity: &GadgetClientEntity{ gadgetClientEntity: &GadgetClientEntity{
@@ -1115,7 +1366,6 @@ func (s *Scene) CreateEntityGadgetVehicle(uid uint32, pos, rot *model.Vector, ve
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1), uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
}, },
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET), entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
level: 0,
gadgetEntity: &GadgetEntity{ gadgetEntity: &GadgetEntity{
gadgetType: GADGET_TYPE_VEHICLE, gadgetType: GADGET_TYPE_VEHICLE,
gadgetVehicleEntity: &GadgetVehicleEntity{ gadgetVehicleEntity: &GadgetVehicleEntity{

View File

@@ -78,8 +78,8 @@ func (a *AoiManager) AoiInfoLog(debug bool) {
minGridObjectCount = gridObjectCount minGridObjectCount = gridObjectCount
} }
if debug { if debug {
logger.Debug("Grid: gid: %d, minX: %d, maxX: %d, minY: %d, maxY: %d, minZ: %d, maxZ: %d, object count: %v", // logger.Debug("Grid: gid: %d, minX: %d, maxX: %d, minY: %d, maxY: %d, minZ: %d, maxZ: %d, object count: %v",
grid.gid, grid.minX, grid.maxX, grid.minY, grid.maxY, grid.minZ, grid.maxZ, gridObjectCount) // grid.gid, grid.minX, grid.maxX, grid.minY, grid.maxY, grid.minZ, grid.maxZ, gridObjectCount)
for objectId, object := range grid.objectMap { for objectId, object := range grid.objectMap {
logger.Debug("objectId: %v, object: %v", objectId, object) logger.Debug("objectId: %v, object: %v", objectId, object)
} }

View File

@@ -8,12 +8,13 @@ import (
type Grid struct { type Grid struct {
gid uint32 // 格子id gid uint32 // 格子id
// 格子边界坐标 // 格子边界坐标
minX int16 // 目前开发阶段暂时用不到 节省点内存
maxX int16 // minX int16
minY int16 // maxX int16
maxY int16 // minY int16
minZ int16 // maxY int16
maxZ int16 // minZ int16
// maxZ int16
objectMap map[int64]any // k:objectId v:对象 objectMap map[int64]any // k:objectId v:对象
} }
@@ -21,12 +22,12 @@ type Grid struct {
func NewGrid(gid uint32, minX, maxX, minY, maxY, minZ, maxZ int16) (r *Grid) { func NewGrid(gid uint32, minX, maxX, minY, maxY, minZ, maxZ int16) (r *Grid) {
r = new(Grid) r = new(Grid)
r.gid = gid r.gid = gid
r.minX = minX // r.minX = minX
r.maxX = maxX // r.maxX = maxX
r.minY = minY // r.minY = minY
r.maxY = maxY // r.maxY = maxY
r.minZ = minZ // r.minZ = minZ
r.maxZ = maxZ // r.maxZ = maxZ
r.objectMap = make(map[int64]any) r.objectMap = make(map[int64]any)
return r return r
} }