mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
整理代码,私有变量接口化访问
This commit is contained in:
@@ -50,6 +50,10 @@ func NewCommandManager() *CommandManager {
|
||||
return r
|
||||
}
|
||||
|
||||
func (c *CommandManager) GetCommandTextInput() chan *CommandMessage {
|
||||
return c.commandTextInput
|
||||
}
|
||||
|
||||
// SetSystem 设置GM指令聊天消息机器人
|
||||
func (c *CommandManager) SetSystem(system *model.Player) {
|
||||
c.system = system
|
||||
|
||||
@@ -219,19 +219,19 @@ func (g *GameManager) gameMainLoop() {
|
||||
ROUTE_MANAGER.RouteHandle(netMsg)
|
||||
end := time.Now().UnixNano()
|
||||
routeCost += end - start
|
||||
case <-TICK_MANAGER.globalTick.C:
|
||||
case <-TICK_MANAGER.GetGlobalTick().C:
|
||||
// 游戏服务器定时帧
|
||||
start := time.Now().UnixNano()
|
||||
TICK_MANAGER.OnGameServerTick()
|
||||
end := time.Now().UnixNano()
|
||||
tickCost += end - start
|
||||
case localEvent := <-LOCAL_EVENT_MANAGER.localEventChan:
|
||||
case localEvent := <-LOCAL_EVENT_MANAGER.GetLocalEventChan():
|
||||
// 处理本地事件
|
||||
start := time.Now().UnixNano()
|
||||
LOCAL_EVENT_MANAGER.LocalEventHandle(localEvent)
|
||||
end := time.Now().UnixNano()
|
||||
localEventCost += end - start
|
||||
case command := <-COMMAND_MANAGER.commandTextInput:
|
||||
case command := <-COMMAND_MANAGER.GetCommandTextInput():
|
||||
// 处理传入的命令(普通玩家 GM命令)
|
||||
start := time.Now().UnixNano()
|
||||
COMMAND_MANAGER.HandleCommand(command)
|
||||
@@ -252,7 +252,7 @@ func (g *GameManager) Close() {
|
||||
saveUserIdList = append(saveUserIdList, userId)
|
||||
}
|
||||
EXIT_SAVE_FIN_CHAN = make(chan bool)
|
||||
LOCAL_EVENT_MANAGER.localEventChan <- &LocalEvent{
|
||||
LOCAL_EVENT_MANAGER.GetLocalEventChan() <- &LocalEvent{
|
||||
EventId: ExitRunUserCopyAndSave,
|
||||
Msg: saveUserIdList,
|
||||
}
|
||||
@@ -319,8 +319,8 @@ func (g *GameManager) SendMsg(cmdId uint16, userId uint32, clientSeq uint32, pay
|
||||
})
|
||||
}
|
||||
|
||||
// CommonRetError 通用返回错误码
|
||||
func (g *GameManager) CommonRetError(cmdId uint16, player *model.Player, rsp pb.Message, retCode ...proto.Retcode) {
|
||||
// SendError 通用返回错误码
|
||||
func (g *GameManager) SendError(cmdId uint16, player *model.Player, rsp pb.Message, retCode ...proto.Retcode) {
|
||||
if rsp == nil {
|
||||
return
|
||||
}
|
||||
@@ -340,8 +340,8 @@ func (g *GameManager) CommonRetError(cmdId uint16, player *model.Player, rsp pb.
|
||||
g.SendMsg(cmdId, player.PlayerID, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
// CommonRetSucc 通用返回成功
|
||||
func (g *GameManager) CommonRetSucc(cmdId uint16, player *model.Player, rsp pb.Message) {
|
||||
// SendSucc 通用返回成功
|
||||
func (g *GameManager) SendSucc(cmdId uint16, player *model.Player, rsp pb.Message) {
|
||||
if rsp == nil {
|
||||
return
|
||||
}
|
||||
@@ -371,7 +371,7 @@ func (g *GameManager) SendToWorldAEC(world *World, cmdId uint16, seq uint32, msg
|
||||
|
||||
// SendToWorldH 给世界房主发消息
|
||||
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) {
|
||||
|
||||
@@ -39,6 +39,10 @@ func NewLocalEventManager() (r *LocalEventManager) {
|
||||
return r
|
||||
}
|
||||
|
||||
func (l *LocalEventManager) GetLocalEventChan() chan *LocalEvent {
|
||||
return l.localEventChan
|
||||
}
|
||||
|
||||
type PlayerLastSaveTimeSortList []*model.Player
|
||||
|
||||
func (p PlayerLastSaveTimeSortList) Len() int {
|
||||
|
||||
@@ -76,27 +76,27 @@ func (g *GameManager) AvatarPromoteGetRewardReq(player *model.Player, payloadMsg
|
||||
avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.AvatarGuid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取角色配置表
|
||||
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
|
||||
if !ok {
|
||||
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
|
||||
g.CommonRetError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{})
|
||||
g.SendError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{})
|
||||
return
|
||||
}
|
||||
// 角色是否获取过该突破等级的奖励
|
||||
if avatar.PromoteRewardMap[req.PromoteLevel] {
|
||||
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
|
||||
}
|
||||
// 获取奖励配置表
|
||||
rewardConfig, ok := gdconf.CONF.RewardDataMap[int32(avatarDataConfig.PromoteRewardMap[req.PromoteLevel])]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 设置该奖励为已被获取状态
|
||||
@@ -127,41 +127,41 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
|
||||
avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.Guid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取角色配置表
|
||||
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
|
||||
if !ok {
|
||||
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
|
||||
g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{})
|
||||
g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{})
|
||||
return
|
||||
}
|
||||
// 获取角色突破配置表
|
||||
avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取角色突破等级的配置表
|
||||
avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 角色等级是否达到限制
|
||||
if avatar.Level < uint8(avatarPromoteConfig.LevelLimit) {
|
||||
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
|
||||
}
|
||||
// 获取角色突破下一级的配置表
|
||||
avatarPromoteConfig, ok = avatarPromoteDataMap[int32(avatar.Promote+1)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 将被消耗的物品列表
|
||||
@@ -184,16 +184,16 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
|
||||
logger.Error("item count not enough, itemId: %v", item.ItemId)
|
||||
// 摩拉的错误提示与材料不同
|
||||
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
|
||||
}
|
||||
}
|
||||
// 冒险等级是否符合要求
|
||||
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])
|
||||
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
|
||||
}
|
||||
// 消耗突破材料和摩拉
|
||||
@@ -220,27 +220,27 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
||||
avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.AvatarGuid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 经验书数量是否足够
|
||||
if player.GetItemCount(req.ItemId) < req.Count {
|
||||
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
|
||||
}
|
||||
// 获取经验书物品配置表
|
||||
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(req.ItemId)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 经验书将给予的经验数
|
||||
itemParam, err := strconv.Atoi(itemDataConfig.Use1Param1)
|
||||
if err != nil {
|
||||
logger.Error("parse item param error: %v", err)
|
||||
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
|
||||
g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
|
||||
return
|
||||
}
|
||||
// 角色获得的经验
|
||||
@@ -248,34 +248,34 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
||||
// 摩拉数量是否足够
|
||||
if player.GetItemCount(constant.ItemConstantConst.SCOIN) < expCount/5 {
|
||||
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
|
||||
}
|
||||
// 获取角色配置表
|
||||
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
|
||||
if !ok {
|
||||
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
|
||||
g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
|
||||
g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
|
||||
return
|
||||
}
|
||||
// 获取角色突破配置表
|
||||
avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取角色突破等级对应的配置表
|
||||
avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 角色等级是否达到限制
|
||||
if avatar.Level >= uint8(avatarPromoteConfig.LevelLimit) {
|
||||
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
|
||||
}
|
||||
// 消耗升级材料以及摩拉
|
||||
@@ -387,13 +387,13 @@ func (g *GameManager) WearEquipReq(player *model.Player, payloadMsg pb.Message)
|
||||
avatar, ok := player.GameObjectGuidMap[avatarGuid].(*model.Avatar)
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
weapon, ok := player.GameObjectGuidMap[equipGuid].(*model.Weapon)
|
||||
if !ok {
|
||||
logger.Error("equip error, equipGuid: %v", equipGuid)
|
||||
g.CommonRetError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{})
|
||||
g.SendError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{})
|
||||
return
|
||||
}
|
||||
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)
|
||||
if weakWorldAvatar != nil {
|
||||
weakWorldAvatar.weaponEntityId = scene.CreateEntityWeapon()
|
||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, weakWorldAvatar.weaponEntityId)
|
||||
weakWorldAvatar.SetWeaponEntityId(scene.CreateEntityWeapon())
|
||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, weakWorldAvatar.GetWeaponEntityId())
|
||||
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
||||
} else {
|
||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, 0)
|
||||
@@ -451,8 +451,8 @@ func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weapon
|
||||
|
||||
worldAvatar := world.GetPlayerWorldAvatar(player, avatarId)
|
||||
if worldAvatar != nil {
|
||||
worldAvatar.weaponEntityId = scene.CreateEntityWeapon()
|
||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, worldAvatar.weaponEntityId)
|
||||
worldAvatar.SetWeaponEntityId(scene.CreateEntityWeapon())
|
||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, worldAvatar.GetWeaponEntityId())
|
||||
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
||||
} else {
|
||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, 0)
|
||||
@@ -487,7 +487,7 @@ func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb
|
||||
|
||||
avatarChangeCostumeNotify := new(proto.AvatarChangeCostumeNotify)
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
|
||||
AvatarGuid: avatarGuid,
|
||||
FlycloakId: flycloakId,
|
||||
}
|
||||
for _, scenePlayer := range scene.playerMap {
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
g.SendMsg(cmd.AvatarFlycloakChangeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarFlycloakChangeNotify)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func (g *GameManager) PullRecentChatReq(player *model.Player, payloadMsg pb.Mess
|
||||
}
|
||||
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
if world.multiplayer {
|
||||
if world.GetMultiplayer() {
|
||||
chatList := world.GetChatList()
|
||||
count := len(chatList)
|
||||
if count > 10 {
|
||||
@@ -239,7 +239,7 @@ func (g *GameManager) PlayerChatReq(player *model.Player, payloadMsg pb.Message)
|
||||
ChannelId: channelId,
|
||||
ChatInfo: sendChatInfo,
|
||||
}
|
||||
for _, worldPlayer := range world.playerMap {
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
g.SendMsg(cmd.PlayerChatNotify, worldPlayer.PlayerID, player.ClientSeq, playerChatNotify)
|
||||
}
|
||||
|
||||
|
||||
@@ -157,12 +157,12 @@ func (g *GameManager) ServerAppidBindNotify(userId uint32, fightAppId string, jo
|
||||
MsgType: mq.MsgTypeFight,
|
||||
EventId: mq.AddFightRoutine,
|
||||
FightMsg: &mq.FightMsg{
|
||||
FightRoutineId: world.id,
|
||||
FightRoutineId: world.GetId(),
|
||||
GateServerAppId: player.GateAppId,
|
||||
},
|
||||
})
|
||||
world.AddPlayer(player, player.SceneId)
|
||||
player.WorldId = world.id
|
||||
player.WorldId = world.GetId()
|
||||
// 进入场景
|
||||
player.SceneJump = true
|
||||
player.SceneLoadState = model.SceneNone
|
||||
|
||||
@@ -29,7 +29,7 @@ func DoForward[IET model.InvokeEntryType](player *model.Player, req pb.Message,
|
||||
for _, fieldName := range copyFieldList {
|
||||
reflection.CopyStructField(ntf, req, fieldName)
|
||||
}
|
||||
for _, v := range world.playerMap {
|
||||
for _, v := range world.GetAllPlayer() {
|
||||
GAME_MANAGER.SendMsg(cmdId, v.PlayerID, player.ClientSeq, ntf)
|
||||
}
|
||||
}
|
||||
@@ -84,8 +84,8 @@ func (g *GameManager) MassiveEntityElementOpBatchNotify(player *model.Player, pa
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
ntf.OpIdx = scene.meeoIndex
|
||||
scene.meeoIndex++
|
||||
ntf.OpIdx = scene.GetMeeoIndex()
|
||||
scene.SetMeeoIndex(scene.GetMeeoIndex() + 1)
|
||||
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
|
||||
currHp := float32(0)
|
||||
if target.fightProp != nil {
|
||||
currHp = target.fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)]
|
||||
fightProp := target.GetFightProp()
|
||||
if fightProp != nil {
|
||||
currHp = fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)]
|
||||
currHp -= damage
|
||||
if 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{
|
||||
FightPropMap: target.fightProp,
|
||||
EntityId: target.id,
|
||||
FightPropMap: fightProp,
|
||||
EntityId: target.GetId(),
|
||||
}
|
||||
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)
|
||||
}
|
||||
combatData, err := pb.Marshal(hitInfo)
|
||||
@@ -186,7 +187,7 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
|
||||
if sceneEntity == nil {
|
||||
continue
|
||||
}
|
||||
if sceneEntity.avatarEntity != nil {
|
||||
if sceneEntity.GetAvatarEntity() != nil {
|
||||
// 玩家实体在移动
|
||||
g.AoiPlayerMove(player, player.Pos, &model.Vector{
|
||||
X: float64(motionInfo.Pos.X),
|
||||
@@ -206,23 +207,26 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
|
||||
} else {
|
||||
// 非玩家实体在移动
|
||||
// 更新场景实体的位置信息
|
||||
sceneEntity.pos.X = float64(motionInfo.Pos.X)
|
||||
sceneEntity.pos.Y = float64(motionInfo.Pos.Y)
|
||||
sceneEntity.pos.Z = float64(motionInfo.Pos.Z)
|
||||
sceneEntity.rot.X = float64(motionInfo.Rot.X)
|
||||
sceneEntity.rot.Y = float64(motionInfo.Rot.Y)
|
||||
sceneEntity.rot.Z = float64(motionInfo.Rot.Z)
|
||||
pos := sceneEntity.GetPos()
|
||||
pos.X = float64(motionInfo.Pos.X)
|
||||
pos.Y = float64(motionInfo.Pos.Y)
|
||||
pos.Z = float64(motionInfo.Pos.Z)
|
||||
rot := sceneEntity.GetRot()
|
||||
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.VehicleDestroyMotion(player, sceneEntity, motionInfo.State)
|
||||
}
|
||||
}
|
||||
sceneEntity.moveState = uint16(motionInfo.State)
|
||||
sceneEntity.lastMoveSceneTimeMs = entityMoveInfo.SceneTime
|
||||
sceneEntity.lastMoveReliableSeq = entityMoveInfo.ReliableSeq
|
||||
sceneEntity.SetMoveState(uint16(motionInfo.State))
|
||||
sceneEntity.SetLastMoveSceneTimeMs(entityMoveInfo.SceneTime)
|
||||
sceneEntity.SetLastMoveReliableSeq(entityMoveInfo.ReliableSeq)
|
||||
|
||||
player.CombatInvokeHandler.AddEntry(entry.ForwardType, entry)
|
||||
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) {
|
||||
aoiManager, exist := WORLD_MANAGER.sceneBlockAoiMap[player.SceneId]
|
||||
sceneBlockAoiMap := WORLD_MANAGER.GetSceneBlockAoiMap()
|
||||
aoiManager, exist := sceneBlockAoiMap[player.SceneId]
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
if exist {
|
||||
@@ -287,8 +292,8 @@ func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector,
|
||||
if entity == nil {
|
||||
continue
|
||||
}
|
||||
scene.DestroyEntity(entity.id)
|
||||
delEntityIdList = append(delEntityIdList, entity.id)
|
||||
scene.DestroyEntity(entity.GetId())
|
||||
delEntityIdList = append(delEntityIdList, entity.GetId())
|
||||
}
|
||||
addEntityIdList := make([]uint32, 0)
|
||||
for newObjectId, newObject := range newObjectMap {
|
||||
@@ -411,7 +416,9 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
|
||||
if abilityMetaAddAbility.Ability == nil {
|
||||
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:
|
||||
abilityMetaModifierChange := new(proto.AbilityMetaModifierChange)
|
||||
if config.CONF.Hk4e.ClientProtoProxyEnable {
|
||||
@@ -451,7 +458,9 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
|
||||
if worldAvatar == nil {
|
||||
continue
|
||||
}
|
||||
worldAvatar.modifierList = append(worldAvatar.modifierList, abilityAppliedModifier)
|
||||
modifierList := worldAvatar.GetModifierList()
|
||||
modifierList = append(modifierList, abilityAppliedModifier)
|
||||
worldAvatar.SetModifierList(modifierList)
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ func (g *GameManager) GCGAskDuelReq(player *model.Player, payloadMsg pb.Message)
|
||||
// 获取玩家所在的游戏
|
||||
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
|
||||
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
|
||||
}
|
||||
// 获取玩家的操控者对象
|
||||
gameController := game.GetControllerByUserId(player.PlayerID)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -265,13 +265,13 @@ func (g *GameManager) GCGInitFinishReq(player *model.Player, payloadMsg pb.Messa
|
||||
// 获取玩家所在的游戏
|
||||
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
|
||||
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
|
||||
}
|
||||
// 获取玩家的操控者对象
|
||||
gameController := game.GetControllerByUserId(player.PlayerID)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -291,13 +291,13 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
|
||||
// 获取玩家所在的游戏
|
||||
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
|
||||
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
|
||||
}
|
||||
// 获取玩家的操控者对象
|
||||
gameController := game.GetControllerByUserId(player.PlayerID)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
|
||||
// 操作者是否拥有该卡牌
|
||||
cardInfo := gameController.GetCharCardByGuid(op.CardGuid)
|
||||
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
|
||||
}
|
||||
// 操控者选择角色牌
|
||||
@@ -318,13 +318,13 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
|
||||
op := req.Op.GetOpReroll()
|
||||
diceSideList, ok := game.roundInfo.diceSideMap[gameController.controllerId]
|
||||
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
|
||||
}
|
||||
// 判断骰子索引是否有效
|
||||
for _, diceIndex := range op.DiceIndexList {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -335,13 +335,13 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
|
||||
op := req.Op.GetOpAttack()
|
||||
diceSideList, ok := game.roundInfo.diceSideMap[gameController.controllerId]
|
||||
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
|
||||
}
|
||||
// 判断骰子索引是否有效
|
||||
for _, diceIndex := range op.CostDiceIndexList {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M
|
||||
|
||||
scenePointConfig, exist := gdconf.CONF.ScenePointMap[int32(req.SceneId)]
|
||||
if !exist {
|
||||
g.CommonRetError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
|
||||
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
|
||||
return
|
||||
}
|
||||
pointConfig, exist := scenePointConfig.PointMap[int32(req.PointId)]
|
||||
if !exist {
|
||||
g.CommonRetError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
|
||||
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ func (g *GameManager) JoinOtherWorld(player *model.Player, hostPlayer *model.Pla
|
||||
playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_OTHER)
|
||||
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerID, player.ClientSeq, playerEnterSceneNotify)
|
||||
} 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)
|
||||
ok := true
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
for _, worldPlayer := range world.playerMap {
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
if worldPlayer.SceneLoadState != model.SceneEnterDone {
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
g.CommonRetSucc(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{})
|
||||
g.SendSucc(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{})
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
}
|
||||
g.CommonRetSucc(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{})
|
||||
g.SendSucc(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{})
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
}
|
||||
g.CommonRetSucc(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{})
|
||||
g.SendSucc(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{})
|
||||
}
|
||||
|
||||
func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Message) {
|
||||
logger.Debug("user kick player, uid: %v", player.PlayerID)
|
||||
req := payloadMsg.(*proto.SceneKickPlayerReq)
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
if player.PlayerID != world.owner.PlayerID {
|
||||
g.CommonRetError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{})
|
||||
if player.PlayerID != world.GetOwner().PlayerID {
|
||||
g.SendError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{})
|
||||
return
|
||||
}
|
||||
targetUid := req.TargetUid
|
||||
@@ -156,7 +156,7 @@ func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Mes
|
||||
}
|
||||
ok := g.UserLeaveWorld(targetPlayer)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Mes
|
||||
TargetUid: targetUid,
|
||||
KickerUid: player.PlayerID,
|
||||
}
|
||||
for _, worldPlayer := range world.playerMap {
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
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)
|
||||
}
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
if world.multiplayer {
|
||||
if world.GetMultiplayer() {
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP)
|
||||
return
|
||||
}
|
||||
@@ -224,13 +224,13 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
|
||||
})
|
||||
return
|
||||
}
|
||||
if WORLD_MANAGER.multiplayerWorldNum >= MAX_MULTIPLAYER_WORLD_NUM {
|
||||
if WORLD_MANAGER.GetMultiplayerWorldNum() >= MAX_MULTIPLAYER_WORLD_NUM {
|
||||
// 超过本服务器最大多人世界数量限制
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_MAX_PLAYER)
|
||||
return
|
||||
}
|
||||
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)
|
||||
return
|
||||
@@ -295,7 +295,7 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
|
||||
}
|
||||
|
||||
otherPlayerWorld := WORLD_MANAGER.GetWorldByID(otherPlayer.WorldId)
|
||||
if otherPlayerWorld.multiplayer {
|
||||
if otherPlayerWorld.GetMultiplayer() {
|
||||
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
|
||||
TargetUid: hostPlayer.PlayerID,
|
||||
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) {
|
||||
world := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
|
||||
if world.multiplayer {
|
||||
if world.GetMultiplayer() {
|
||||
return
|
||||
}
|
||||
world.ChangeToMultiplayer()
|
||||
@@ -328,8 +328,8 @@ func (g *GameManager) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32
|
||||
// 是否多人游戏
|
||||
worldDataNotify.WorldPropMap[2] = &proto.PropValue{
|
||||
Type: 2,
|
||||
Val: object.ConvBoolToInt64(world.multiplayer),
|
||||
Value: &proto.PropValue_Ival{Ival: object.ConvBoolToInt64(world.multiplayer)},
|
||||
Val: object.ConvBoolToInt64(world.GetMultiplayer()),
|
||||
Value: &proto.PropValue_Ival{Ival: object.ConvBoolToInt64(world.GetMultiplayer())},
|
||||
}
|
||||
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 {
|
||||
oldWorld := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
if !oldWorld.multiplayer {
|
||||
if !oldWorld.GetMultiplayer() {
|
||||
return false
|
||||
}
|
||||
for _, worldPlayer := range oldWorld.playerMap {
|
||||
for _, worldPlayer := range oldWorld.GetAllPlayer() {
|
||||
if worldPlayer.SceneLoadState != model.SceneEnterDone {
|
||||
return false
|
||||
}
|
||||
@@ -376,22 +376,22 @@ func (g *GameManager) UserWorldAddPlayer(world *World, player *model.Player) {
|
||||
if !WORLD_MANAGER.IsBigWorld(world) && world.GetWorldPlayerNum() >= 4 {
|
||||
return
|
||||
}
|
||||
_, exist := world.playerMap[player.PlayerID]
|
||||
_, exist := world.GetAllPlayer()[player.PlayerID]
|
||||
if exist {
|
||||
return
|
||||
}
|
||||
world.AddPlayer(player, player.SceneId)
|
||||
player.WorldId = world.id
|
||||
player.WorldId = world.GetId()
|
||||
if world.GetWorldPlayerNum() > 1 {
|
||||
g.UpdateWorldPlayerInfo(world, 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 {
|
||||
if worldPlayer.PlayerID == world.owner.PlayerID {
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
if worldPlayer.PlayerID == world.GetOwner().PlayerID {
|
||||
continue
|
||||
}
|
||||
if ok := g.UserLeaveWorld(worldPlayer); !ok {
|
||||
@@ -408,7 +408,7 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
|
||||
delTeamEntityNotify := g.PacketDelTeamEntityNotify(scene, player)
|
||||
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify)
|
||||
|
||||
if world.multiplayer {
|
||||
if world.GetMultiplayer() {
|
||||
playerQuitFromMpNotify := &proto.PlayerQuitFromMpNotify{
|
||||
Reason: proto.PlayerQuitFromMpNotify_BACK_TO_MY_WORLD,
|
||||
}
|
||||
@@ -420,25 +420,25 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
|
||||
|
||||
world.RemovePlayer(player)
|
||||
player.WorldId = 0
|
||||
if world.owner.PlayerID == player.PlayerID {
|
||||
if world.GetOwner().PlayerID == player.PlayerID {
|
||||
// 房主离开销毁世界
|
||||
WORLD_MANAGER.DestroyWorld(world.id)
|
||||
MESSAGE_QUEUE.SendToFight(world.owner.FightAppId, &mq.NetMsg{
|
||||
WORLD_MANAGER.DestroyWorld(world.GetId())
|
||||
MESSAGE_QUEUE.SendToFight(world.GetOwner().FightAppId, &mq.NetMsg{
|
||||
MsgType: mq.MsgTypeFight,
|
||||
EventId: mq.DelFightRoutine,
|
||||
FightMsg: &mq.FightMsg{
|
||||
FightRoutineId: world.id,
|
||||
FightRoutineId: world.GetId(),
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
if world.multiplayer && world.GetWorldPlayerNum() > 0 {
|
||||
if world.GetMultiplayer() && world.GetWorldPlayerNum() > 0 {
|
||||
g.UpdateWorldPlayerInfo(world, 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 {
|
||||
continue
|
||||
}
|
||||
@@ -454,7 +454,7 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
|
||||
PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
|
||||
PlayerUidList: make([]uint32, 0),
|
||||
}
|
||||
for _, subWorldPlayer := range hostWorld.playerMap {
|
||||
for _, subWorldPlayer := range hostWorld.GetAllPlayer() {
|
||||
onlinePlayerInfo := &proto.OnlinePlayerInfo{
|
||||
Uid: subWorldPlayer.PlayerID,
|
||||
Nickname: subWorldPlayer.NickName,
|
||||
@@ -479,7 +479,7 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
|
||||
scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{
|
||||
PlayerInfoList: make([]*proto.ScenePlayerInfo, 0),
|
||||
}
|
||||
for _, worldPlayer := range hostWorld.playerMap {
|
||||
for _, worldPlayer := range hostWorld.GetAllPlayer() {
|
||||
onlinePlayerInfo := &proto.OnlinePlayerInfo{
|
||||
Uid: worldPlayer.PlayerID,
|
||||
Nickname: worldPlayer.NickName,
|
||||
@@ -507,8 +507,8 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
|
||||
SceneId: worldPlayer.SceneId,
|
||||
TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0),
|
||||
}
|
||||
if hostWorld.multiplayer {
|
||||
for _, worldPlayer := range hostWorld.playerMap {
|
||||
if hostWorld.GetMultiplayer() {
|
||||
for _, worldPlayer := range hostWorld.GetAllPlayer() {
|
||||
if worldPlayer.PlayerID == worldPlayer.PlayerID {
|
||||
continue
|
||||
}
|
||||
@@ -554,13 +554,13 @@ func (g *GameManager) ServerUserMpReq(userMpInfo *mq.UserMpInfo, gsAppId string)
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP)
|
||||
return
|
||||
}
|
||||
if WORLD_MANAGER.multiplayerWorldNum >= MAX_MULTIPLAYER_WORLD_NUM {
|
||||
if WORLD_MANAGER.GetMultiplayerWorldNum() >= MAX_MULTIPLAYER_WORLD_NUM {
|
||||
// 超过本服务器最大多人世界数量限制
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_MAX_PLAYER)
|
||||
return
|
||||
}
|
||||
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)
|
||||
return
|
||||
@@ -612,7 +612,7 @@ func (g *GameManager) ServerUserMpReq(userMpInfo *mq.UserMpInfo, gsAppId string)
|
||||
return
|
||||
}
|
||||
applyPlayerWorld := WORLD_MANAGER.GetWorldByID(applyPlayer.WorldId)
|
||||
if applyPlayerWorld.multiplayer {
|
||||
if applyPlayerWorld.GetMultiplayer() {
|
||||
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
|
||||
TargetUid: userMpInfo.HostUserId,
|
||||
TargetNickname: userMpInfo.HostNickname,
|
||||
|
||||
@@ -28,7 +28,7 @@ func (g *GameManager) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Mes
|
||||
enterScenePeerNotify := &proto.EnterScenePeerNotify{
|
||||
DestSceneId: player.SceneId,
|
||||
PeerId: world.GetPlayerPeerId(player),
|
||||
HostPeerId: world.GetPlayerPeerId(world.owner),
|
||||
HostPeerId: world.GetPlayerPeerId(world.GetOwner()),
|
||||
EnterSceneToken: player.EnterSceneToken,
|
||||
}
|
||||
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),
|
||||
PlayerUidList: make([]uint32, 0),
|
||||
}
|
||||
for _, worldPlayer := range world.playerMap {
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
onlinePlayerInfo := &proto.OnlinePlayerInfo{
|
||||
Uid: worldPlayer.PlayerID,
|
||||
Nickname: worldPlayer.NickName,
|
||||
@@ -76,14 +76,14 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
|
||||
// 世界等级
|
||||
worldDataNotify.WorldPropMap[1] = &proto.PropValue{
|
||||
Type: 1,
|
||||
Val: int64(world.worldLevel),
|
||||
Value: &proto.PropValue_Ival{Ival: int64(world.worldLevel)},
|
||||
Val: int64(world.GetWorldLevel()),
|
||||
Value: &proto.PropValue_Ival{Ival: int64(world.GetWorldLevel())},
|
||||
}
|
||||
// 是否多人游戏
|
||||
worldDataNotify.WorldPropMap[2] = &proto.PropValue{
|
||||
Type: 2,
|
||||
Val: object.ConvBoolToInt64(world.multiplayer),
|
||||
Value: &proto.PropValue_Ival{Ival: object.ConvBoolToInt64(world.multiplayer)},
|
||||
Val: object.ConvBoolToInt64(world.GetMultiplayer()),
|
||||
Value: &proto.PropValue_Ival{Ival: object.ConvBoolToInt64(world.GetMultiplayer())},
|
||||
}
|
||||
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))
|
||||
|
||||
hostPlayerNotify := &proto.HostPlayerNotify{
|
||||
HostUid: world.owner.PlayerID,
|
||||
HostPeerId: world.GetPlayerPeerId(world.owner),
|
||||
HostUid: world.GetOwner().PlayerID,
|
||||
HostPeerId: world.GetPlayerPeerId(world.GetOwner()),
|
||||
}
|
||||
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)
|
||||
|
||||
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
|
||||
GameTime: scene.gameTime,
|
||||
GameTime: scene.GetGameTime(),
|
||||
Uid: player.PlayerID,
|
||||
}
|
||||
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),
|
||||
},
|
||||
MpLevelEntityInfo: &proto.MPLevelEntityInfo{
|
||||
EntityId: WORLD_MANAGER.GetWorldByID(player.WorldId).mpLevelEntityId,
|
||||
EntityId: WORLD_MANAGER.GetWorldByID(player.WorldId).GetMpLevelEntityId(),
|
||||
AuthorityPeerId: world.GetPlayerPeerId(player),
|
||||
AbilityInfo: empty,
|
||||
},
|
||||
AvatarEnterInfo: make([]*proto.AvatarEnterSceneInfo, 0),
|
||||
}
|
||||
for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) {
|
||||
avatar := player.AvatarMap[worldAvatar.avatarId]
|
||||
avatar := player.AvatarMap[worldAvatar.GetAvatarId()]
|
||||
avatarEnterSceneInfo := &proto.AvatarEnterSceneInfo{
|
||||
AvatarGuid: avatar.Guid,
|
||||
AvatarEntityId: world.GetPlayerWorldAvatarEntityId(player, worldAvatar.avatarId),
|
||||
AvatarEntityId: world.GetPlayerWorldAvatarEntityId(player, worldAvatar.GetAvatarId()),
|
||||
WeaponGuid: avatar.EquipWeapon.Guid,
|
||||
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(player, worldAvatar.avatarId),
|
||||
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(player, worldAvatar.GetAvatarId()),
|
||||
AvatarAbilityInfo: &proto.AbilitySyncStateInfo{
|
||||
IsInited: len(worldAvatar.abilityList) != 0,
|
||||
IsInited: len(worldAvatar.GetAbilityList()) != 0,
|
||||
DynamicValueMap: nil,
|
||||
AppliedAbilities: worldAvatar.abilityList,
|
||||
AppliedModifiers: worldAvatar.modifierList,
|
||||
AppliedAbilities: worldAvatar.GetAbilityList(),
|
||||
AppliedModifiers: worldAvatar.GetModifierList(),
|
||||
MixinRecoverInfos: nil,
|
||||
SgvDynamicValueMap: nil,
|
||||
},
|
||||
@@ -175,7 +175,7 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
|
||||
scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{
|
||||
PlayerInfoList: make([]*proto.ScenePlayerInfo, 0),
|
||||
}
|
||||
for _, worldPlayer := range world.playerMap {
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
onlinePlayerInfo := &proto.OnlinePlayerInfo{
|
||||
Uid: worldPlayer.PlayerID,
|
||||
Nickname: worldPlayer.NickName,
|
||||
@@ -203,8 +203,8 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
|
||||
SceneId: player.SceneId,
|
||||
TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0),
|
||||
}
|
||||
if world.multiplayer {
|
||||
for _, worldPlayer := range world.playerMap {
|
||||
if world.GetMultiplayer() {
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
if worldPlayer.PlayerID == player.PlayerID {
|
||||
continue
|
||||
}
|
||||
@@ -241,12 +241,12 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
|
||||
if world.multiplayer && world.IsPlayerFirstEnter(player) {
|
||||
if world.GetMultiplayer() && world.IsPlayerFirstEnter(player) {
|
||||
guestPostEnterSceneNotify := &proto.GuestPostEnterSceneNotify{
|
||||
SceneId: player.SceneId,
|
||||
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
|
||||
@@ -260,7 +260,7 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
|
||||
activeAvatarEntityId := world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)
|
||||
g.AddSceneEntityNotify(player, visionType, []uint32{activeAvatarEntityId}, true, false)
|
||||
|
||||
aoiManager, exist := WORLD_MANAGER.sceneBlockAoiMap[scene.id]
|
||||
aoiManager, exist := WORLD_MANAGER.GetSceneBlockAoiMap()[scene.GetId()]
|
||||
if exist {
|
||||
objectList := aoiManager.GetObjectListByPos(float32(player.Pos.X), 0.0, float32(player.Pos.Z))
|
||||
for objectId, entityConfig := range objectList {
|
||||
@@ -275,10 +275,10 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
|
||||
entityMap := scene.GetAllEntity()
|
||||
entityIdList := make([]uint32, 0)
|
||||
for _, entity := range entityMap {
|
||||
if entity.id == activeAvatarEntityId {
|
||||
if entity.GetId() == activeAvatarEntityId {
|
||||
continue
|
||||
}
|
||||
entityIdList = append(entityIdList, entity.id)
|
||||
entityIdList = append(entityIdList, entity.GetId())
|
||||
}
|
||||
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)
|
||||
|
||||
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)
|
||||
if otherPlayer == nil {
|
||||
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.ChangeGameTime(gameTime)
|
||||
|
||||
for _, scenePlayer := range scene.playerMap {
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
|
||||
GameTime: scene.gameTime,
|
||||
GameTime: scene.GetGameTime(),
|
||||
Uid: scenePlayer.PlayerID,
|
||||
}
|
||||
g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, playerGameTimeNotify)
|
||||
}
|
||||
|
||||
changeGameTimeRsp := &proto.ChangeGameTimeRsp{
|
||||
CurGameTime: scene.gameTime,
|
||||
CurGameTime: scene.GetGameTime(),
|
||||
}
|
||||
g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp)
|
||||
}
|
||||
@@ -503,7 +503,7 @@ func (g *GameManager) AddSceneEntityNotifyBroadcast(player *model.Player, scene
|
||||
AppearType: visionType,
|
||||
EntityList: entityList,
|
||||
}
|
||||
for _, scenePlayer := range scene.playerMap {
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
if aec && scenePlayer.PlayerID == player.PlayerID {
|
||||
continue
|
||||
}
|
||||
@@ -528,7 +528,7 @@ func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType
|
||||
EntityList: entityIdList,
|
||||
DisappearType: visionType,
|
||||
}
|
||||
for _, scenePlayer := range scene.playerMap {
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
|
||||
logger.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v",
|
||||
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)
|
||||
for _, entityId := range entityIdList[begin:end] {
|
||||
entity, exist := scene.entityMap[entityId]
|
||||
entityMap := scene.GetAllEntity()
|
||||
entity, exist := entityMap[entityId]
|
||||
if !exist {
|
||||
logger.Error("get entity is nil, entityId: %v", entityId)
|
||||
continue
|
||||
}
|
||||
switch entity.entityType {
|
||||
switch entity.GetEntityType() {
|
||||
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
|
||||
}
|
||||
scenePlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
|
||||
scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
||||
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
|
||||
}
|
||||
if entity.avatarEntity.avatarId != world.GetPlayerActiveAvatarId(scenePlayer) {
|
||||
if entity.GetAvatarEntity().GetAvatarId() != world.GetPlayerActiveAvatarId(scenePlayer) {
|
||||
continue
|
||||
}
|
||||
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
|
||||
entityList = append(entityList, sceneEntityInfoAvatar)
|
||||
case uint32(proto.ProtEntityType_PROT_ENTITY_WEAPON):
|
||||
case uint32(proto.ProtEntityType_PROT_ENTITY_MONSTER):
|
||||
sceneEntityInfoMonster := g.PacketSceneEntityInfoMonster(scene, entity.id)
|
||||
sceneEntityInfoMonster := g.PacketSceneEntityInfoMonster(scene, entity.GetId())
|
||||
entityList = append(entityList, sceneEntityInfoMonster)
|
||||
case uint32(proto.ProtEntityType_PROT_ENTITY_NPC):
|
||||
sceneEntityInfoNpc := g.PacketSceneEntityInfoNpc(scene, entity.id)
|
||||
sceneEntityInfoNpc := g.PacketSceneEntityInfoNpc(scene, entity.GetId())
|
||||
entityList = append(entityList, sceneEntityInfoNpc)
|
||||
case uint32(proto.ProtEntityType_PROT_ENTITY_GADGET):
|
||||
sceneEntityInfoGadget := g.PacketSceneEntityInfoGadget(scene, entity.id)
|
||||
sceneEntityInfoGadget := g.PacketSceneEntityInfoGadget(scene, entity.GetId())
|
||||
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) {
|
||||
for _, player := range scene.playerMap {
|
||||
for _, player := range scene.GetAllPlayer() {
|
||||
// PacketEntityFightPropUpdateNotify
|
||||
entityFightPropUpdateNotify := new(proto.EntityFightPropUpdateNotify)
|
||||
entityFightPropUpdateNotify.EntityId = entity.id
|
||||
entityFightPropUpdateNotify.FightPropMap = make(map[uint32]float32)
|
||||
entityFightPropUpdateNotify.FightPropMap[fightPropId] = entity.fightProp[fightPropId]
|
||||
g.SendMsg(cmd.EntityFightPropUpdateNotify, player.PlayerID, player.ClientSeq, entityFightPropUpdateNotify)
|
||||
g.SendMsg(cmd.EntityFightPropUpdateNotify, player.PlayerID, player.ClientSeq, &proto.EntityFightPropUpdateNotify{
|
||||
FightPropMap: entity.GetFightProp(),
|
||||
EntityId: entity.GetId(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,33 +646,33 @@ func (g *GameManager) PacketFightPropMapToPbFightPropList(fightPropMap map[uint3
|
||||
}
|
||||
|
||||
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 {
|
||||
return new(proto.SceneEntityInfo)
|
||||
}
|
||||
pos := &proto.Vector{
|
||||
X: float32(entity.pos.X),
|
||||
Y: float32(entity.pos.Y),
|
||||
Z: float32(entity.pos.Z),
|
||||
X: float32(entity.GetPos().X),
|
||||
Y: float32(entity.GetPos().Y),
|
||||
Z: float32(entity.GetPos().Z),
|
||||
}
|
||||
worldAvatar := scene.world.GetWorldAvatarByEntityId(entity.id)
|
||||
avatar, ok := player.AvatarMap[worldAvatar.avatarId]
|
||||
worldAvatar := scene.GetWorld().GetWorldAvatarByEntityId(entity.GetId())
|
||||
avatar, ok := player.AvatarMap[worldAvatar.GetAvatarId()]
|
||||
if !ok {
|
||||
logger.Error("avatar error, avatarId: %v", worldAvatar.avatarId)
|
||||
logger.Error("avatar error, avatarId: %v", worldAvatar.GetAvatarId())
|
||||
return new(proto.SceneEntityInfo)
|
||||
}
|
||||
sceneEntityInfo := &proto.SceneEntityInfo{
|
||||
EntityType: proto.ProtEntityType_PROT_ENTITY_AVATAR,
|
||||
EntityId: entity.id,
|
||||
EntityId: entity.GetId(),
|
||||
MotionInfo: &proto.MotionInfo{
|
||||
Pos: pos,
|
||||
Rot: &proto.Vector{
|
||||
X: float32(entity.rot.X),
|
||||
Y: float32(entity.rot.Y),
|
||||
Z: float32(entity.rot.Z),
|
||||
X: float32(entity.GetRot().X),
|
||||
Y: float32(entity.GetRot().Y),
|
||||
Z: float32(entity.GetRot().Z),
|
||||
},
|
||||
Speed: &proto.Vector{},
|
||||
State: proto.MotionState(entity.moveState),
|
||||
State: proto.MotionState(entity.GetMoveState()),
|
||||
},
|
||||
PropList: []*proto.PropPair{
|
||||
{
|
||||
@@ -720,10 +720,10 @@ func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Pl
|
||||
EntityClientData: new(proto.EntityClientData),
|
||||
EntityAuthorityInfo: &proto.EntityAuthorityInfo{
|
||||
AbilityInfo: &proto.AbilitySyncStateInfo{
|
||||
IsInited: len(worldAvatar.abilityList) != 0,
|
||||
IsInited: len(worldAvatar.GetAbilityList()) != 0,
|
||||
DynamicValueMap: nil,
|
||||
AppliedAbilities: worldAvatar.abilityList,
|
||||
AppliedModifiers: worldAvatar.modifierList,
|
||||
AppliedAbilities: worldAvatar.GetAbilityList(),
|
||||
AppliedModifiers: worldAvatar.GetModifierList(),
|
||||
MixinRecoverInfos: nil,
|
||||
SgvDynamicValueMap: nil,
|
||||
},
|
||||
@@ -734,8 +734,8 @@ func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Pl
|
||||
},
|
||||
BornPos: pos,
|
||||
},
|
||||
LastMoveSceneTimeMs: entity.lastMoveSceneTimeMs,
|
||||
LastMoveReliableSeq: entity.lastMoveReliableSeq,
|
||||
LastMoveSceneTimeMs: entity.GetLastMoveSceneTimeMs(),
|
||||
LastMoveReliableSeq: entity.GetLastMoveReliableSeq(),
|
||||
}
|
||||
return sceneEntityInfo
|
||||
}
|
||||
@@ -746,30 +746,30 @@ func (g *GameManager) PacketSceneEntityInfoMonster(scene *Scene, entityId uint32
|
||||
return new(proto.SceneEntityInfo)
|
||||
}
|
||||
pos := &proto.Vector{
|
||||
X: float32(entity.pos.X),
|
||||
Y: float32(entity.pos.Y),
|
||||
Z: float32(entity.pos.Z),
|
||||
X: float32(entity.GetPos().X),
|
||||
Y: float32(entity.GetPos().Y),
|
||||
Z: float32(entity.GetPos().Z),
|
||||
}
|
||||
sceneEntityInfo := &proto.SceneEntityInfo{
|
||||
EntityType: proto.ProtEntityType_PROT_ENTITY_MONSTER,
|
||||
EntityId: entity.id,
|
||||
EntityId: entity.GetId(),
|
||||
MotionInfo: &proto.MotionInfo{
|
||||
Pos: pos,
|
||||
Rot: &proto.Vector{
|
||||
X: float32(entity.rot.X),
|
||||
Y: float32(entity.rot.Y),
|
||||
Z: float32(entity.rot.Z),
|
||||
X: float32(entity.GetRot().X),
|
||||
Y: float32(entity.GetRot().Y),
|
||||
Z: float32(entity.GetRot().Z),
|
||||
},
|
||||
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{
|
||||
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
|
||||
Value: &proto.PropValue_Ival{Ival: int64(entity.level)},
|
||||
Val: int64(entity.level),
|
||||
Value: &proto.PropValue_Ival{Ival: int64(entity.GetLevel())},
|
||||
Val: int64(entity.GetLevel()),
|
||||
}}},
|
||||
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.fightProp),
|
||||
LifeState: uint32(entity.lifeState),
|
||||
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.GetFightProp()),
|
||||
LifeState: uint32(entity.GetLifeState()),
|
||||
AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0),
|
||||
Entity: &proto.SceneEntityInfo_Monster{
|
||||
Monster: g.PacketSceneMonsterInfo(entity),
|
||||
@@ -794,33 +794,33 @@ func (g *GameManager) PacketSceneEntityInfoNpc(scene *Scene, entityId uint32) *p
|
||||
return new(proto.SceneEntityInfo)
|
||||
}
|
||||
pos := &proto.Vector{
|
||||
X: float32(entity.pos.X),
|
||||
Y: float32(entity.pos.Y),
|
||||
Z: float32(entity.pos.Z),
|
||||
X: float32(entity.GetPos().X),
|
||||
Y: float32(entity.GetPos().Y),
|
||||
Z: float32(entity.GetPos().Z),
|
||||
}
|
||||
sceneEntityInfo := &proto.SceneEntityInfo{
|
||||
EntityType: proto.ProtEntityType_PROT_ENTITY_NPC,
|
||||
EntityId: entity.id,
|
||||
EntityId: entity.GetId(),
|
||||
MotionInfo: &proto.MotionInfo{
|
||||
Pos: pos,
|
||||
Rot: &proto.Vector{
|
||||
X: float32(entity.rot.X),
|
||||
Y: float32(entity.rot.Y),
|
||||
Z: float32(entity.rot.Z),
|
||||
X: float32(entity.GetRot().X),
|
||||
Y: float32(entity.GetRot().Y),
|
||||
Z: float32(entity.GetRot().Z),
|
||||
},
|
||||
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{
|
||||
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
|
||||
Value: &proto.PropValue_Ival{Ival: int64(entity.level)},
|
||||
Val: int64(entity.level),
|
||||
Value: &proto.PropValue_Ival{Ival: int64(entity.GetLevel())},
|
||||
Val: int64(entity.GetLevel()),
|
||||
}}},
|
||||
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.fightProp),
|
||||
LifeState: uint32(entity.lifeState),
|
||||
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.GetFightProp()),
|
||||
LifeState: uint32(entity.GetLifeState()),
|
||||
AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0),
|
||||
Entity: &proto.SceneEntityInfo_Npc{
|
||||
Npc: g.PacketSceneNpcInfo(entity.npcEntity),
|
||||
Npc: g.PacketSceneNpcInfo(entity.GetNpcEntity()),
|
||||
},
|
||||
EntityClientData: new(proto.EntityClientData),
|
||||
EntityAuthorityInfo: &proto.EntityAuthorityInfo{
|
||||
@@ -842,30 +842,30 @@ func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32)
|
||||
return new(proto.SceneEntityInfo)
|
||||
}
|
||||
pos := &proto.Vector{
|
||||
X: float32(entity.pos.X),
|
||||
Y: float32(entity.pos.Y),
|
||||
Z: float32(entity.pos.Z),
|
||||
X: float32(entity.GetPos().X),
|
||||
Y: float32(entity.GetPos().Y),
|
||||
Z: float32(entity.GetPos().Z),
|
||||
}
|
||||
sceneEntityInfo := &proto.SceneEntityInfo{
|
||||
EntityType: proto.ProtEntityType_PROT_ENTITY_GADGET,
|
||||
EntityId: entity.id,
|
||||
EntityId: entity.GetId(),
|
||||
MotionInfo: &proto.MotionInfo{
|
||||
Pos: pos,
|
||||
Rot: &proto.Vector{
|
||||
X: float32(entity.rot.X),
|
||||
Y: float32(entity.rot.Y),
|
||||
Z: float32(entity.rot.Z),
|
||||
X: float32(entity.GetRot().X),
|
||||
Y: float32(entity.GetRot().Y),
|
||||
Z: float32(entity.GetRot().Z),
|
||||
},
|
||||
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{
|
||||
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
|
||||
Value: &proto.PropValue_Ival{Ival: int64(1)},
|
||||
Val: int64(1),
|
||||
}}},
|
||||
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.fightProp),
|
||||
LifeState: uint32(entity.lifeState),
|
||||
FightPropList: g.PacketFightPropMapToPbFightPropList(entity.GetFightProp()),
|
||||
LifeState: uint32(entity.GetLifeState()),
|
||||
AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0),
|
||||
EntityClientData: new(proto.EntityClientData),
|
||||
EntityAuthorityInfo: &proto.EntityAuthorityInfo{
|
||||
@@ -878,7 +878,8 @@ func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32)
|
||||
BornPos: pos,
|
||||
},
|
||||
}
|
||||
switch entity.gadgetEntity.gadgetType {
|
||||
gadgetEntity := entity.GetGadgetEntity()
|
||||
switch gadgetEntity.GetGadgetType() {
|
||||
case GADGET_TYPE_NORMAL:
|
||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||
Gadget: g.PacketSceneGadgetInfoNormal(entity),
|
||||
@@ -889,11 +890,11 @@ func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32)
|
||||
}
|
||||
case GADGET_TYPE_CLIENT:
|
||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||
Gadget: g.PacketSceneGadgetInfoClient(entity.gadgetEntity.gadgetClientEntity),
|
||||
Gadget: g.PacketSceneGadgetInfoClient(gadgetEntity.GetGadgetClientEntity()),
|
||||
}
|
||||
case GADGET_TYPE_VEHICLE:
|
||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||
Gadget: g.PacketSceneGadgetInfoVehicle(entity.gadgetEntity.gadgetVehicleEntity),
|
||||
Gadget: g.PacketSceneGadgetInfoVehicle(gadgetEntity.GetGadgetVehicleEntity()),
|
||||
}
|
||||
}
|
||||
return sceneEntityInfo
|
||||
@@ -915,7 +916,7 @@ func (g *GameManager) PacketSceneAvatarInfo(scene *Scene, player *model.Player,
|
||||
EquipIdList: equipIdList,
|
||||
SkillDepotId: player.AvatarMap[avatarId].SkillDepotId,
|
||||
Weapon: &proto.SceneWeaponInfo{
|
||||
EntityId: scene.world.GetPlayerWorldAvatarWeaponEntityId(player, avatarId),
|
||||
EntityId: scene.GetWorld().GetPlayerWorldAvatarWeaponEntityId(player, avatarId),
|
||||
GadgetId: uint32(gdconf.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId),
|
||||
ItemId: weapon.ItemId,
|
||||
Guid: weapon.Guid,
|
||||
@@ -937,7 +938,7 @@ func (g *GameManager) PacketSceneAvatarInfo(scene *Scene, player *model.Player,
|
||||
|
||||
func (g *GameManager) PacketSceneMonsterInfo(entity *Entity) *proto.SceneMonsterInfo {
|
||||
sceneMonsterInfo := &proto.SceneMonsterInfo{
|
||||
MonsterId: entity.monsterEntity.monsterId,
|
||||
MonsterId: entity.GetMonsterEntity().GetMonsterId(),
|
||||
AuthorityPeerId: 1,
|
||||
BornType: proto.MonsterBornType_MONSTER_BORN_DEFAULT,
|
||||
// BlockId: 3001,
|
||||
@@ -958,10 +959,11 @@ func (g *GameManager) PacketSceneNpcInfo(entity *NpcEntity) *proto.SceneNpcInfo
|
||||
}
|
||||
|
||||
func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGadgetInfo {
|
||||
gadgetEntity := entity.GetGadgetEntity()
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: entity.gadgetEntity.gadgetId,
|
||||
GadgetId: gadgetEntity.GetGadgetId(),
|
||||
GroupId: 0,
|
||||
ConfigId: entity.configId,
|
||||
ConfigId: entity.GetConfigId(),
|
||||
GadgetState: 0,
|
||||
IsEnableInteract: true,
|
||||
AuthorityPeerId: 1,
|
||||
@@ -970,15 +972,17 @@ func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGa
|
||||
}
|
||||
|
||||
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 {
|
||||
logger.Error("gather data error, gatherId: %v", entity.gadgetEntity.gadgetGatherEntity.gatherId)
|
||||
logger.Error("gather data error, gatherId: %v", gatherEntity.GetGatherId())
|
||||
return new(proto.SceneGadgetInfo)
|
||||
}
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: entity.gadgetEntity.gadgetId,
|
||||
GadgetId: gadgetEntity.GetGadgetId(),
|
||||
GroupId: 0,
|
||||
ConfigId: entity.configId,
|
||||
ConfigId: entity.GetConfigId(),
|
||||
GadgetState: 0,
|
||||
IsEnableInteract: true,
|
||||
AuthorityPeerId: 1,
|
||||
@@ -994,33 +998,33 @@ func (g *GameManager) PacketSceneGadgetInfoGather(entity *Entity) *proto.SceneGa
|
||||
|
||||
func (g *GameManager) PacketSceneGadgetInfoClient(gadgetClientEntity *GadgetClientEntity) *proto.SceneGadgetInfo {
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: gadgetClientEntity.configId,
|
||||
OwnerEntityId: gadgetClientEntity.ownerEntityId,
|
||||
GadgetId: gadgetClientEntity.GetConfigId(),
|
||||
OwnerEntityId: gadgetClientEntity.GetOwnerEntityId(),
|
||||
AuthorityPeerId: 1,
|
||||
IsEnableInteract: true,
|
||||
Content: &proto.SceneGadgetInfo_ClientGadget{
|
||||
ClientGadget: &proto.ClientGadgetInfo{
|
||||
CampId: gadgetClientEntity.campId,
|
||||
CampType: gadgetClientEntity.campType,
|
||||
OwnerEntityId: gadgetClientEntity.ownerEntityId,
|
||||
TargetEntityId: gadgetClientEntity.targetEntityId,
|
||||
CampId: gadgetClientEntity.GetCampId(),
|
||||
CampType: gadgetClientEntity.GetCampType(),
|
||||
OwnerEntityId: gadgetClientEntity.GetOwnerEntityId(),
|
||||
TargetEntityId: gadgetClientEntity.GetTargetEntityId(),
|
||||
},
|
||||
},
|
||||
PropOwnerEntityId: gadgetClientEntity.propOwnerEntityId,
|
||||
PropOwnerEntityId: gadgetClientEntity.GetPropOwnerEntityId(),
|
||||
}
|
||||
return sceneGadgetInfo
|
||||
}
|
||||
|
||||
func (g *GameManager) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVehicleEntity) *proto.SceneGadgetInfo {
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: gadgetVehicleEntity.vehicleId,
|
||||
AuthorityPeerId: WORLD_MANAGER.GetWorldByID(gadgetVehicleEntity.owner.WorldId).GetPlayerPeerId(gadgetVehicleEntity.owner),
|
||||
GadgetId: gadgetVehicleEntity.GetVehicleId(),
|
||||
AuthorityPeerId: WORLD_MANAGER.GetWorldByID(gadgetVehicleEntity.GetOwner().WorldId).GetPlayerPeerId(gadgetVehicleEntity.GetOwner()),
|
||||
IsEnableInteract: true,
|
||||
Content: &proto.SceneGadgetInfo_VehicleInfo{
|
||||
VehicleInfo: &proto.VehicleInfo{
|
||||
MemberList: make([]*proto.VehicleMember, 0, len(gadgetVehicleEntity.memberMap)),
|
||||
OwnerUid: gadgetVehicleEntity.owner.PlayerID,
|
||||
CurStamina: gadgetVehicleEntity.curStamina,
|
||||
MemberList: make([]*proto.VehicleMember, 0, len(gadgetVehicleEntity.GetMemberMap())),
|
||||
OwnerUid: gadgetVehicleEntity.GetOwner().PlayerID,
|
||||
CurStamina: gadgetVehicleEntity.GetCurStamina(),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1030,7 +1034,7 @@ func (g *GameManager) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVe
|
||||
func (g *GameManager) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify {
|
||||
delTeamEntityNotify := &proto.DelTeamEntityNotify{
|
||||
SceneId: player.SceneId,
|
||||
DelEntityIdList: []uint32{scene.world.GetPlayerTeamEntityId(player)},
|
||||
DelEntityIdList: []uint32{scene.GetWorld().GetPlayerTeamEntityId(player)},
|
||||
}
|
||||
return delTeamEntityNotify
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func (g *GameManager) GetPlayerSocialDetailReq(player *model.Player, payloadMsg
|
||||
|
||||
targetPlayer, _, _ := USER_MANAGER.LoadGlobalPlayer(targetUid)
|
||||
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
|
||||
}
|
||||
_, 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)
|
||||
req := payloadMsg.(*proto.SetPlayerBirthdayReq)
|
||||
if player.Birthday[0] != 0 || player.Birthday[1] != 0 {
|
||||
g.CommonRetError(cmd.SetPlayerBirthdayRsp, player, &proto.SetPlayerBirthdayRsp{})
|
||||
g.SendError(cmd.SetPlayerBirthdayRsp, player, &proto.SetPlayerBirthdayRsp{})
|
||||
return
|
||||
}
|
||||
birthday := req.Birthday
|
||||
@@ -440,7 +440,7 @@ func (g *GameManager) GetOnlinePlayerInfoReq(player *model.Player, payloadMsg pb
|
||||
|
||||
targetPlayer, online, _ := USER_MANAGER.LoadGlobalPlayer(targetUid.TargetUid)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ func (g *GameManager) HandleAbilityStamina(player *model.Player, entry *proto.Ab
|
||||
}
|
||||
// 查找是不是属于该角色实体的ability id
|
||||
abilityNameHashCode := uint32(0)
|
||||
for _, ability := range worldAvatar.abilityList {
|
||||
for _, ability := range worldAvatar.GetAbilityList() {
|
||||
if ability.InstancedAbilityId == entry.Head.InstancedAbilityId {
|
||||
// logger.Error("%v", ability)
|
||||
abilityNameHashCode = ability.AbilityName.GetHash()
|
||||
@@ -107,7 +107,7 @@ func (g *GameManager) SceneAvatarStaminaStepReq(player *model.Player, payloadMsg
|
||||
angleRevise = int32(req.Rot.X - 360.0)
|
||||
} else {
|
||||
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
|
||||
}
|
||||
// 攀爬耐力修正曲线
|
||||
@@ -191,9 +191,9 @@ func (g *GameManager) SkillSustainStamina(player *model.Player, isSwim bool) {
|
||||
return
|
||||
}
|
||||
// 获取现行角色的配置表
|
||||
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.avatarId)]
|
||||
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
|
||||
if !ok {
|
||||
logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.avatarId)
|
||||
logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.GetAvatarId())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -230,9 +230,9 @@ func (g *GameManager) ChargedAttackStamina(player *model.Player, worldAvatar *Wo
|
||||
return
|
||||
}
|
||||
// 获取现行角色的配置表
|
||||
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.avatarId)]
|
||||
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
|
||||
if !ok {
|
||||
logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.avatarId)
|
||||
logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.GetAvatarId())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -307,11 +307,12 @@ func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
|
||||
return
|
||||
}
|
||||
// 确保实体类型是否为载具
|
||||
if entity.gadgetEntity == nil || entity.gadgetEntity.gadgetVehicleEntity == nil {
|
||||
gadgetEntity := entity.GetGadgetEntity()
|
||||
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
|
||||
return
|
||||
}
|
||||
// 判断玩家处于载具中
|
||||
if g.IsPlayerInVehicle(player, entity.gadgetEntity.gadgetVehicleEntity) {
|
||||
if g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
||||
// 角色回复耐力
|
||||
g.UpdatePlayerStamina(player, constant.StaminaCostConst.IN_SKIFF)
|
||||
} else {
|
||||
@@ -333,7 +334,8 @@ func (g *GameManager) SustainStaminaHandler(player *model.Player) {
|
||||
// 获取玩家处于的载具实体
|
||||
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)
|
||||
} else {
|
||||
@@ -382,9 +384,10 @@ func (g *GameManager) UpdateVehicleStamina(player *model.Player, vehicleEntity *
|
||||
// 因为载具的耐力需要换算
|
||||
// 这里先*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)
|
||||
@@ -449,9 +452,9 @@ func (g *GameManager) DrownBackHandler(player *model.Player) {
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player))
|
||||
avatarEntity := scene.GetEntity(activeAvatar.avatarEntityId)
|
||||
avatarEntity := scene.GetEntity(activeAvatar.GetAvatarEntityId())
|
||||
if avatarEntity == nil {
|
||||
logger.Error("avatar entity is nil, entityId: %v", activeAvatar.avatarEntityId)
|
||||
logger.Error("avatar entity is nil, entityId: %v", activeAvatar.GetAvatarEntityId())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -514,9 +517,9 @@ func (g *GameManager) HandleDrown(player *model.Player, stamina uint32) {
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
activeAvatar := world.GetPlayerWorldAvatar(player, world.GetPlayerActiveAvatarId(player))
|
||||
avatarEntity := scene.GetEntity(activeAvatar.avatarEntityId)
|
||||
avatarEntity := scene.GetEntity(activeAvatar.GetAvatarEntityId())
|
||||
if avatarEntity == nil {
|
||||
logger.Error("avatar entity is nil, entityId: %v", activeAvatar.avatarEntityId)
|
||||
logger.Error("avatar entity is nil, entityId: %v", activeAvatar.GetAvatarEntityId())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -533,12 +536,13 @@ func (g *GameManager) HandleDrown(player *model.Player, stamina uint32) {
|
||||
// SetVehicleStamina 设置载具耐力
|
||||
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)
|
||||
|
||||
// PacketVehicleStaminaNotify
|
||||
vehicleStaminaNotify := new(proto.VehicleStaminaNotify)
|
||||
vehicleStaminaNotify.EntityId = vehicleEntity.id
|
||||
vehicleStaminaNotify.EntityId = vehicleEntity.GetId()
|
||||
vehicleStaminaNotify.CurStamina = stamina
|
||||
g.SendMsg(cmd.VehicleStaminaNotify, player.PlayerID, player.ClientSeq, vehicleStaminaNotify)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
return
|
||||
}
|
||||
if !world.multiplayer {
|
||||
if !world.GetMultiplayer() {
|
||||
player.TeamConfig.CurrAvatarIndex = uint8(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)
|
||||
return
|
||||
}
|
||||
oldAvatarEntity.moveState = uint16(proto.MotionState_MOTION_STANDBY)
|
||||
oldAvatarEntity.SetMoveState(uint16(proto.MotionState_MOTION_STANDBY))
|
||||
|
||||
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Messag
|
||||
newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarId)
|
||||
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
||||
AppearType: proto.VisionType_VISION_REPLACE,
|
||||
Param: oldAvatarEntity.id,
|
||||
Param: oldAvatarEntity.GetId(),
|
||||
EntityList: []*proto.SceneEntityInfo{newAvatarEntity},
|
||||
}
|
||||
for _, scenePlayer := range scene.playerMap {
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
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)
|
||||
req := payloadMsg.(*proto.SetUpAvatarTeamReq)
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
if world.multiplayer {
|
||||
g.CommonRetError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
if world.GetMultiplayer() {
|
||||
g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
teamId := req.TeamId
|
||||
if teamId <= 0 || teamId >= 5 {
|
||||
g.CommonRetError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
avatarGuidList := req.AvatarTeamGuidList
|
||||
selfTeam := teamId == uint32(player.TeamConfig.GetActiveTeamId())
|
||||
if (selfTeam && len(avatarGuidList) == 0) || len(avatarGuidList) > 4 {
|
||||
g.CommonRetError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
avatarIdList := make([]uint32, 0)
|
||||
@@ -139,8 +139,8 @@ func (g *GameManager) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb
|
||||
req := payloadMsg.(*proto.ChooseCurAvatarTeamReq)
|
||||
teamId := req.TeamId
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
if world.multiplayer {
|
||||
g.CommonRetError(cmd.ChooseCurAvatarTeamRsp, player, &proto.ChooseCurAvatarTeamRsp{})
|
||||
if world.GetMultiplayer() {
|
||||
g.SendError(cmd.ChooseCurAvatarTeamRsp, player, &proto.ChooseCurAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
team := player.TeamConfig.GetTeamByIndex(uint8(teamId) - 1)
|
||||
@@ -169,8 +169,8 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
|
||||
req := payloadMsg.(*proto.ChangeMpTeamAvatarReq)
|
||||
avatarGuidList := req.AvatarGuidList
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
if !world.multiplayer || len(avatarGuidList) == 0 || len(avatarGuidList) > 4 {
|
||||
g.CommonRetError(cmd.ChangeMpTeamAvatarRsp, player, &proto.ChangeMpTeamAvatarRsp{})
|
||||
if !world.GetMultiplayer() || len(avatarGuidList) == 0 || len(avatarGuidList) > 4 {
|
||||
g.SendError(cmd.ChangeMpTeamAvatarRsp, player, &proto.ChangeMpTeamAvatarRsp{})
|
||||
return
|
||||
}
|
||||
avatarIdList := make([]uint32, 0)
|
||||
@@ -187,7 +187,7 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
|
||||
newAvatarIndex := world.GetPlayerAvatarIndexByAvatarId(player, currAvatarId)
|
||||
world.SetPlayerAvatarIndex(player, newAvatarIndex)
|
||||
|
||||
for _, worldPlayer := range world.playerMap {
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
|
||||
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 {
|
||||
sceneTeamUpdateNotify := &proto.SceneTeamUpdateNotify{
|
||||
IsInMp: world.multiplayer,
|
||||
IsInMp: world.GetMultiplayer(),
|
||||
}
|
||||
empty := new(proto.AbilitySyncStateInfo)
|
||||
for _, worldAvatar := range world.GetWorldAvatarList() {
|
||||
worldPlayer := USER_MANAGER.GetOnlineUser(worldAvatar.uid)
|
||||
worldPlayer := USER_MANAGER.GetOnlineUser(worldAvatar.GetUid())
|
||||
if worldPlayer == nil {
|
||||
logger.Error("player is nil, uid: %v", worldAvatar.uid)
|
||||
logger.Error("player is nil, uid: %v", worldAvatar.GetUid())
|
||||
continue
|
||||
}
|
||||
worldPlayerScene := world.GetSceneById(worldPlayer.SceneId)
|
||||
worldPlayerAvatar := worldPlayer.AvatarMap[worldAvatar.avatarId]
|
||||
worldPlayerAvatar := worldPlayer.AvatarMap[worldAvatar.GetAvatarId()]
|
||||
equipIdList := make([]uint32, 0)
|
||||
weapon := worldPlayerAvatar.EquipWeapon
|
||||
equipIdList = append(equipIdList, weapon.ItemId)
|
||||
@@ -222,29 +222,29 @@ func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeam
|
||||
PlayerUid: worldPlayer.PlayerID,
|
||||
AvatarGuid: worldPlayerAvatar.Guid,
|
||||
SceneId: worldPlayer.SceneId,
|
||||
EntityId: world.GetPlayerWorldAvatarEntityId(worldPlayer, worldAvatar.avatarId),
|
||||
SceneEntityInfo: g.PacketSceneEntityInfoAvatar(worldPlayerScene, worldPlayer, worldAvatar.avatarId),
|
||||
EntityId: world.GetPlayerWorldAvatarEntityId(worldPlayer, worldAvatar.GetAvatarId()),
|
||||
SceneEntityInfo: g.PacketSceneEntityInfoAvatar(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId()),
|
||||
WeaponGuid: worldPlayerAvatar.EquipWeapon.Guid,
|
||||
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(worldPlayer, worldAvatar.avatarId),
|
||||
IsPlayerCurAvatar: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.avatarId,
|
||||
IsOnScene: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.avatarId,
|
||||
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(worldPlayer, worldAvatar.GetAvatarId()),
|
||||
IsPlayerCurAvatar: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.GetAvatarId(),
|
||||
IsOnScene: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.GetAvatarId(),
|
||||
AvatarAbilityInfo: &proto.AbilitySyncStateInfo{
|
||||
IsInited: len(worldAvatar.abilityList) != 0,
|
||||
IsInited: len(worldAvatar.GetAbilityList()) != 0,
|
||||
DynamicValueMap: nil,
|
||||
AppliedAbilities: worldAvatar.abilityList,
|
||||
AppliedModifiers: worldAvatar.modifierList,
|
||||
AppliedAbilities: worldAvatar.GetAbilityList(),
|
||||
AppliedModifiers: worldAvatar.GetModifierList(),
|
||||
MixinRecoverInfos: nil,
|
||||
SgvDynamicValueMap: nil,
|
||||
},
|
||||
WeaponAbilityInfo: empty,
|
||||
AbilityControlBlock: new(proto.AbilityControlBlock),
|
||||
}
|
||||
if world.multiplayer {
|
||||
if world.GetMultiplayer() {
|
||||
sceneTeamAvatar.AvatarInfo = g.PacketAvatarInfo(worldPlayerAvatar)
|
||||
sceneTeamAvatar.SceneAvatarInfo = g.PacketSceneAvatarInfo(worldPlayerScene, worldPlayer, worldAvatar.avatarId)
|
||||
sceneTeamAvatar.SceneAvatarInfo = g.PacketSceneAvatarInfo(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId())
|
||||
}
|
||||
// add AbilityControlBlock
|
||||
avatarDataConfig := gdconf.CONF.AvatarDataMap[int32(worldAvatar.avatarId)]
|
||||
avatarDataConfig := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
|
||||
acb := sceneTeamAvatar.AbilityControlBlock
|
||||
embryoId := 0
|
||||
// add avatar abilities
|
||||
|
||||
@@ -18,7 +18,8 @@ func (g *GameManager) VehicleDestroyMotion(player *model.Player, entity *Entity,
|
||||
|
||||
// 状态等于 MOTION_STATE_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 冷却时间读取配置表
|
||||
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
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ func (g *GameManager) CreateVehicleReq(player *model.Player, payloadMsg pb.Messa
|
||||
entityId := scene.CreateEntityGadgetVehicle(player.PlayerID, pos, rot, req.VehicleId)
|
||||
if entityId == 0 {
|
||||
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
|
||||
}
|
||||
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 {
|
||||
return false
|
||||
}
|
||||
for _, p := range gadgetVehicleEntity.memberMap {
|
||||
for _, p := range gadgetVehicleEntity.GetMemberMap() {
|
||||
if p == player {
|
||||
return true
|
||||
}
|
||||
@@ -88,51 +89,53 @@ func (g *GameManager) DestroyVehicleEntity(player *model.Player, scene *Scene, v
|
||||
return
|
||||
}
|
||||
// 确保实体类型是否为载具
|
||||
if entity.gadgetEntity == nil || entity.gadgetEntity.gadgetVehicleEntity == nil {
|
||||
gadgetEntity := entity.GetGadgetEntity()
|
||||
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
|
||||
return
|
||||
}
|
||||
// 目前原神仅有一种载具 多载具目前理论上是兼容了 到时候有问题再改
|
||||
// 确保载具Id为将要创建的 (每种载具允许存在1个)
|
||||
if entity.gadgetEntity.gadgetVehicleEntity.vehicleId != vehicleId {
|
||||
if gadgetEntity.GetGadgetVehicleEntity().GetVehicleId() != vehicleId {
|
||||
return
|
||||
}
|
||||
// 该载具是否为此玩家的
|
||||
if entity.gadgetEntity.gadgetVehicleEntity.owner != player {
|
||||
if gadgetEntity.GetGadgetVehicleEntity().GetOwner() != player {
|
||||
return
|
||||
}
|
||||
// 如果玩家正在载具中
|
||||
if g.IsPlayerInVehicle(player, entity.gadgetEntity.gadgetVehicleEntity) {
|
||||
if g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
||||
// 离开载具
|
||||
g.ExitVehicle(player, entity, player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid)
|
||||
}
|
||||
// 删除已创建的载具
|
||||
scene.DestroyEntity(entity.id)
|
||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.id})
|
||||
scene.DestroyEntity(entity.GetId())
|
||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.GetId()})
|
||||
}
|
||||
|
||||
// EnterVehicle 进入载具
|
||||
func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
||||
maxSlot := 1 // TODO 读取配置表
|
||||
// 判断载具是否已满
|
||||
if len(entity.gadgetEntity.gadgetVehicleEntity.memberMap) >= maxSlot {
|
||||
g.CommonRetError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_VEHICLE_SLOT_OCCUPIED)
|
||||
gadgetEntity := entity.GetGadgetEntity()
|
||||
if len(gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()) >= maxSlot {
|
||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_VEHICLE_SLOT_OCCUPIED)
|
||||
return
|
||||
}
|
||||
|
||||
// 找出载具空闲的位置
|
||||
var freePos uint32
|
||||
for i := uint32(0); i < uint32(maxSlot); i++ {
|
||||
p := entity.gadgetEntity.gadgetVehicleEntity.memberMap[i]
|
||||
p := gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()[i]
|
||||
// 玩家如果已进入载具重复记录不进行报错
|
||||
if p == player || p == nil {
|
||||
// 载具成员记录玩家
|
||||
entity.gadgetEntity.gadgetVehicleEntity.memberMap[i] = player
|
||||
gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()[i] = player
|
||||
freePos = i
|
||||
}
|
||||
}
|
||||
|
||||
// 记录玩家所在的载具信息
|
||||
player.VehicleInfo.InVehicleEntityId = entity.id
|
||||
player.VehicleInfo.InVehicleEntityId = entity.GetId()
|
||||
|
||||
// PacketVehicleInteractRsp
|
||||
vehicleInteractRsp := &proto.VehicleInteractRsp{
|
||||
@@ -142,7 +145,7 @@ func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarG
|
||||
AvatarGuid: avatarGuid,
|
||||
Pos: freePos, // 应该是多人坐船时的位置?
|
||||
},
|
||||
EntityId: entity.id,
|
||||
EntityId: entity.GetId(),
|
||||
}
|
||||
g.SendMsg(cmd.VehicleInteractRsp, player.PlayerID, player.ClientSeq, vehicleInteractRsp)
|
||||
}
|
||||
@@ -150,17 +153,19 @@ func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarG
|
||||
// ExitVehicle 离开载具
|
||||
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)
|
||||
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
|
||||
}
|
||||
// 载具成员删除玩家
|
||||
var memberPos uint32
|
||||
for pos, p := range entity.gadgetEntity.gadgetVehicleEntity.memberMap {
|
||||
memberMap := gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()
|
||||
for pos, p := range memberMap {
|
||||
if p == player {
|
||||
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,
|
||||
Pos: memberPos, // 应该是多人坐船时的位置?
|
||||
},
|
||||
EntityId: entity.id,
|
||||
EntityId: entity.GetId(),
|
||||
}
|
||||
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)
|
||||
if entity == nil {
|
||||
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
|
||||
}
|
||||
// 判断实体类型是否为载具
|
||||
if entity.gadgetEntity == nil || entity.gadgetEntity.gadgetVehicleEntity == nil {
|
||||
logger.Error("vehicle entity error, entityType: %v", entity.entityType)
|
||||
g.CommonRetError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_GADGET_NOT_VEHICLE)
|
||||
gadgetEntity := entity.GetGadgetEntity()
|
||||
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
|
||||
logger.Error("vehicle entity error, entityType: %v", entity.GetEntityType())
|
||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_GADGET_NOT_VEHICLE)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -119,34 +119,34 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
||||
// 确保精炼的武器与精炼材料不是同一个
|
||||
if req.TargetWeaponGuid == req.ItemGuid {
|
||||
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
|
||||
}
|
||||
// 是否拥有武器
|
||||
weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取武器物品配置表
|
||||
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 摩拉数量是否足够
|
||||
if player.GetItemCount(constant.ItemConstantConst.SCOIN) < weaponConfig.AwakenCoinCostList[weapon.Refinement] {
|
||||
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
|
||||
}
|
||||
// 武器精炼等级是否不超过限制
|
||||
// 暂时精炼等级是写死的 应该最大精炼等级就是5级
|
||||
if weapon.Refinement >= 4 {
|
||||
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
|
||||
}
|
||||
// 获取精炼材料物品配置表
|
||||
@@ -154,7 +154,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
||||
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(player.GetItemIdByItemAndWeaponGuid(req.ItemGuid))]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 根据精炼材料的类型做不同操作
|
||||
@@ -165,13 +165,13 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
||||
foodWeapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.ItemGuid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 确保被精炼武器没有被任何角色装备
|
||||
if foodWeapon.AvatarId != 0 {
|
||||
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
|
||||
}
|
||||
// 消耗作为精炼材料的武器
|
||||
@@ -182,13 +182,13 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
||||
item, ok := player.ItemMap[player.GetItemIdByGuid(req.ItemGuid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 武器的精炼材料是否为这个
|
||||
if item.ItemId != uint32(weaponConfig.AwakenMaterial) {
|
||||
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
|
||||
}
|
||||
// 消耗作为精炼材料的道具
|
||||
@@ -200,7 +200,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
||||
})
|
||||
default:
|
||||
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
|
||||
}
|
||||
// 消耗摩拉
|
||||
@@ -252,41 +252,41 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
|
||||
weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取武器配置表
|
||||
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
|
||||
if !ok {
|
||||
logger.Error("weapon config error, itemId: %v", weapon.ItemId)
|
||||
g.CommonRetError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{})
|
||||
g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{})
|
||||
return
|
||||
}
|
||||
// 获取武器突破配置表
|
||||
weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取武器突破等级的配置表
|
||||
weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 武器等级是否达到限制
|
||||
if weapon.Level < uint8(weaponPromoteConfig.LevelLimit) {
|
||||
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
|
||||
}
|
||||
// 获取武器突破下一级的配置表
|
||||
weaponPromoteConfig, ok = weaponPromoteDataMap[int32(weapon.Promote+1)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 将被消耗的物品列表
|
||||
@@ -309,16 +309,16 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
|
||||
logger.Error("item count not enough, itemId: %v", item.ItemId)
|
||||
// 摩拉的错误提示与材料不同
|
||||
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
|
||||
}
|
||||
}
|
||||
// 冒险等级是否符合要求
|
||||
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])
|
||||
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
|
||||
}
|
||||
// 消耗突破材料和摩拉
|
||||
@@ -533,34 +533,34 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
||||
weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取武器配置表
|
||||
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
|
||||
if !ok {
|
||||
logger.Error("weapon config error, itemId: %v", weapon.ItemId)
|
||||
g.CommonRetError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
|
||||
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
|
||||
return
|
||||
}
|
||||
// 获取武器突破配置表
|
||||
weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 获取武器突破等级对应的配置表
|
||||
weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 武器等级是否达到限制
|
||||
if weapon.Level >= uint8(weaponPromoteConfig.LevelLimit) {
|
||||
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
|
||||
}
|
||||
// 将被消耗的物品列表
|
||||
@@ -576,7 +576,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
||||
expCount, coinCost, success := g.CalcWeaponUpgradeExpAndCoin(player, req.ItemParamList, req.FoodWeaponGuidList)
|
||||
if !success {
|
||||
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
|
||||
}
|
||||
// 消耗列表添加摩拉的消耗
|
||||
@@ -590,9 +590,9 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
||||
logger.Error("item count not enough, itemId: %v", item.ItemId)
|
||||
// 摩拉的错误提示与材料不同
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -602,7 +602,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
||||
foodWeapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(weaponGuid)]
|
||||
if !ok {
|
||||
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)
|
||||
}
|
||||
@@ -617,7 +617,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
||||
weaponLevel, weaponExp, returnItemList, success := g.CalcWeaponUpgrade(weapon, expCount)
|
||||
if !success {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -663,21 +663,21 @@ func (g *GameManager) CalcWeaponUpgradeReturnItemsReq(player *model.Player, payl
|
||||
weapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.TargetWeaponGuid)]
|
||||
if !ok {
|
||||
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
|
||||
}
|
||||
// 计算使用材料强化武器后将会获得的经验数
|
||||
expCount, _, success := g.CalcWeaponUpgradeExpAndCoin(player, req.ItemParamList, req.FoodWeaponGuidList)
|
||||
if !success {
|
||||
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
|
||||
}
|
||||
// 计算武器使用材料升级后的等级经验以及返回的矿石
|
||||
_, _, returnItemList, success := g.CalcWeaponUpgrade(weapon, expCount)
|
||||
if !success {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,10 @@ func NewTickManager() (r *TickManager) {
|
||||
return r
|
||||
}
|
||||
|
||||
func (t *TickManager) GetGlobalTick() *time.Ticker {
|
||||
return t.globalTick
|
||||
}
|
||||
|
||||
// 每个玩家自己的tick
|
||||
|
||||
// CreateUserGlobalTick 创建玩家tick对象
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -213,6 +213,14 @@ func (w *WorldManager) IsBigWorld(world *World) bool {
|
||||
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 {
|
||||
@@ -231,6 +239,14 @@ type World struct {
|
||||
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 {
|
||||
return w.playerMap
|
||||
}
|
||||
@@ -239,6 +255,18 @@ func (w *World) GetAllScene() map[uint32]*Scene {
|
||||
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 {
|
||||
for {
|
||||
w.entityIdCounter++
|
||||
@@ -353,6 +381,42 @@ type WorldAvatar struct {
|
||||
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 获取世界队伍的全部角色列表
|
||||
func (w *World) GetWorldAvatarList() []*WorldAvatar {
|
||||
worldAvatarList := make([]*WorldAvatar, 0)
|
||||
@@ -643,8 +707,24 @@ func (w *World) IsPlayerFirstEnter(player *model.Player) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *World) PlayerEnter(player *model.Player) {
|
||||
w.playerFirstEnterMap[player.PlayerID] = time.Now().UnixMilli()
|
||||
func (w *World) PlayerEnter(uid uint32) {
|
||||
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 {
|
||||
@@ -683,6 +763,14 @@ type Scene struct {
|
||||
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 {
|
||||
return s.playerMap
|
||||
}
|
||||
@@ -691,15 +779,39 @@ func (s *Scene) GetAllEntity() map[uint32]*Entity {
|
||||
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 {
|
||||
uid uint32
|
||||
avatarId uint32
|
||||
}
|
||||
|
||||
func (a *AvatarEntity) GetUid() uint32 {
|
||||
return a.uid
|
||||
}
|
||||
|
||||
func (a *AvatarEntity) GetAvatarId() uint32 {
|
||||
return a.avatarId
|
||||
}
|
||||
|
||||
type MonsterEntity struct {
|
||||
monsterId uint32
|
||||
}
|
||||
|
||||
func (m *MonsterEntity) GetMonsterId() uint32 {
|
||||
return m.monsterId
|
||||
}
|
||||
|
||||
type NpcEntity struct {
|
||||
NpcId uint32
|
||||
RoomId uint32
|
||||
@@ -723,10 +835,38 @@ type GadgetClientEntity struct {
|
||||
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 {
|
||||
gatherId uint32
|
||||
}
|
||||
|
||||
func (g *GadgetGatherEntity) GetGatherId() uint32 {
|
||||
return g.gatherId
|
||||
}
|
||||
|
||||
type GadgetVehicleEntity struct {
|
||||
vehicleId uint32
|
||||
owner *model.Player
|
||||
@@ -735,6 +875,30 @@ type GadgetVehicleEntity struct {
|
||||
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 {
|
||||
gadgetType int
|
||||
gadgetId uint32
|
||||
@@ -743,6 +907,26 @@ type GadgetEntity struct {
|
||||
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 {
|
||||
@@ -765,6 +949,78 @@ type Entity struct {
|
||||
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 {
|
||||
combatInvokeEntry *proto.CombatInvokeEntry
|
||||
uid uint32
|
||||
@@ -913,7 +1169,6 @@ func (s *Scene) CreateEntityWeapon() uint32 {
|
||||
lastMoveReliableSeq: 0,
|
||||
fightProp: nil,
|
||||
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_WEAPON),
|
||||
level: 0,
|
||||
}
|
||||
s.CreateEntity(entity, 0)
|
||||
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),
|
||||
},
|
||||
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_NPC),
|
||||
level: 0,
|
||||
npcEntity: &NpcEntity{
|
||||
NpcId: npcId,
|
||||
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),
|
||||
},
|
||||
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
|
||||
level: 0,
|
||||
gadgetEntity: &GadgetEntity{
|
||||
gadgetId: gadgetId,
|
||||
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),
|
||||
},
|
||||
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
|
||||
level: 0,
|
||||
gadgetEntity: &GadgetEntity{
|
||||
gadgetId: gadgetId,
|
||||
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),
|
||||
},
|
||||
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
|
||||
level: 0,
|
||||
gadgetEntity: &GadgetEntity{
|
||||
gadgetType: GADGET_TYPE_CLIENT,
|
||||
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),
|
||||
},
|
||||
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
|
||||
level: 0,
|
||||
gadgetEntity: &GadgetEntity{
|
||||
gadgetType: GADGET_TYPE_VEHICLE,
|
||||
gadgetVehicleEntity: &GadgetVehicleEntity{
|
||||
|
||||
@@ -78,8 +78,8 @@ func (a *AoiManager) AoiInfoLog(debug bool) {
|
||||
minGridObjectCount = gridObjectCount
|
||||
}
|
||||
if debug {
|
||||
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)
|
||||
// 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)
|
||||
for objectId, object := range grid.objectMap {
|
||||
logger.Debug("objectId: %v, object: %v", objectId, object)
|
||||
}
|
||||
|
||||
@@ -8,12 +8,13 @@ import (
|
||||
type Grid struct {
|
||||
gid uint32 // 格子id
|
||||
// 格子边界坐标
|
||||
minX int16
|
||||
maxX int16
|
||||
minY int16
|
||||
maxY int16
|
||||
minZ int16
|
||||
maxZ int16
|
||||
// 目前开发阶段暂时用不到 节省点内存
|
||||
// minX int16
|
||||
// maxX int16
|
||||
// minY int16
|
||||
// maxY int16
|
||||
// minZ int16
|
||||
// maxZ int16
|
||||
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) {
|
||||
r = new(Grid)
|
||||
r.gid = gid
|
||||
r.minX = minX
|
||||
r.maxX = maxX
|
||||
r.minY = minY
|
||||
r.maxY = maxY
|
||||
r.minZ = minZ
|
||||
r.maxZ = maxZ
|
||||
// r.minX = minX
|
||||
// r.maxX = maxX
|
||||
// r.minY = minY
|
||||
// r.maxY = maxY
|
||||
// r.minZ = minZ
|
||||
// r.maxZ = maxZ
|
||||
r.objectMap = make(map[int64]any)
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user