调整角色场景实体相关协议
This commit is contained in:
1 parent
346b583f64
commit
d8a3af9fc8
15 files changed
+245
-225
No files matched your search
@@ -300,7 +300,7 @@ func UpdateFrame(fileData []byte, basePos *model.Vector, rgb bool) {
|
|||||||
for _, v := range SCREEN_ENTITY_ID_LIST {
|
for _, v := range SCREEN_ENTITY_ID_LIST {
|
||||||
scene.DestroyEntity(v)
|
scene.DestroyEntity(v)
|
||||||
}
|
}
|
||||||
GAME.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, SCREEN_ENTITY_ID_LIST)
|
GAME.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, SCREEN_ENTITY_ID_LIST, 0)
|
||||||
SCREEN_ENTITY_ID_LIST = make([]uint32, 0)
|
SCREEN_ENTITY_ID_LIST = make([]uint32, 0)
|
||||||
leftTopPos := &model.Vector{
|
leftTopPos := &model.Vector{
|
||||||
X: basePos.X + float64(SCREEN_WIDTH)*SCREEN_DPI/2,
|
X: basePos.X + float64(SCREEN_WIDTH)*SCREEN_DPI/2,
|
||||||
|
|||||||
@@ -443,6 +443,13 @@ func (g *Game) SendToSceneA(scene *Scene, cmdId uint16, seq uint32, msg pb.Messa
|
|||||||
if aecUid == v.PlayerId {
|
if aecUid == v.PlayerId {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if SELF != nil {
|
||||||
|
p1 := g.GetPlayerPos(SELF)
|
||||||
|
p2 := g.GetPlayerPos(v)
|
||||||
|
if !g.IsInVision(p1, p2) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
g.SendMsg(cmdId, v.PlayerId, seq, msg)
|
g.SendMsg(cmdId, v.PlayerId, seq, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,6 +484,13 @@ func (g *Game) SendToSceneACV(scene *Scene, cmdId uint16, seq uint32, msg pb.Mes
|
|||||||
if v.ClientVersion != clientVersion {
|
if v.ClientVersion != clientVersion {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if SELF != nil {
|
||||||
|
p1 := g.GetPlayerPos(SELF)
|
||||||
|
p2 := g.GetPlayerPos(v)
|
||||||
|
if !g.IsInVision(p1, p2) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
g.SendMsg(cmdId, v.PlayerId, seq, msg)
|
g.SendMsg(cmdId, v.PlayerId, seq, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -486,6 +486,7 @@ func (g *GMCmd) GMUnlockAllOpenState(userId uint32) {
|
|||||||
|
|
||||||
// GMFreeMode 自由探索模式
|
// GMFreeMode 自由探索模式
|
||||||
func (g *GMCmd) GMFreeMode(userId uint32) {
|
func (g *GMCmd) GMFreeMode(userId uint32) {
|
||||||
|
GAME.LogoutPlayer(userId)
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -499,7 +500,10 @@ func (g *GMCmd) GMFreeMode(userId uint32) {
|
|||||||
player.PropMap[constant.PLAYER_PROP_PLAYER_CAN_DIVE] = 1
|
player.PropMap[constant.PLAYER_PROP_PLAYER_CAN_DIVE] = 1
|
||||||
player.PropMap[constant.PLAYER_PROP_DIVE_MAX_STAMINA] = 10000
|
player.PropMap[constant.PLAYER_PROP_DIVE_MAX_STAMINA] = 10000
|
||||||
player.PropMap[constant.PLAYER_PROP_DIVE_CUR_STAMINA] = 10000
|
player.PropMap[constant.PLAYER_PROP_DIVE_CUR_STAMINA] = 10000
|
||||||
GAME.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, GAME.PacketPlayerPropNotify(player))
|
g.GMUnlockAllOpenState(userId)
|
||||||
|
for _, sceneData := range gdconf.GetSceneDataMap() {
|
||||||
|
g.GMUnlockAllPoint(userId, uint32(sceneData.SceneId))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 系统级GM指令
|
// 系统级GM指令
|
||||||
@@ -609,9 +613,8 @@ func (g *GMCmd) CreateRobotInAiWorld(uid uint32, name string, avatarId uint32, p
|
|||||||
GAME.PostEnterSceneReq(robot, &proto.PostEnterSceneReq{
|
GAME.PostEnterSceneReq(robot, &proto.PostEnterSceneReq{
|
||||||
EnterSceneToken: aiWorld.GetEnterSceneToken(),
|
EnterSceneToken: aiWorld.GetEnterSceneToken(),
|
||||||
})
|
})
|
||||||
activeAvatarId := aiWorld.GetPlayerActiveAvatarId(robot)
|
|
||||||
entityMoveInfo := &proto.EntityMoveInfo{
|
entityMoveInfo := &proto.EntityMoveInfo{
|
||||||
EntityId: aiWorld.GetPlayerWorldAvatarEntityId(robot, activeAvatarId),
|
EntityId: aiWorld.GetPlayerActiveAvatarEntity(robot).GetId(),
|
||||||
MotionInfo: &proto.MotionInfo{
|
MotionInfo: &proto.MotionInfo{
|
||||||
Pos: &proto.Vector{X: float32(posX), Y: float32(posY), Z: float32(posZ)},
|
Pos: &proto.Vector{X: float32(posX), Y: float32(posY), Z: float32(posZ)},
|
||||||
Rot: &proto.Vector{X: float32(0.0), Y: float32(0.0), Z: float32(0.0)},
|
Rot: &proto.Vector{X: float32(0.0), Y: float32(0.0), Z: float32(0.0)},
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ func (p *PluginPubg) GlobalTickPubg() {
|
|||||||
GAME.handleEvtBeingHit(scenePlayer, scene, &proto.EvtBeingHitInfo{
|
GAME.handleEvtBeingHit(scenePlayer, scene, &proto.EvtBeingHitInfo{
|
||||||
AttackResult: &proto.AttackResult{
|
AttackResult: &proto.AttackResult{
|
||||||
AttackerId: 0,
|
AttackerId: 0,
|
||||||
DefenseId: world.GetPlayerWorldAvatarEntityId(scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer)),
|
DefenseId: world.GetPlayerActiveAvatarEntity(scenePlayer).GetId(),
|
||||||
Damage: PUBG_HP_LOST,
|
Damage: PUBG_HP_LOST,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -560,9 +560,10 @@ func (p *PluginPubg) PubgHit(scene *Scene, defAvatarEntityId uint32, atkAvatarEn
|
|||||||
}
|
}
|
||||||
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
|
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
|
||||||
AttackResult: &proto.AttackResult{
|
AttackResult: &proto.AttackResult{
|
||||||
AttackerId: atkAvatarEntity.GetId(),
|
AttackerId: atkAvatarEntity.GetId(),
|
||||||
DefenseId: defAvatarEntity.GetId(),
|
DefenseId: defAvatarEntity.GetId(),
|
||||||
Damage: dmg,
|
Damage: dmg,
|
||||||
|
DamageShield: dmg,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if attackResultTemplate == nil {
|
if attackResultTemplate == nil {
|
||||||
|
|||||||
@@ -210,6 +210,9 @@ func (w *WorldManager) GetMultiplayerWorldNum() uint32 {
|
|||||||
type EnterSceneContext struct {
|
type EnterSceneContext struct {
|
||||||
OldSceneId uint32
|
OldSceneId uint32
|
||||||
OldPos *model.Vector
|
OldPos *model.Vector
|
||||||
|
NewSceneId uint32
|
||||||
|
NewPos *model.Vector
|
||||||
|
NewRot *model.Vector
|
||||||
OldDungeonPointId uint32
|
OldDungeonPointId uint32
|
||||||
Uid uint32
|
Uid uint32
|
||||||
}
|
}
|
||||||
@@ -357,9 +360,10 @@ func (w *World) GetAiWorldAoi() *alg.AoiManager {
|
|||||||
return w.aiWorldAoi
|
return w.aiWorldAoi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *World) AddPlayer(player *model.Player, sceneId uint32) {
|
func (w *World) AddPlayer(player *model.Player) {
|
||||||
w.peerList = append(w.peerList, player)
|
w.peerList = append(w.peerList, player)
|
||||||
w.playerMap[player.PlayerId] = player
|
w.playerMap[player.PlayerId] = player
|
||||||
|
|
||||||
// 将玩家自身当前的队伍角色信息复制到世界的玩家本地队伍
|
// 将玩家自身当前的队伍角色信息复制到世界的玩家本地队伍
|
||||||
dbTeam := player.GetDbTeam()
|
dbTeam := player.GetDbTeam()
|
||||||
team := dbTeam.GetActiveTeam()
|
team := dbTeam.GetActiveTeam()
|
||||||
@@ -385,7 +389,8 @@ func (w *World) AddPlayer(player *model.Player, sceneId uint32) {
|
|||||||
w.SetPlayerAvatarIndex(worldPlayer, index)
|
w.SetPlayerAvatarIndex(worldPlayer, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scene := w.GetSceneById(sceneId)
|
|
||||||
|
scene := w.GetSceneById(player.SceneId)
|
||||||
scene.AddPlayer(player)
|
scene.AddPlayer(player)
|
||||||
w.InitPlayerTeamEntityId(player)
|
w.InitPlayerTeamEntityId(player)
|
||||||
}
|
}
|
||||||
@@ -518,8 +523,6 @@ func (w *World) UpdatePlayerWorldAvatar(player *model.Player) {
|
|||||||
if worldAvatar.avatarEntityId != 0 {
|
if worldAvatar.avatarEntityId != 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
scene.DestroyEntity(worldAvatar.avatarEntityId)
|
|
||||||
scene.DestroyEntity(worldAvatar.weaponEntityId)
|
|
||||||
worldAvatar.avatarEntityId = scene.CreateEntityAvatar(player, worldAvatar.avatarId)
|
worldAvatar.avatarEntityId = scene.CreateEntityAvatar(player, worldAvatar.avatarId)
|
||||||
worldAvatar.weaponEntityId = scene.CreateEntityWeapon(player.GetPos(), player.GetRot())
|
worldAvatar.weaponEntityId = scene.CreateEntityWeapon(player.GetPos(), player.GetRot())
|
||||||
}
|
}
|
||||||
@@ -594,6 +597,15 @@ func (w *World) GetPlayerActiveAvatarEntity(player *model.Player) *Entity {
|
|||||||
return entity
|
return entity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsPlayerActiveAvatarEntity 是否为玩家当前活跃角色场景实体
|
||||||
|
func (w *World) IsPlayerActiveAvatarEntity(player *model.Player, entityId uint32) bool {
|
||||||
|
entity := w.GetPlayerActiveAvatarEntity(player)
|
||||||
|
if entity == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return entity.GetId() == entityId
|
||||||
|
}
|
||||||
|
|
||||||
type MultiplayerTeam struct {
|
type MultiplayerTeam struct {
|
||||||
// key:uid value:玩家的本地队伍
|
// key:uid value:玩家的本地队伍
|
||||||
localTeamMap map[uint32][]*WorldAvatar
|
localTeamMap map[uint32][]*WorldAvatar
|
||||||
@@ -620,7 +632,7 @@ func (w *World) GetPlayerLocalTeam(player *model.Player) []*WorldAvatar {
|
|||||||
func (w *World) SetPlayerLocalTeam(player *model.Player, avatarIdList []uint32) {
|
func (w *World) SetPlayerLocalTeam(player *model.Player, avatarIdList []uint32) {
|
||||||
oldLocalTeam := w.multiplayerTeam.localTeamMap[player.PlayerId]
|
oldLocalTeam := w.multiplayerTeam.localTeamMap[player.PlayerId]
|
||||||
sameAvatarIdList := make([]uint32, 0)
|
sameAvatarIdList := make([]uint32, 0)
|
||||||
diffAvatarIdList := make([]uint32, 0)
|
addAvatarIdList := make([]uint32, 0)
|
||||||
for _, avatarId := range avatarIdList {
|
for _, avatarId := range avatarIdList {
|
||||||
exist := false
|
exist := false
|
||||||
for _, worldAvatar := range oldLocalTeam {
|
for _, worldAvatar := range oldLocalTeam {
|
||||||
@@ -631,7 +643,7 @@ func (w *World) SetPlayerLocalTeam(player *model.Player, avatarIdList []uint32)
|
|||||||
if exist {
|
if exist {
|
||||||
sameAvatarIdList = append(sameAvatarIdList, avatarId)
|
sameAvatarIdList = append(sameAvatarIdList, avatarId)
|
||||||
} else {
|
} else {
|
||||||
diffAvatarIdList = append(diffAvatarIdList, avatarId)
|
addAvatarIdList = append(addAvatarIdList, avatarId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newLocalTeam := make([]*WorldAvatar, len(avatarIdList))
|
newLocalTeam := make([]*WorldAvatar, len(avatarIdList))
|
||||||
@@ -648,7 +660,7 @@ func (w *World) SetPlayerLocalTeam(player *model.Player, avatarIdList []uint32)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, avatarId := range diffAvatarIdList {
|
for _, avatarId := range addAvatarIdList {
|
||||||
index := 0
|
index := 0
|
||||||
for i, v := range avatarIdList {
|
for i, v := range avatarIdList {
|
||||||
if avatarId == v {
|
if avatarId == v {
|
||||||
@@ -664,6 +676,19 @@ func (w *World) SetPlayerLocalTeam(player *model.Player, avatarIdList []uint32)
|
|||||||
modifierMap: make(map[uint32]*proto.AbilityAppliedModifier),
|
modifierMap: make(map[uint32]*proto.AbilityAppliedModifier),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scene := w.GetSceneById(player.SceneId)
|
||||||
|
for _, worldAvatar := range oldLocalTeam {
|
||||||
|
exist := false
|
||||||
|
for _, avatarId := range avatarIdList {
|
||||||
|
if worldAvatar.avatarId == avatarId {
|
||||||
|
exist = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !exist {
|
||||||
|
scene.DestroyEntity(worldAvatar.avatarEntityId)
|
||||||
|
scene.DestroyEntity(worldAvatar.weaponEntityId)
|
||||||
|
}
|
||||||
|
}
|
||||||
w.multiplayerTeam.localTeamMap[player.PlayerId] = newLocalTeam
|
w.multiplayerTeam.localTeamMap[player.PlayerId] = newLocalTeam
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -409,35 +409,54 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
|
|||||||
oldVisionEntityMap := g.GetVisionEntity(scene, oldPos)
|
oldVisionEntityMap := g.GetVisionEntity(scene, oldPos)
|
||||||
newVisionEntityMap := g.GetVisionEntity(scene, newPos)
|
newVisionEntityMap := g.GetVisionEntity(scene, newPos)
|
||||||
delEntityIdList := make([]uint32, 0)
|
delEntityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range oldVisionEntityMap {
|
for entityId := range oldVisionEntityMap {
|
||||||
_, exist = newVisionEntityMap[entityId]
|
_, exist = newVisionEntityMap[entityId]
|
||||||
if exist {
|
if exist {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// 旧有新没有的实体即为消失的
|
// 旧有新没有的实体即为消失的
|
||||||
delEntityIdList = append(delEntityIdList, entityId)
|
delEntityIdList = append(delEntityIdList, entityId)
|
||||||
}
|
}
|
||||||
addEntityIdList := make([]uint32, 0)
|
addEntityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range newVisionEntityMap {
|
for entityId := range newVisionEntityMap {
|
||||||
_, exist = oldVisionEntityMap[entityId]
|
_, exist = oldVisionEntityMap[entityId]
|
||||||
if exist {
|
if exist {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// 新有旧没有的实体即为出现的
|
// 新有旧没有的实体即为出现的
|
||||||
addEntityIdList = append(addEntityIdList, entityId)
|
addEntityIdList = append(addEntityIdList, entityId)
|
||||||
}
|
}
|
||||||
// 同步客户端消失和出现的场景实体
|
// 同步客户端消失和出现的场景实体
|
||||||
if len(delEntityIdList) > 0 {
|
if len(delEntityIdList) > 0 {
|
||||||
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
||||||
|
for _, delEntityId := range delEntityIdList {
|
||||||
|
entity := scene.GetEntity(delEntityId)
|
||||||
|
if entity.GetEntityType() != constant.ENTITY_TYPE_AVATAR {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
otherPlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
||||||
|
if otherPlayer == nil {
|
||||||
|
logger.Error("get player is nil, target uid: %v, uid: %v", entity.GetAvatarEntity().GetUid(), player.PlayerId)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MISS, []uint32{avatarEntityId})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(addEntityIdList) > 0 {
|
if len(addEntityIdList) > 0 {
|
||||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_MEET, addEntityIdList, false, false)
|
g.AddSceneEntityNotify(player, proto.VisionType_VISION_MEET, addEntityIdList, false, false)
|
||||||
|
for _, addEntityId := range addEntityIdList {
|
||||||
|
entity := scene.GetEntity(addEntityId)
|
||||||
|
if entity.GetEntityType() != constant.ENTITY_TYPE_AVATAR {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
otherPlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
||||||
|
if otherPlayer == nil {
|
||||||
|
logger.Error("get player is nil, target uid: %v, uid: %v", entity.GetAvatarEntity().GetUid(), player.PlayerId)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, player, scene.GetEntity(avatarEntityId).GetAvatarEntity().GetAvatarId())
|
||||||
|
g.AddSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MEET, []*proto.SceneEntityInfo{sceneEntityInfoAvatar})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 场景区域触发器检测
|
// 场景区域触发器检测
|
||||||
g.SceneRegionTriggerCheck(player, oldPos, newPos, avatarEntityId)
|
g.SceneRegionTriggerCheck(player, oldPos, newPos, avatarEntityId)
|
||||||
@@ -534,7 +553,7 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
|
|||||||
logger.Error("get player is nil, target uid: %v, uid: %v", otherPlayerId, player.PlayerId)
|
logger.Error("get player is nil, target uid: %v, uid: %v", otherPlayerId, player.PlayerId)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, player, world.GetPlayerActiveAvatarId(player))
|
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, player, activeAvatarId)
|
||||||
g.AddSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MEET, []*proto.SceneEntityInfo{sceneEntityInfoAvatar})
|
g.AddSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MEET, []*proto.SceneEntityInfo{sceneEntityInfoAvatar})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -550,7 +569,7 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
|
|||||||
newVisionEntityMap := g.GetVisionEntity(scene, newPos)
|
newVisionEntityMap := g.GetVisionEntity(scene, newPos)
|
||||||
delEntityIdList := make([]uint32, 0)
|
delEntityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range oldVisionEntityMap {
|
for entityId, entity := range oldVisionEntityMap {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
|
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, exist := newVisionEntityMap[entityId]
|
_, exist := newVisionEntityMap[entityId]
|
||||||
@@ -562,7 +581,7 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
|
|||||||
}
|
}
|
||||||
addEntityIdList := make([]uint32, 0)
|
addEntityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range newVisionEntityMap {
|
for entityId, entity := range newVisionEntityMap {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
|
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, exist := oldVisionEntityMap[entityId]
|
_, exist := oldVisionEntityMap[entityId]
|
||||||
@@ -946,10 +965,9 @@ func (g *Game) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.Message
|
|||||||
}
|
}
|
||||||
yawAngle := ntf.InitEulerAngles.Y
|
yawAngle := ntf.InitEulerAngles.Y
|
||||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
|
||||||
bulletPhysicsEngine.CreateRigidBody(
|
bulletPhysicsEngine.CreateRigidBody(
|
||||||
ntf.EntityId,
|
ntf.EntityId,
|
||||||
world.GetPlayerWorldAvatarEntityId(player, activeAvatarId),
|
world.GetPlayerActiveAvatarEntity(player).GetId(),
|
||||||
player.SceneId,
|
player.SceneId,
|
||||||
ntf.InitPos.X, ntf.InitPos.Y, ntf.InitPos.Z,
|
ntf.InitPos.X, ntf.InitPos.Y, ntf.InitPos.Z,
|
||||||
pitchAngle, yawAngle,
|
pitchAngle, yawAngle,
|
||||||
@@ -969,7 +987,7 @@ func (g *Game) EvtDestroyGadgetNotify(player *model.Player, payloadMsg pb.Messag
|
|||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
scene.DestroyEntity(ntf.EntityId)
|
scene.DestroyEntity(ntf.EntityId)
|
||||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{ntf.EntityId})
|
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{ntf.EntityId}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) EvtAiSyncSkillCdNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtAiSyncSkillCdNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ func (g *Game) SetPlayerBornDataReq(player *model.Player, payloadMsg pb.Message)
|
|||||||
|
|
||||||
// 创建世界
|
// 创建世界
|
||||||
world := WORLD_MANAGER.CreateWorld(player)
|
world := WORLD_MANAGER.CreateWorld(player)
|
||||||
world.AddPlayer(player, player.SceneId)
|
world.AddPlayer(player)
|
||||||
player.WorldId = world.GetId()
|
player.WorldId = world.GetId()
|
||||||
// 进入场景
|
// 进入场景
|
||||||
player.SceneJump = true
|
player.SceneJump = true
|
||||||
player.SceneLoadState = model.SceneNone
|
player.SceneLoadState = model.SceneNone
|
||||||
player.SceneEnterReason = uint32(proto.EnterReason_ENTER_REASON_LOGIN)
|
player.SceneEnterReason = uint32(proto.EnterReason_ENTER_REASON_LOGIN)
|
||||||
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_SELF))
|
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerEnterSceneNotifyLogin(player))
|
||||||
|
|
||||||
g.SendMsg(cmd.SetPlayerBornDataRsp, player.PlayerId, player.ClientSeq, new(proto.SetPlayerBornDataRsp))
|
g.SendMsg(cmd.SetPlayerBornDataRsp, player.PlayerId, player.ClientSeq, new(proto.SetPlayerBornDataRsp))
|
||||||
}
|
}
|
||||||
@@ -121,13 +121,13 @@ func (g *Game) OnLogin(userId uint32, clientSeq uint32, gateAppId string, player
|
|||||||
} else {
|
} else {
|
||||||
// 创建世界
|
// 创建世界
|
||||||
world := WORLD_MANAGER.CreateWorld(player)
|
world := WORLD_MANAGER.CreateWorld(player)
|
||||||
world.AddPlayer(player, player.SceneId)
|
world.AddPlayer(player)
|
||||||
player.WorldId = world.GetId()
|
player.WorldId = world.GetId()
|
||||||
// 进入场景
|
// 进入场景
|
||||||
player.SceneJump = true
|
player.SceneJump = true
|
||||||
player.SceneLoadState = model.SceneNone
|
player.SceneLoadState = model.SceneNone
|
||||||
player.SceneEnterReason = uint32(proto.EnterReason_ENTER_REASON_LOGIN)
|
player.SceneEnterReason = uint32(proto.EnterReason_ENTER_REASON_LOGIN)
|
||||||
g.SendMsg(cmd.PlayerEnterSceneNotify, userId, clientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_SELF))
|
g.SendMsg(cmd.PlayerEnterSceneNotify, userId, clientSeq, g.PacketPlayerEnterSceneNotifyLogin(player))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g.SendMsg(cmd.DoSetPlayerBornDataNotify, userId, clientSeq, new(proto.DoSetPlayerBornDataNotify))
|
g.SendMsg(cmd.DoSetPlayerBornDataNotify, userId, clientSeq, new(proto.DoSetPlayerBornDataNotify))
|
||||||
|
|||||||
@@ -180,12 +180,18 @@ func (g *Game) JoinOtherWorld(player *model.Player, hostPlayer *model.Player) {
|
|||||||
player.SetRot(hostPlayer.GetRot())
|
player.SetRot(hostPlayer.GetRot())
|
||||||
g.WorldAddPlayer(hostWorld, player)
|
g.WorldAddPlayer(hostWorld, player)
|
||||||
|
|
||||||
|
enterSceneToken := hostWorld.AddEnterSceneContext(&EnterSceneContext{
|
||||||
|
OldSceneId: 0,
|
||||||
|
Uid: player.PlayerId,
|
||||||
|
})
|
||||||
|
|
||||||
playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp(
|
playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp(
|
||||||
player,
|
player,
|
||||||
hostPlayer,
|
hostPlayer,
|
||||||
proto.EnterType_ENTER_OTHER,
|
proto.EnterType_ENTER_OTHER,
|
||||||
0,
|
hostPlayer.SceneId,
|
||||||
new(model.Vector),
|
hostPlayer.GetPos(),
|
||||||
|
enterSceneToken,
|
||||||
)
|
)
|
||||||
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, playerEnterSceneNotify)
|
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, playerEnterSceneNotify)
|
||||||
} else {
|
} else {
|
||||||
@@ -365,12 +371,23 @@ func (g *Game) HostEnterMpWorld(hostPlayer *model.Player) {
|
|||||||
|
|
||||||
pos := g.GetPlayerPos(hostPlayer)
|
pos := g.GetPlayerPos(hostPlayer)
|
||||||
|
|
||||||
|
enterSceneToken := world.AddEnterSceneContext(&EnterSceneContext{
|
||||||
|
OldSceneId: hostPlayer.SceneId,
|
||||||
|
OldPos: pos,
|
||||||
|
NewSceneId: hostPlayer.SceneId,
|
||||||
|
NewPos: hostPlayer.GetPos(),
|
||||||
|
NewRot: hostPlayer.GetRot(),
|
||||||
|
OldDungeonPointId: 0,
|
||||||
|
Uid: hostPlayer.PlayerId,
|
||||||
|
})
|
||||||
|
|
||||||
hostPlayerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp(
|
hostPlayerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp(
|
||||||
hostPlayer,
|
hostPlayer,
|
||||||
hostPlayer,
|
hostPlayer,
|
||||||
proto.EnterType_ENTER_GOTO,
|
proto.EnterType_ENTER_GOTO,
|
||||||
hostPlayer.SceneId,
|
hostPlayer.SceneId,
|
||||||
pos,
|
hostPlayer.GetPos(),
|
||||||
|
enterSceneToken,
|
||||||
)
|
)
|
||||||
g.SendMsg(cmd.PlayerEnterSceneNotify, hostPlayer.PlayerId, hostPlayer.ClientSeq, hostPlayerEnterSceneNotify)
|
g.SendMsg(cmd.PlayerEnterSceneNotify, hostPlayer.PlayerId, hostPlayer.ClientSeq, hostPlayerEnterSceneNotify)
|
||||||
}
|
}
|
||||||
@@ -407,7 +424,7 @@ func (g *Game) WorldAddPlayer(world *World, player *model.Player) {
|
|||||||
if exist {
|
if exist {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
world.AddPlayer(player, player.SceneId)
|
world.AddPlayer(player)
|
||||||
player.WorldId = world.GetId()
|
player.WorldId = world.GetId()
|
||||||
if world.IsMultiplayerWorld() && world.GetWorldPlayerNum() > 1 {
|
if world.IsMultiplayerWorld() && world.GetWorldPlayerNum() > 1 {
|
||||||
g.UpdateWorldPlayerInfo(world, player)
|
g.UpdateWorldPlayerInfo(world, player)
|
||||||
@@ -437,25 +454,23 @@ func (g *Game) WorldRemovePlayer(world *World, player *model.Player) {
|
|||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
|
||||||
|
// 清除玩家的载具
|
||||||
|
for vehicleId, entityId := range player.VehicleInfo.CreateEntityIdMap {
|
||||||
|
g.DestroyVehicleEntity(player, scene, vehicleId, entityId)
|
||||||
|
}
|
||||||
|
|
||||||
entityIdList := make([]uint32, 0)
|
entityIdList := make([]uint32, 0)
|
||||||
for _, entity := range g.GetVisionEntity(scene, g.GetPlayerPos(player)) {
|
for _, entity := range g.GetVisionEntity(scene, g.GetPlayerPos(player)) {
|
||||||
entityIdList = append(entityIdList, entity.GetId())
|
entityIdList = append(entityIdList, entity.GetId())
|
||||||
}
|
}
|
||||||
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, entityIdList)
|
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, entityIdList)
|
||||||
|
|
||||||
delTeamEntityNotify := g.PacketDelTeamEntityNotify(scene, player)
|
delTeamEntityNotify := g.PacketDelTeamEntityNotify(world, player)
|
||||||
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerId, player.ClientSeq, delTeamEntityNotify)
|
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerId, player.ClientSeq, delTeamEntityNotify)
|
||||||
|
|
||||||
// 清除其他玩家的载具
|
|
||||||
if world.GetOwner().PlayerId != player.PlayerId {
|
|
||||||
for vehicleId, entityId := range player.VehicleInfo.CreateEntityIdMap {
|
|
||||||
g.DestroyVehicleEntity(player, scene, vehicleId, entityId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if world.IsMultiplayerWorld() {
|
if world.IsMultiplayerWorld() {
|
||||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
activeAvatarEntity := world.GetPlayerActiveAvatarEntity(player)
|
||||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)})
|
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, []uint32{activeAvatarEntity.GetId()}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
world.RemovePlayer(player)
|
world.RemovePlayer(player)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func (g *Game) QuestDestroyEntityReq(player *model.Player, payloadMsg pb.Message
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
scene.DestroyEntity(req.EntityId)
|
scene.DestroyEntity(req.EntityId)
|
||||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId})
|
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId}, 0)
|
||||||
rsp := &proto.QuestDestroyEntityRsp{
|
rsp := &proto.QuestDestroyEntityRsp{
|
||||||
QuestId: req.QuestId,
|
QuestId: req.QuestId,
|
||||||
SceneId: req.SceneId,
|
SceneId: req.SceneId,
|
||||||
|
|||||||
+89
-79
@@ -53,19 +53,27 @@ func (g *Game) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ctx.OldSceneId != 0 {
|
if ctx.OldSceneId != 0 {
|
||||||
oldScene := world.GetSceneById(ctx.OldSceneId)
|
oldSceneId := ctx.OldSceneId
|
||||||
|
oldPos := ctx.OldPos
|
||||||
|
newSceneId := ctx.NewSceneId
|
||||||
|
newPos := ctx.NewPos
|
||||||
|
newRot := ctx.NewRot
|
||||||
|
|
||||||
|
oldScene := world.GetSceneById(oldSceneId)
|
||||||
|
newScene := world.GetSceneById(newSceneId)
|
||||||
|
|
||||||
delEntityIdList := make([]uint32, 0)
|
delEntityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range g.GetVisionEntity(oldScene, ctx.OldPos) {
|
for entityId := range g.GetVisionEntity(oldScene, oldPos) {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
delEntityIdList = append(delEntityIdList, entityId)
|
delEntityIdList = append(delEntityIdList, entityId)
|
||||||
}
|
}
|
||||||
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
||||||
|
|
||||||
|
activeAvatarEntity := world.GetPlayerActiveAvatarEntity(player)
|
||||||
|
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_REMOVE, []uint32{activeAvatarEntity.GetId()}, player.PlayerId)
|
||||||
|
|
||||||
if !WORLD_MANAGER.IsAiWorld(world) {
|
if !WORLD_MANAGER.IsAiWorld(world) {
|
||||||
// 卸载旧位置附近的group
|
// 卸载旧位置附近的group
|
||||||
for _, groupConfig := range g.GetNeighborGroup(ctx.OldSceneId, ctx.OldPos) {
|
for _, groupConfig := range g.GetNeighborGroup(oldSceneId, oldPos) {
|
||||||
if !world.IsMultiplayerWorld() {
|
if !world.IsMultiplayerWorld() {
|
||||||
// 单人世界直接卸载group
|
// 单人世界直接卸载group
|
||||||
g.RemoveSceneGroup(player, oldScene, groupConfig)
|
g.RemoveSceneGroup(player, oldScene, groupConfig)
|
||||||
@@ -93,6 +101,28 @@ func (g *Game) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.SceneLoadState = model.SceneNone
|
||||||
|
|
||||||
|
if player.SceneJump {
|
||||||
|
oldScene.RemovePlayer(player)
|
||||||
|
|
||||||
|
player.SetPos(newPos)
|
||||||
|
player.SetRot(newRot)
|
||||||
|
|
||||||
|
player.SceneId = newSceneId
|
||||||
|
newScene.AddPlayer(player)
|
||||||
|
} else {
|
||||||
|
player.SetPos(newPos)
|
||||||
|
player.SetRot(newRot)
|
||||||
|
|
||||||
|
for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) {
|
||||||
|
entityId := worldAvatar.GetAvatarEntityId()
|
||||||
|
entity := oldScene.GetEntity(entityId)
|
||||||
|
entity.SetPos(newPos)
|
||||||
|
entity.SetRot(newRot)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enterScenePeerNotify := &proto.EnterScenePeerNotify{
|
enterScenePeerNotify := &proto.EnterScenePeerNotify{
|
||||||
@@ -204,9 +234,8 @@ func (g *Game) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
}
|
}
|
||||||
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerId, player.ClientSeq, playerGameTimeNotify)
|
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerId, player.ClientSeq, playerGameTimeNotify)
|
||||||
|
|
||||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
|
||||||
playerEnterSceneInfoNotify := &proto.PlayerEnterSceneInfoNotify{
|
playerEnterSceneInfoNotify := &proto.PlayerEnterSceneInfoNotify{
|
||||||
CurAvatarEntityId: world.GetPlayerWorldAvatarEntityId(player, activeAvatarId),
|
CurAvatarEntityId: world.GetPlayerActiveAvatarEntity(player).GetId(),
|
||||||
EnterSceneToken: req.EnterSceneToken,
|
EnterSceneToken: req.EnterSceneToken,
|
||||||
TeamEnterInfo: &proto.TeamEnterSceneInfo{
|
TeamEnterInfo: &proto.TeamEnterSceneInfo{
|
||||||
TeamEntityId: world.GetPlayerTeamEntityId(player),
|
TeamEntityId: world.GetPlayerTeamEntityId(player),
|
||||||
@@ -336,17 +365,14 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
visionEntityMap := g.GetVisionEntity(scene, pos)
|
visionEntityMap := g.GetVisionEntity(scene, pos)
|
||||||
entityIdList := make([]uint32, 0)
|
entityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range visionEntityMap {
|
for entityId, entity := range visionEntityMap {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
|
if WORLD_MANAGER.IsAiWorld(world) {
|
||||||
continue
|
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
entityIdList = append(entityIdList, entityId)
|
entityIdList = append(entityIdList, entityId)
|
||||||
}
|
}
|
||||||
g.AddSceneEntityNotify(player, visionType, entityIdList, false, false)
|
g.AddSceneEntityNotify(player, visionType, entityIdList, false, false)
|
||||||
// 加载该场景的载具
|
|
||||||
if world.GetOwner().PlayerId == player.PlayerId {
|
|
||||||
vehicleEntityIdList := g.CreateSceneVehicle(scene)
|
|
||||||
g.AddSceneEntityNotify(player, visionType, vehicleEntityIdList, false, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
if WORLD_MANAGER.IsAiWorld(world) {
|
if WORLD_MANAGER.IsAiWorld(world) {
|
||||||
aiWorldAoi := world.GetAiWorldAoi()
|
aiWorldAoi := world.GetAiWorldAoi()
|
||||||
@@ -502,7 +528,7 @@ func (g *Game) RemoveSceneEntityNotifyToPlayer(player *model.Player, visionType
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveSceneEntityNotifyBroadcast 移除的场景实体广播
|
// RemoveSceneEntityNotifyBroadcast 移除的场景实体广播
|
||||||
func (g *Game) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32) {
|
func (g *Game) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32, aecUid uint32) {
|
||||||
ntf := &proto.SceneEntityDisappearNotify{
|
ntf := &proto.SceneEntityDisappearNotify{
|
||||||
EntityList: entityIdList,
|
EntityList: entityIdList,
|
||||||
DisappearType: visionType,
|
DisappearType: visionType,
|
||||||
@@ -510,7 +536,7 @@ func (g *Game) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.V
|
|||||||
world := scene.GetWorld()
|
world := scene.GetWorld()
|
||||||
owner := world.GetOwner()
|
owner := world.GetOwner()
|
||||||
// logger.Debug("[SceneEntityDisappearNotify BC], type: %v, len: %v, uid: %v", ntf.DisappearType, len(ntf.EntityList), owner.PlayerId)
|
// logger.Debug("[SceneEntityDisappearNotify BC], type: %v, len: %v, uid: %v", ntf.DisappearType, len(ntf.EntityList), owner.PlayerId)
|
||||||
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, owner.ClientSeq, ntf, 0)
|
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, owner.ClientSeq, ntf, aecUid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddSceneEntityNotify 添加的场景实体同步 封装接口
|
// AddSceneEntityNotify 添加的场景实体同步 封装接口
|
||||||
@@ -537,17 +563,11 @@ func (g *Game) AddSceneEntityNotify(player *model.Player, visionType proto.Visio
|
|||||||
}
|
}
|
||||||
switch entity.GetEntityType() {
|
switch entity.GetEntityType() {
|
||||||
case constant.ENTITY_TYPE_AVATAR:
|
case constant.ENTITY_TYPE_AVATAR:
|
||||||
if visionType == proto.VisionType_VISION_MEET && entity.GetAvatarEntity().GetUid() == player.PlayerId {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
||||||
if scenePlayer == nil {
|
if scenePlayer == nil {
|
||||||
logger.Error("get scene player is nil, world id: %v, scene id: %v", world.GetId(), scene.GetId())
|
logger.Error("get scene player is nil, world id: %v, scene id: %v", world.GetId(), scene.GetId())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if entity.GetAvatarEntity().GetAvatarId() != world.GetPlayerActiveAvatarId(scenePlayer) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
|
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
|
||||||
entityList = append(entityList, sceneEntityInfoAvatar)
|
entityList = append(entityList, sceneEntityInfoAvatar)
|
||||||
case constant.ENTITY_TYPE_MONSTER:
|
case constant.ENTITY_TYPE_MONSTER:
|
||||||
@@ -694,7 +714,7 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
|
|||||||
|
|
||||||
// 删除实体
|
// 删除实体
|
||||||
g.EntityFightPropUpdateNotifyBroadcast(scene, entity)
|
g.EntityFightPropUpdateNotifyBroadcast(scene, entity)
|
||||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.GetId()})
|
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.GetId()}, 0)
|
||||||
scene.DestroyEntity(entity.GetId())
|
scene.DestroyEntity(entity.GetId())
|
||||||
group := scene.GetGroupById(entity.GetGroupId())
|
group := scene.GetGroupById(entity.GetGroupId())
|
||||||
if group == nil {
|
if group == nil {
|
||||||
@@ -770,15 +790,20 @@ func (g *Game) GetVisionEntity(scene *Scene, pos *model.Vector) map[uint32]*Enti
|
|||||||
ratio := float32(ENTITY_VISION_DISTANCE*ENTITY_VISION_DISTANCE) / float32(GROUP_LOAD_DISTANCE*GROUP_LOAD_DISTANCE)
|
ratio := float32(ENTITY_VISION_DISTANCE*ENTITY_VISION_DISTANCE) / float32(GROUP_LOAD_DISTANCE*GROUP_LOAD_DISTANCE)
|
||||||
visionEntity := make(map[uint32]*Entity, int(float32(len(allEntityMap))*ratio))
|
visionEntity := make(map[uint32]*Entity, int(float32(len(allEntityMap))*ratio))
|
||||||
for _, entity := range allEntityMap {
|
for _, entity := range allEntityMap {
|
||||||
dx := int32(pos.X) - int32(entity.GetPos().X)
|
if !g.IsInVision(pos, entity.GetPos()) {
|
||||||
if dx < 0 {
|
continue
|
||||||
dx *= -1
|
|
||||||
}
|
}
|
||||||
dy := int32(pos.Z) - int32(entity.GetPos().Z)
|
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
||||||
if dy < 0 {
|
scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
||||||
dy *= -1
|
if scenePlayer == nil {
|
||||||
|
logger.Error("get scene player is nil, target uid: %v", entity.GetAvatarEntity().GetUid())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !scene.GetWorld().IsPlayerActiveAvatarEntity(scenePlayer, entity.GetId()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if dx > ENTITY_VISION_DISTANCE || dy > ENTITY_VISION_DISTANCE {
|
if entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
visionEntity[entity.GetId()] = entity
|
visionEntity[entity.GetId()] = entity
|
||||||
@@ -786,25 +811,19 @@ func (g *Game) GetVisionEntity(scene *Scene, pos *model.Vector) map[uint32]*Enti
|
|||||||
return visionEntity
|
return visionEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSceneVehicle 创建场景内的载具
|
func (g *Game) IsInVision(p1 *model.Vector, p2 *model.Vector) bool {
|
||||||
func (g *Game) CreateSceneVehicle(scene *Scene) []uint32 {
|
dx := int32(p1.X) - int32(p2.X)
|
||||||
world := scene.GetWorld()
|
if dx < 0 {
|
||||||
owner := world.GetOwner()
|
dx *= -1
|
||||||
dbWorld := owner.GetDbWorld()
|
|
||||||
dbScene := dbWorld.GetSceneById(scene.GetId())
|
|
||||||
entityIdList := make([]uint32, 0, len(dbScene.VehicleMap))
|
|
||||||
for _, vehicle := range dbScene.VehicleMap {
|
|
||||||
// 创建载具
|
|
||||||
entityId := scene.CreateEntityGadgetVehicle(vehicle.OwnerUid, vehicle.Pos, vehicle.Rot, vehicle.VehicleId)
|
|
||||||
if entityId == 0 {
|
|
||||||
logger.Error("create vehicle error, sceneId: %v", dbScene.SceneId)
|
|
||||||
return entityIdList
|
|
||||||
}
|
|
||||||
entityIdList = append(entityIdList, entityId)
|
|
||||||
// 记录数据
|
|
||||||
owner.VehicleInfo.CreateEntityIdMap[vehicle.VehicleId] = entityId
|
|
||||||
}
|
}
|
||||||
return entityIdList
|
dy := int32(p1.Z) - int32(p2.Z)
|
||||||
|
if dy < 0 {
|
||||||
|
dy *= -1
|
||||||
|
}
|
||||||
|
if dx > ENTITY_VISION_DISTANCE || dy > ENTITY_VISION_DISTANCE {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNeighborGroup 获取某位置附近的场景组
|
// GetNeighborGroup 获取某位置附近的场景组
|
||||||
@@ -1364,7 +1383,7 @@ func (g *Game) SetPlayerWeather(player *model.Player, weatherAreaId uint32, clim
|
|||||||
|
|
||||||
var SceneTransactionSeq uint32 = 0
|
var SceneTransactionSeq uint32 = 0
|
||||||
|
|
||||||
func (g *Game) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
|
func (g *Game) PacketPlayerEnterSceneNotifyLogin(player *model.Player) *proto.PlayerEnterSceneNotify {
|
||||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||||
@@ -1380,7 +1399,7 @@ func (g *Game) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType
|
|||||||
SceneId: player.SceneId,
|
SceneId: player.SceneId,
|
||||||
Pos: &proto.Vector{X: float32(pos.X), Y: float32(pos.Y), Z: float32(pos.Z)},
|
Pos: &proto.Vector{X: float32(pos.X), Y: float32(pos.Y), Z: float32(pos.Z)},
|
||||||
SceneBeginTime: uint64(scene.GetSceneCreateTime()),
|
SceneBeginTime: uint64(scene.GetSceneCreateTime()),
|
||||||
Type: enterType,
|
Type: proto.EnterType_ENTER_SELF,
|
||||||
TargetUid: player.PlayerId,
|
TargetUid: player.PlayerId,
|
||||||
EnterSceneToken: enterSceneToken,
|
EnterSceneToken: enterSceneToken,
|
||||||
WorldLevel: player.PropMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
|
WorldLevel: player.PropMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
|
||||||
@@ -1405,32 +1424,33 @@ func (g *Game) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType
|
|||||||
func (g *Game) PacketPlayerEnterSceneNotifyTp(
|
func (g *Game) PacketPlayerEnterSceneNotifyTp(
|
||||||
player *model.Player,
|
player *model.Player,
|
||||||
enterType proto.EnterType,
|
enterType proto.EnterType,
|
||||||
prevSceneId uint32,
|
sceneId uint32,
|
||||||
prevPos *model.Vector,
|
pos *model.Vector,
|
||||||
dungeonId uint32,
|
dungeonId uint32,
|
||||||
dungeonPointId uint32,
|
enterSceneToken uint32,
|
||||||
) *proto.PlayerEnterSceneNotify {
|
) *proto.PlayerEnterSceneNotify {
|
||||||
return g.PacketPlayerEnterSceneNotifyCore(player, player, enterType, prevSceneId, prevPos, dungeonId, dungeonPointId)
|
return g.PacketPlayerEnterSceneNotifyCore(player, player, enterType, sceneId, pos, dungeonId, enterSceneToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) PacketPlayerEnterSceneNotifyMp(
|
func (g *Game) PacketPlayerEnterSceneNotifyMp(
|
||||||
player *model.Player,
|
player *model.Player,
|
||||||
targetPlayer *model.Player,
|
targetPlayer *model.Player,
|
||||||
enterType proto.EnterType,
|
enterType proto.EnterType,
|
||||||
prevSceneId uint32,
|
sceneId uint32,
|
||||||
prevPos *model.Vector,
|
pos *model.Vector,
|
||||||
|
enterSceneToken uint32,
|
||||||
) *proto.PlayerEnterSceneNotify {
|
) *proto.PlayerEnterSceneNotify {
|
||||||
return g.PacketPlayerEnterSceneNotifyCore(player, targetPlayer, enterType, prevSceneId, prevPos, 0, 0)
|
return g.PacketPlayerEnterSceneNotifyCore(player, targetPlayer, enterType, sceneId, pos, 0, enterSceneToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) PacketPlayerEnterSceneNotifyCore(
|
func (g *Game) PacketPlayerEnterSceneNotifyCore(
|
||||||
player *model.Player,
|
player *model.Player,
|
||||||
targetPlayer *model.Player,
|
targetPlayer *model.Player,
|
||||||
enterType proto.EnterType,
|
enterType proto.EnterType,
|
||||||
prevSceneId uint32,
|
sceneId uint32,
|
||||||
prevPos *model.Vector,
|
pos *model.Vector,
|
||||||
dungeonId uint32,
|
dungeonId uint32,
|
||||||
dungeonPointId uint32,
|
enterSceneToken uint32,
|
||||||
) *proto.PlayerEnterSceneNotify {
|
) *proto.PlayerEnterSceneNotify {
|
||||||
world := WORLD_MANAGER.GetWorldById(targetPlayer.WorldId)
|
world := WORLD_MANAGER.GetWorldById(targetPlayer.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
@@ -1438,21 +1458,11 @@ func (g *Game) PacketPlayerEnterSceneNotifyCore(
|
|||||||
return new(proto.PlayerEnterSceneNotify)
|
return new(proto.PlayerEnterSceneNotify)
|
||||||
}
|
}
|
||||||
scene := world.GetSceneById(targetPlayer.SceneId)
|
scene := world.GetSceneById(targetPlayer.SceneId)
|
||||||
enterSceneToken := world.AddEnterSceneContext(&EnterSceneContext{
|
|
||||||
OldSceneId: prevSceneId,
|
|
||||||
OldPos: &model.Vector{
|
|
||||||
X: prevPos.X,
|
|
||||||
Y: prevPos.Y,
|
|
||||||
Z: prevPos.Z,
|
|
||||||
},
|
|
||||||
OldDungeonPointId: dungeonPointId,
|
|
||||||
Uid: player.PlayerId,
|
|
||||||
})
|
|
||||||
playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
|
playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
|
||||||
PrevSceneId: prevSceneId,
|
PrevSceneId: player.SceneId,
|
||||||
PrevPos: &proto.Vector{X: float32(prevPos.X), Y: float32(prevPos.Y), Z: float32(prevPos.Z)},
|
PrevPos: &proto.Vector{X: float32(player.GetPos().X), Y: float32(player.GetPos().Y), Z: float32(player.GetPos().Z)},
|
||||||
SceneId: targetPlayer.SceneId,
|
SceneId: sceneId,
|
||||||
Pos: &proto.Vector{X: float32(targetPlayer.GetPos().X), Y: float32(targetPlayer.GetPos().Y), Z: float32(targetPlayer.GetPos().Z)},
|
Pos: &proto.Vector{X: float32(pos.X), Y: float32(pos.Y), Z: float32(pos.Z)},
|
||||||
SceneBeginTime: uint64(scene.GetSceneCreateTime()),
|
SceneBeginTime: uint64(scene.GetSceneCreateTime()),
|
||||||
Type: enterType,
|
Type: enterType,
|
||||||
TargetUid: targetPlayer.PlayerId,
|
TargetUid: targetPlayer.PlayerId,
|
||||||
@@ -1464,12 +1474,12 @@ func (g *Game) PacketPlayerEnterSceneNotifyCore(
|
|||||||
SceneTagIdList: make([]uint32, 0),
|
SceneTagIdList: make([]uint32, 0),
|
||||||
}
|
}
|
||||||
SceneTransactionSeq++
|
SceneTransactionSeq++
|
||||||
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(targetPlayer.SceneId)) + "-" +
|
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(sceneId)) + "-" +
|
||||||
strconv.Itoa(int(player.PlayerId)) + "-" +
|
strconv.Itoa(int(player.PlayerId)) + "-" +
|
||||||
strconv.Itoa(int(time.Now().Unix())) + "-" +
|
strconv.Itoa(int(time.Now().Unix())) + "-" +
|
||||||
strconv.Itoa(int(SceneTransactionSeq))
|
strconv.Itoa(int(SceneTransactionSeq))
|
||||||
for _, sceneTagDataConfig := range gdconf.GetSceneTagDataMap() {
|
for _, sceneTagDataConfig := range gdconf.GetSceneTagDataMap() {
|
||||||
if uint32(sceneTagDataConfig.SceneId) == targetPlayer.SceneId {
|
if uint32(sceneTagDataConfig.SceneId) == sceneId {
|
||||||
playerEnterSceneNotify.SceneTagIdList = append(playerEnterSceneNotify.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
|
playerEnterSceneNotify.SceneTagIdList = append(playerEnterSceneNotify.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1860,10 +1870,10 @@ func (g *Game) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVehicleEn
|
|||||||
return sceneGadgetInfo
|
return sceneGadgetInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify {
|
func (g *Game) PacketDelTeamEntityNotify(world *World, player *model.Player) *proto.DelTeamEntityNotify {
|
||||||
delTeamEntityNotify := &proto.DelTeamEntityNotify{
|
delTeamEntityNotify := &proto.DelTeamEntityNotify{
|
||||||
SceneId: player.SceneId,
|
SceneId: player.SceneId,
|
||||||
DelEntityIdList: []uint32{scene.GetWorld().GetPlayerTeamEntityId(player)},
|
DelEntityIdList: []uint32{world.GetPlayerTeamEntityId(player)},
|
||||||
}
|
}
|
||||||
return delTeamEntityNotify
|
return delTeamEntityNotify
|
||||||
}
|
}
|
||||||
@@ -222,13 +222,8 @@ func (g *Game) VehicleRestoreStaminaHandler(player *model.Player) {
|
|||||||
if entity == nil {
|
if entity == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 确保实体类型是否为载具
|
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
|
||||||
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// 判断玩家处于载具中
|
// 判断玩家处于载具中
|
||||||
if g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
if g.IsPlayerInVehicle(player, entity) {
|
||||||
// 角色回复耐力
|
// 角色回复耐力
|
||||||
g.UpdatePlayerStamina(player, constant.STAMINA_COST_IN_SKIFF)
|
g.UpdatePlayerStamina(player, constant.STAMINA_COST_IN_SKIFF)
|
||||||
} else {
|
} else {
|
||||||
@@ -257,8 +252,7 @@ func (g *Game) SustainStaminaHandler(player *model.Player) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力
|
// 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
if g.IsPlayerInVehicle(player, entity) {
|
||||||
if gadgetEntity != nil && gadgetEntity.GetGadgetVehicleEntity() != nil && g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
|
||||||
// 更新载具耐力
|
// 更新载具耐力
|
||||||
g.UpdateVehicleStamina(player, entity, player.StaminaInfo.CostStamina)
|
g.UpdateVehicleStamina(player, entity, player.StaminaInfo.CostStamina)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -270,8 +270,7 @@ func (g *Game) ChangeAvatar(player *model.Player, targetAvatarId uint32) {
|
|||||||
}
|
}
|
||||||
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
|
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
|
||||||
|
|
||||||
newAvatarId := world.GetPlayerActiveAvatarId(player)
|
newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, targetAvatarId)
|
||||||
newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarId)
|
|
||||||
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
||||||
AppearType: proto.VisionType_VISION_REPLACE,
|
AppearType: proto.VisionType_VISION_REPLACE,
|
||||||
Param: oldAvatarEntity.GetId(),
|
Param: oldAvatarEntity.GetId(),
|
||||||
@@ -357,8 +356,8 @@ func (g *Game) PacketSceneTeamUpdateNotify(world *World, player *model.Player) *
|
|||||||
SceneEntityInfo: g.PacketSceneEntityInfoAvatar(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId()),
|
SceneEntityInfo: g.PacketSceneEntityInfoAvatar(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId()),
|
||||||
WeaponGuid: worldPlayerAvatar.EquipWeapon.Guid,
|
WeaponGuid: worldPlayerAvatar.EquipWeapon.Guid,
|
||||||
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(worldPlayer, worldAvatar.GetAvatarId()),
|
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(worldPlayer, worldAvatar.GetAvatarId()),
|
||||||
IsPlayerCurAvatar: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.GetAvatarId(),
|
IsPlayerCurAvatar: world.IsPlayerActiveAvatarEntity(worldPlayer, worldAvatar.GetAvatarEntityId()),
|
||||||
IsOnScene: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.GetAvatarId(),
|
IsOnScene: world.IsPlayerActiveAvatarEntity(worldPlayer, worldAvatar.GetAvatarEntityId()),
|
||||||
AvatarAbilityInfo: &proto.AbilitySyncStateInfo{
|
AvatarAbilityInfo: &proto.AbilitySyncStateInfo{
|
||||||
IsInited: len(worldAvatar.GetAbilityList()) != 0,
|
IsInited: len(worldAvatar.GetAbilityList()) != 0,
|
||||||
DynamicValueMap: nil,
|
DynamicValueMap: nil,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package game
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"hk4e/common/constant"
|
||||||
"hk4e/gdconf"
|
"hk4e/gdconf"
|
||||||
"hk4e/gs/model"
|
"hk4e/gs/model"
|
||||||
"hk4e/pkg/logger"
|
"hk4e/pkg/logger"
|
||||||
@@ -56,13 +57,6 @@ func (g *Game) CreateVehicleReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
// 记录创建的载具信息
|
// 记录创建的载具信息
|
||||||
player.VehicleInfo.CreateEntityIdMap[req.VehicleId] = entityId
|
player.VehicleInfo.CreateEntityIdMap[req.VehicleId] = entityId
|
||||||
player.VehicleInfo.LastCreateTime = time.Now().UnixMilli()
|
player.VehicleInfo.LastCreateTime = time.Now().UnixMilli()
|
||||||
// 记录房主的载具位置
|
|
||||||
owner := world.GetOwner()
|
|
||||||
if owner == player {
|
|
||||||
dbWorld := owner.GetDbWorld()
|
|
||||||
dbScene := dbWorld.GetSceneById(scene.GetId())
|
|
||||||
dbScene.AddVehicle(req.VehicleId, player.PlayerId, pos, rot)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PacketCreateVehicleRsp
|
// PacketCreateVehicleRsp
|
||||||
createVehicleRsp := &proto.CreateVehicleRsp{
|
createVehicleRsp := &proto.CreateVehicleRsp{
|
||||||
@@ -132,7 +126,11 @@ func (g *Game) VehicleDestroyMotion(player *model.Player, entity *Entity, state
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsPlayerInVehicle 判断玩家是否在载具中
|
// IsPlayerInVehicle 判断玩家是否在载具中
|
||||||
func (g *Game) IsPlayerInVehicle(player *model.Player, gadgetVehicleEntity *GadgetVehicleEntity) bool {
|
func (g *Game) IsPlayerInVehicle(player *model.Player, entity *Entity) bool {
|
||||||
|
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
gadgetVehicleEntity := entity.GetGadgetEntity().GetGadgetVehicleEntity()
|
||||||
if gadgetVehicleEntity == nil {
|
if gadgetVehicleEntity == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -165,7 +163,7 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 如果玩家正在载具中
|
// 如果玩家正在载具中
|
||||||
if g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
if g.IsPlayerInVehicle(player, entity) {
|
||||||
// 离开载具
|
// 离开载具
|
||||||
dbTeam := player.GetDbTeam()
|
dbTeam := player.GetDbTeam()
|
||||||
dbAvatar := player.GetDbAvatar()
|
dbAvatar := player.GetDbAvatar()
|
||||||
@@ -173,18 +171,9 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
|
|||||||
}
|
}
|
||||||
// 删除已创建的载具
|
// 删除已创建的载具
|
||||||
scene.DestroyEntity(entity.GetId())
|
scene.DestroyEntity(entity.GetId())
|
||||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.GetId()})
|
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.GetId()}, 0)
|
||||||
// 删除玩家载具在线数据
|
// 删除玩家载具在线数据
|
||||||
delete(player.VehicleInfo.CreateEntityIdMap, vehicleId)
|
delete(player.VehicleInfo.CreateEntityIdMap, vehicleId)
|
||||||
// 删除房主的载具存档
|
|
||||||
world := scene.GetWorld()
|
|
||||||
owner := world.GetOwner()
|
|
||||||
if owner == player {
|
|
||||||
dbWorld := owner.GetDbWorld()
|
|
||||||
dbScene := dbWorld.GetSceneById(scene.GetId())
|
|
||||||
delete(dbScene.VehicleMap, vehicleId)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnterVehicle 进入载具
|
// EnterVehicle 进入载具
|
||||||
@@ -235,7 +224,7 @@ func (g *Game) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uin
|
|||||||
func (g *Game) ExitVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
func (g *Game) ExitVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
||||||
// 玩家是否进入载具
|
// 玩家是否进入载具
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetEntity := entity.GetGadgetEntity()
|
||||||
if !g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
if !g.IsPlayerInVehicle(player, entity) {
|
||||||
logger.Error("vehicle not has player, uid: %v", player.PlayerId)
|
logger.Error("vehicle not has player, uid: %v", player.PlayerId)
|
||||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_NOT_IN_VEHICLE)
|
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_NOT_IN_VEHICLE)
|
||||||
return
|
return
|
||||||
|
|||||||
+18
-46
@@ -728,7 +728,7 @@ func (g *Game) TeleportPlayer(
|
|||||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if WORLD_MANAGER.IsAiWorld(world) && player.CmdPerm != uint8(CommandPermGM) {
|
if WORLD_MANAGER.IsAiWorld(world) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,65 +737,37 @@ func (g *Game) TeleportPlayer(
|
|||||||
newSceneId := sceneId
|
newSceneId := sceneId
|
||||||
newPos := pos
|
newPos := pos
|
||||||
newRot := rot
|
newRot := rot
|
||||||
jumpScene := false
|
|
||||||
if newSceneId != oldSceneId {
|
|
||||||
jumpScene = true
|
|
||||||
}
|
|
||||||
|
|
||||||
player.SceneJump = jumpScene
|
|
||||||
|
|
||||||
activeAvatarEntity := world.GetPlayerActiveAvatarEntity(player)
|
|
||||||
oldScene := world.GetSceneById(oldSceneId)
|
|
||||||
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_REMOVE, []uint32{activeAvatarEntity.GetId()})
|
|
||||||
|
|
||||||
if WORLD_MANAGER.IsAiWorld(world) {
|
|
||||||
aiWorldAoi := world.GetAiWorldAoi()
|
|
||||||
logger.Debug("ai world aoi remove player, oldPos: %+v, uid: %v", oldPos, player.PlayerId)
|
|
||||||
ok := aiWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(oldPos.X), float32(oldPos.Y), float32(oldPos.Z))
|
|
||||||
if !ok {
|
|
||||||
logger.Error("ai world aoi remove player fail, uid: %v, pos: %+v", player.PlayerId, oldPos)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var enterType proto.EnterType
|
var enterType proto.EnterType
|
||||||
if jumpScene {
|
if newSceneId != oldSceneId {
|
||||||
delTeamEntityNotify := g.PacketDelTeamEntityNotify(oldScene, player)
|
player.SceneJump = true
|
||||||
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerId, player.ClientSeq, delTeamEntityNotify)
|
|
||||||
|
|
||||||
oldScene.RemovePlayer(player)
|
|
||||||
|
|
||||||
player.SceneLoadState = model.SceneNone
|
|
||||||
player.SetPos(newPos)
|
|
||||||
player.SetRot(newRot)
|
|
||||||
|
|
||||||
player.SceneId = newSceneId
|
|
||||||
newScene := world.GetSceneById(newSceneId)
|
|
||||||
newScene.AddPlayer(player)
|
|
||||||
|
|
||||||
logger.Debug("player jump scene, scene: %v, pos: %v", player.SceneId, newPos)
|
logger.Debug("player jump scene, scene: %v, pos: %v", player.SceneId, newPos)
|
||||||
enterType = proto.EnterType_ENTER_JUMP
|
enterType = proto.EnterType_ENTER_JUMP
|
||||||
if enterReason == proto.EnterReason_ENTER_REASON_DUNGEON_ENTER {
|
if enterReason == proto.EnterReason_ENTER_REASON_DUNGEON_ENTER {
|
||||||
logger.Debug("player tp to dungeon scene, sceneId: %v, pos: %v", player.SceneId, newPos)
|
logger.Debug("player tp to dungeon scene, sceneId: %v, pos: %v", player.SceneId, newPos)
|
||||||
enterType = proto.EnterType_ENTER_DUNGEON
|
enterType = proto.EnterType_ENTER_DUNGEON
|
||||||
}
|
}
|
||||||
|
delTeamEntityNotify := g.PacketDelTeamEntityNotify(world, player)
|
||||||
|
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerId, player.ClientSeq, delTeamEntityNotify)
|
||||||
} else {
|
} else {
|
||||||
player.SceneLoadState = model.SceneNone
|
player.SceneJump = false
|
||||||
player.SetPos(newPos)
|
|
||||||
player.SetRot(newRot)
|
|
||||||
|
|
||||||
for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) {
|
|
||||||
entityId := worldAvatar.GetAvatarEntityId()
|
|
||||||
entity := oldScene.GetEntity(entityId)
|
|
||||||
entity.SetPos(newPos)
|
|
||||||
entity.SetRot(newRot)
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Debug("player goto scene, scene: %v, pos: %v", player.SceneId, newPos)
|
logger.Debug("player goto scene, scene: %v, pos: %v", player.SceneId, newPos)
|
||||||
enterType = proto.EnterType_ENTER_GOTO
|
enterType = proto.EnterType_ENTER_GOTO
|
||||||
}
|
}
|
||||||
|
|
||||||
player.SceneEnterReason = uint32(enterReason)
|
player.SceneEnterReason = uint32(enterReason)
|
||||||
playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyTp(player, enterType, oldSceneId, oldPos, dungeonId, dungeonPointId)
|
|
||||||
|
enterSceneToken := world.AddEnterSceneContext(&EnterSceneContext{
|
||||||
|
OldSceneId: oldSceneId,
|
||||||
|
OldPos: oldPos,
|
||||||
|
NewSceneId: newSceneId,
|
||||||
|
NewPos: newPos,
|
||||||
|
NewRot: newRot,
|
||||||
|
OldDungeonPointId: dungeonPointId,
|
||||||
|
Uid: player.PlayerId,
|
||||||
|
})
|
||||||
|
|
||||||
|
playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyTp(player, enterType, newSceneId, newPos, dungeonId, enterSceneToken)
|
||||||
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, playerEnterSceneNotify)
|
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, playerEnterSceneNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ type DbScene struct {
|
|||||||
UnlockPointMap map[uint32]bool
|
UnlockPointMap map[uint32]bool
|
||||||
UnHidePointMap map[uint32]bool
|
UnHidePointMap map[uint32]bool
|
||||||
SceneGroupMap map[uint32]*DbSceneGroup
|
SceneGroupMap map[uint32]*DbSceneGroup
|
||||||
VehicleMap map[uint32]*DbVehicle
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DbSceneGroup struct {
|
type DbSceneGroup struct {
|
||||||
@@ -24,13 +23,6 @@ type DbSceneGroup struct {
|
|||||||
GadgetStateMap map[uint32]uint8
|
GadgetStateMap map[uint32]uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
type DbVehicle struct {
|
|
||||||
VehicleId uint32 // 载具Id
|
|
||||||
OwnerUid uint32 // 所有者Id
|
|
||||||
Pos *Vector // 位置
|
|
||||||
Rot *Vector // 旋转
|
|
||||||
}
|
|
||||||
|
|
||||||
type MapMark struct {
|
type MapMark struct {
|
||||||
SceneId uint32
|
SceneId uint32
|
||||||
Pos *Vector
|
Pos *Vector
|
||||||
@@ -76,9 +68,6 @@ func (w *DbWorld) GetSceneById(sceneId uint32) *DbScene {
|
|||||||
if scene.SceneGroupMap == nil {
|
if scene.SceneGroupMap == nil {
|
||||||
scene.SceneGroupMap = make(map[uint32]*DbSceneGroup)
|
scene.SceneGroupMap = make(map[uint32]*DbSceneGroup)
|
||||||
}
|
}
|
||||||
if scene.VehicleMap == nil {
|
|
||||||
scene.VehicleMap = make(map[uint32]*DbVehicle)
|
|
||||||
}
|
|
||||||
return scene
|
return scene
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,12 +159,3 @@ func (g *DbSceneGroup) CheckGadgetExist(configId uint32) bool {
|
|||||||
_, exist := g.GadgetStateMap[configId]
|
_, exist := g.GadgetStateMap[configId]
|
||||||
return exist
|
return exist
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DbScene) AddVehicle(vehicleId uint32, ownerId uint32, pos *Vector, rot *Vector) {
|
|
||||||
s.VehicleMap[vehicleId] = &DbVehicle{
|
|
||||||
VehicleId: vehicleId,
|
|
||||||
OwnerUid: ownerId,
|
|
||||||
Pos: pos,
|
|
||||||
Rot: rot,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user