调整角色场景实体相关协议

This commit is contained in:
flswld committed 2023-11-08 02:01:14 +08:00
1 parent 346b583f64
commit d8a3af9fc8
15 files changed
+245 -225

No files matched your search

+1 -1
View File
@@ -300,7 +300,7 @@ func UpdateFrame(fileData []byte, basePos *model.Vector, rgb bool) {
for _, v := range SCREEN_ENTITY_ID_LIST {
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)
leftTopPos := &model.Vector{
X: basePos.X + float64(SCREEN_WIDTH)*SCREEN_DPI/2,
+14
View File
@@ -443,6 +443,13 @@ func (g *Game) SendToSceneA(scene *Scene, cmdId uint16, seq uint32, msg pb.Messa
if aecUid == v.PlayerId {
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)
}
}
@@ -477,6 +484,13 @@ func (g *Game) SendToSceneACV(scene *Scene, cmdId uint16, seq uint32, msg pb.Mes
if v.ClientVersion != clientVersion {
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)
}
}
+6 -3
View File
@@ -486,6 +486,7 @@ func (g *GMCmd) GMUnlockAllOpenState(userId uint32) {
// GMFreeMode 自由探索模式
func (g *GMCmd) GMFreeMode(userId uint32) {
GAME.LogoutPlayer(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
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_DIVE_MAX_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指令
@@ -609,9 +613,8 @@ func (g *GMCmd) CreateRobotInAiWorld(uid uint32, name string, avatarId uint32, p
GAME.PostEnterSceneReq(robot, &proto.PostEnterSceneReq{
EnterSceneToken: aiWorld.GetEnterSceneToken(),
})
activeAvatarId := aiWorld.GetPlayerActiveAvatarId(robot)
entityMoveInfo := &proto.EntityMoveInfo{
EntityId: aiWorld.GetPlayerWorldAvatarEntityId(robot, activeAvatarId),
EntityId: aiWorld.GetPlayerActiveAvatarEntity(robot).GetId(),
MotionInfo: &proto.MotionInfo{
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)},
+5 -4
View File
@@ -225,7 +225,7 @@ func (p *PluginPubg) GlobalTickPubg() {
GAME.handleEvtBeingHit(scenePlayer, scene, &proto.EvtBeingHitInfo{
AttackResult: &proto.AttackResult{
AttackerId: 0,
DefenseId: world.GetPlayerWorldAvatarEntityId(scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer)),
DefenseId: world.GetPlayerActiveAvatarEntity(scenePlayer).GetId(),
Damage: PUBG_HP_LOST,
},
})
@@ -560,9 +560,10 @@ func (p *PluginPubg) PubgHit(scene *Scene, defAvatarEntityId uint32, atkAvatarEn
}
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
AttackResult: &proto.AttackResult{
AttackerId: atkAvatarEntity.GetId(),
DefenseId: defAvatarEntity.GetId(),
Damage: dmg,
AttackerId: atkAvatarEntity.GetId(),
DefenseId: defAvatarEntity.GetId(),
Damage: dmg,
DamageShield: dmg,
},
})
if attackResultTemplate == nil {
+32 -7
View File
@@ -210,6 +210,9 @@ func (w *WorldManager) GetMultiplayerWorldNum() uint32 {
type EnterSceneContext struct {
OldSceneId uint32
OldPos *model.Vector
NewSceneId uint32
NewPos *model.Vector
NewRot *model.Vector
OldDungeonPointId uint32
Uid uint32
}
@@ -357,9 +360,10 @@ func (w *World) GetAiWorldAoi() *alg.AoiManager {
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.playerMap[player.PlayerId] = player
// 将玩家自身当前的队伍角色信息复制到世界的玩家本地队伍
dbTeam := player.GetDbTeam()
team := dbTeam.GetActiveTeam()
@@ -385,7 +389,8 @@ func (w *World) AddPlayer(player *model.Player, sceneId uint32) {
w.SetPlayerAvatarIndex(worldPlayer, index)
}
}
scene := w.GetSceneById(sceneId)
scene := w.GetSceneById(player.SceneId)
scene.AddPlayer(player)
w.InitPlayerTeamEntityId(player)
}
@@ -518,8 +523,6 @@ func (w *World) UpdatePlayerWorldAvatar(player *model.Player) {
if worldAvatar.avatarEntityId != 0 {
continue
}
scene.DestroyEntity(worldAvatar.avatarEntityId)
scene.DestroyEntity(worldAvatar.weaponEntityId)
worldAvatar.avatarEntityId = scene.CreateEntityAvatar(player, worldAvatar.avatarId)
worldAvatar.weaponEntityId = scene.CreateEntityWeapon(player.GetPos(), player.GetRot())
}
@@ -594,6 +597,15 @@ func (w *World) GetPlayerActiveAvatarEntity(player *model.Player) *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 {
// key:uid value:玩家的本地队伍
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) {
oldLocalTeam := w.multiplayerTeam.localTeamMap[player.PlayerId]
sameAvatarIdList := make([]uint32, 0)
diffAvatarIdList := make([]uint32, 0)
addAvatarIdList := make([]uint32, 0)
for _, avatarId := range avatarIdList {
exist := false
for _, worldAvatar := range oldLocalTeam {
@@ -631,7 +643,7 @@ func (w *World) SetPlayerLocalTeam(player *model.Player, avatarIdList []uint32)
if exist {
sameAvatarIdList = append(sameAvatarIdList, avatarId)
} else {
diffAvatarIdList = append(diffAvatarIdList, avatarId)
addAvatarIdList = append(addAvatarIdList, avatarId)
}
}
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
for i, v := range avatarIdList {
if avatarId == v {
@@ -664,6 +676,19 @@ func (w *World) SetPlayerLocalTeam(player *model.Player, avatarIdList []uint32)
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
}
+32 -14
View File
@@ -409,35 +409,54 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
oldVisionEntityMap := g.GetVisionEntity(scene, oldPos)
newVisionEntityMap := g.GetVisionEntity(scene, newPos)
delEntityIdList := make([]uint32, 0)
for entityId, entity := range oldVisionEntityMap {
for entityId := range oldVisionEntityMap {
_, exist = newVisionEntityMap[entityId]
if exist {
continue
}
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
continue
}
// 旧有新没有的实体即为消失的
delEntityIdList = append(delEntityIdList, entityId)
}
addEntityIdList := make([]uint32, 0)
for entityId, entity := range newVisionEntityMap {
for entityId := range newVisionEntityMap {
_, exist = oldVisionEntityMap[entityId]
if exist {
continue
}
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
continue
}
// 新有旧没有的实体即为出现的
addEntityIdList = append(addEntityIdList, entityId)
}
// 同步客户端消失和出现的场景实体
if len(delEntityIdList) > 0 {
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 {
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)
@@ -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)
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})
}
}
@@ -550,7 +569,7 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
newVisionEntityMap := g.GetVisionEntity(scene, newPos)
delEntityIdList := make([]uint32, 0)
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
}
_, exist := newVisionEntityMap[entityId]
@@ -562,7 +581,7 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
}
addEntityIdList := make([]uint32, 0)
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
}
_, exist := oldVisionEntityMap[entityId]
@@ -946,10 +965,9 @@ func (g *Game) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.Message
}
yawAngle := ntf.InitEulerAngles.Y
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
activeAvatarId := world.GetPlayerActiveAvatarId(player)
bulletPhysicsEngine.CreateRigidBody(
ntf.EntityId,
world.GetPlayerWorldAvatarEntityId(player, activeAvatarId),
world.GetPlayerActiveAvatarEntity(player).GetId(),
player.SceneId,
ntf.InitPos.X, ntf.InitPos.Y, ntf.InitPos.Z,
pitchAngle, yawAngle,
@@ -969,7 +987,7 @@ func (g *Game) EvtDestroyGadgetNotify(player *model.Player, payloadMsg pb.Messag
}
scene := world.GetSceneById(player.SceneId)
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) {
+4 -4
View File
@@ -61,13 +61,13 @@ func (g *Game) SetPlayerBornDataReq(player *model.Player, payloadMsg pb.Message)
// 创建世界
world := WORLD_MANAGER.CreateWorld(player)
world.AddPlayer(player, player.SceneId)
world.AddPlayer(player)
player.WorldId = world.GetId()
// 进入场景
player.SceneJump = true
player.SceneLoadState = model.SceneNone
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))
}
@@ -121,13 +121,13 @@ func (g *Game) OnLogin(userId uint32, clientSeq uint32, gateAppId string, player
} else {
// 创建世界
world := WORLD_MANAGER.CreateWorld(player)
world.AddPlayer(player, player.SceneId)
world.AddPlayer(player)
player.WorldId = world.GetId()
// 进入场景
player.SceneJump = true
player.SceneLoadState = model.SceneNone
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 {
g.SendMsg(cmd.DoSetPlayerBornDataNotify, userId, clientSeq, new(proto.DoSetPlayerBornDataNotify))
+29 -14
View File
@@ -180,12 +180,18 @@ func (g *Game) JoinOtherWorld(player *model.Player, hostPlayer *model.Player) {
player.SetRot(hostPlayer.GetRot())
g.WorldAddPlayer(hostWorld, player)
enterSceneToken := hostWorld.AddEnterSceneContext(&EnterSceneContext{
OldSceneId: 0,
Uid: player.PlayerId,
})
playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp(
player,
hostPlayer,
proto.EnterType_ENTER_OTHER,
0,
new(model.Vector),
hostPlayer.SceneId,
hostPlayer.GetPos(),
enterSceneToken,
)
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, playerEnterSceneNotify)
} else {
@@ -365,12 +371,23 @@ func (g *Game) HostEnterMpWorld(hostPlayer *model.Player) {
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(
hostPlayer,
hostPlayer,
proto.EnterType_ENTER_GOTO,
hostPlayer.SceneId,
pos,
hostPlayer.GetPos(),
enterSceneToken,
)
g.SendMsg(cmd.PlayerEnterSceneNotify, hostPlayer.PlayerId, hostPlayer.ClientSeq, hostPlayerEnterSceneNotify)
}
@@ -407,7 +424,7 @@ func (g *Game) WorldAddPlayer(world *World, player *model.Player) {
if exist {
return
}
world.AddPlayer(player, player.SceneId)
world.AddPlayer(player)
player.WorldId = world.GetId()
if world.IsMultiplayerWorld() && world.GetWorldPlayerNum() > 1 {
g.UpdateWorldPlayerInfo(world, player)
@@ -437,25 +454,23 @@ func (g *Game) WorldRemovePlayer(world *World, player *model.Player) {
}
scene := world.GetSceneById(player.SceneId)
// 清除玩家的载具
for vehicleId, entityId := range player.VehicleInfo.CreateEntityIdMap {
g.DestroyVehicleEntity(player, scene, vehicleId, entityId)
}
entityIdList := make([]uint32, 0)
for _, entity := range g.GetVisionEntity(scene, g.GetPlayerPos(player)) {
entityIdList = append(entityIdList, entity.GetId())
}
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)
// 清除其他玩家的载具
if world.GetOwner().PlayerId != player.PlayerId {
for vehicleId, entityId := range player.VehicleInfo.CreateEntityIdMap {
g.DestroyVehicleEntity(player, scene, vehicleId, entityId)
}
}
if world.IsMultiplayerWorld() {
activeAvatarId := world.GetPlayerActiveAvatarId(player)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)})
activeAvatarEntity := world.GetPlayerActiveAvatarEntity(player)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, []uint32{activeAvatarEntity.GetId()}, 0)
}
world.RemovePlayer(player)
+1 -1
View File
@@ -67,7 +67,7 @@ func (g *Game) QuestDestroyEntityReq(player *model.Player, payloadMsg pb.Message
return
}
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{
QuestId: req.QuestId,
SceneId: req.SceneId,
+89 -79
View File
@@ -53,19 +53,27 @@ func (g *Game) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
return
}
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)
for entityId, entity := range g.GetVisionEntity(oldScene, ctx.OldPos) {
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
continue
}
for entityId := range g.GetVisionEntity(oldScene, oldPos) {
delEntityIdList = append(delEntityIdList, entityId)
}
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) {
// 卸载旧位置附近的group
for _, groupConfig := range g.GetNeighborGroup(ctx.OldSceneId, ctx.OldPos) {
for _, groupConfig := range g.GetNeighborGroup(oldSceneId, oldPos) {
if !world.IsMultiplayerWorld() {
// 单人世界直接卸载group
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{
@@ -204,9 +234,8 @@ func (g *Game) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
}
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerId, player.ClientSeq, playerGameTimeNotify)
activeAvatarId := world.GetPlayerActiveAvatarId(player)
playerEnterSceneInfoNotify := &proto.PlayerEnterSceneInfoNotify{
CurAvatarEntityId: world.GetPlayerWorldAvatarEntityId(player, activeAvatarId),
CurAvatarEntityId: world.GetPlayerActiveAvatarEntity(player).GetId(),
EnterSceneToken: req.EnterSceneToken,
TeamEnterInfo: &proto.TeamEnterSceneInfo{
TeamEntityId: world.GetPlayerTeamEntityId(player),
@@ -336,17 +365,14 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
visionEntityMap := g.GetVisionEntity(scene, pos)
entityIdList := make([]uint32, 0)
for entityId, entity := range visionEntityMap {
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR || entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
continue
if WORLD_MANAGER.IsAiWorld(world) {
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
continue
}
}
entityIdList = append(entityIdList, entityId)
}
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) {
aiWorldAoi := world.GetAiWorldAoi()
@@ -502,7 +528,7 @@ func (g *Game) RemoveSceneEntityNotifyToPlayer(player *model.Player, visionType
}
// 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{
EntityList: entityIdList,
DisappearType: visionType,
@@ -510,7 +536,7 @@ func (g *Game) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.V
world := scene.GetWorld()
owner := world.GetOwner()
// 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 添加的场景实体同步 封装接口
@@ -537,17 +563,11 @@ func (g *Game) AddSceneEntityNotify(player *model.Player, visionType proto.Visio
}
switch entity.GetEntityType() {
case constant.ENTITY_TYPE_AVATAR:
if visionType == proto.VisionType_VISION_MEET && entity.GetAvatarEntity().GetUid() == player.PlayerId {
continue
}
scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
if scenePlayer == nil {
logger.Error("get scene player is nil, world id: %v, scene id: %v", world.GetId(), scene.GetId())
continue
}
if entity.GetAvatarEntity().GetAvatarId() != world.GetPlayerActiveAvatarId(scenePlayer) {
continue
}
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
entityList = append(entityList, sceneEntityInfoAvatar)
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.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.GetId()})
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.GetId()}, 0)
scene.DestroyEntity(entity.GetId())
group := scene.GetGroupById(entity.GetGroupId())
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)
visionEntity := make(map[uint32]*Entity, int(float32(len(allEntityMap))*ratio))
for _, entity := range allEntityMap {
dx := int32(pos.X) - int32(entity.GetPos().X)
if dx < 0 {
dx *= -1
if !g.IsInVision(pos, entity.GetPos()) {
continue
}
dy := int32(pos.Z) - int32(entity.GetPos().Z)
if dy < 0 {
dy *= -1
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
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
}
visionEntity[entity.GetId()] = entity
@@ -786,25 +811,19 @@ func (g *Game) GetVisionEntity(scene *Scene, pos *model.Vector) map[uint32]*Enti
return visionEntity
}
// CreateSceneVehicle 创建场景内的载具
func (g *Game) CreateSceneVehicle(scene *Scene) []uint32 {
world := scene.GetWorld()
owner := world.GetOwner()
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
func (g *Game) IsInVision(p1 *model.Vector, p2 *model.Vector) bool {
dx := int32(p1.X) - int32(p2.X)
if dx < 0 {
dx *= -1
}
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 获取某位置附近的场景组
@@ -1364,7 +1383,7 @@ func (g *Game) SetPlayerWeather(player *model.Player, weatherAreaId uint32, clim
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)
if world == nil {
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,
Pos: &proto.Vector{X: float32(pos.X), Y: float32(pos.Y), Z: float32(pos.Z)},
SceneBeginTime: uint64(scene.GetSceneCreateTime()),
Type: enterType,
Type: proto.EnterType_ENTER_SELF,
TargetUid: player.PlayerId,
EnterSceneToken: enterSceneToken,
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(
player *model.Player,
enterType proto.EnterType,
prevSceneId uint32,
prevPos *model.Vector,
sceneId uint32,
pos *model.Vector,
dungeonId uint32,
dungeonPointId uint32,
enterSceneToken uint32,
) *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(
player *model.Player,
targetPlayer *model.Player,
enterType proto.EnterType,
prevSceneId uint32,
prevPos *model.Vector,
sceneId uint32,
pos *model.Vector,
enterSceneToken uint32,
) *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(
player *model.Player,
targetPlayer *model.Player,
enterType proto.EnterType,
prevSceneId uint32,
prevPos *model.Vector,
sceneId uint32,
pos *model.Vector,
dungeonId uint32,
dungeonPointId uint32,
enterSceneToken uint32,
) *proto.PlayerEnterSceneNotify {
world := WORLD_MANAGER.GetWorldById(targetPlayer.WorldId)
if world == nil {
@@ -1438,21 +1458,11 @@ func (g *Game) PacketPlayerEnterSceneNotifyCore(
return new(proto.PlayerEnterSceneNotify)
}
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{
PrevSceneId: prevSceneId,
PrevPos: &proto.Vector{X: float32(prevPos.X), Y: float32(prevPos.Y), Z: float32(prevPos.Z)},
SceneId: targetPlayer.SceneId,
Pos: &proto.Vector{X: float32(targetPlayer.GetPos().X), Y: float32(targetPlayer.GetPos().Y), Z: float32(targetPlayer.GetPos().Z)},
PrevSceneId: player.SceneId,
PrevPos: &proto.Vector{X: float32(player.GetPos().X), Y: float32(player.GetPos().Y), Z: float32(player.GetPos().Z)},
SceneId: sceneId,
Pos: &proto.Vector{X: float32(pos.X), Y: float32(pos.Y), Z: float32(pos.Z)},
SceneBeginTime: uint64(scene.GetSceneCreateTime()),
Type: enterType,
TargetUid: targetPlayer.PlayerId,
@@ -1464,12 +1474,12 @@ func (g *Game) PacketPlayerEnterSceneNotifyCore(
SceneTagIdList: make([]uint32, 0),
}
SceneTransactionSeq++
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(targetPlayer.SceneId)) + "-" +
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(sceneId)) + "-" +
strconv.Itoa(int(player.PlayerId)) + "-" +
strconv.Itoa(int(time.Now().Unix())) + "-" +
strconv.Itoa(int(SceneTransactionSeq))
for _, sceneTagDataConfig := range gdconf.GetSceneTagDataMap() {
if uint32(sceneTagDataConfig.SceneId) == targetPlayer.SceneId {
if uint32(sceneTagDataConfig.SceneId) == sceneId {
playerEnterSceneNotify.SceneTagIdList = append(playerEnterSceneNotify.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
}
}
@@ -1860,10 +1870,10 @@ func (g *Game) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVehicleEn
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{
SceneId: player.SceneId,
DelEntityIdList: []uint32{scene.GetWorld().GetPlayerTeamEntityId(player)},
DelEntityIdList: []uint32{world.GetPlayerTeamEntityId(player)},
}
return delTeamEntityNotify
}
+2 -8
View File
@@ -222,13 +222,8 @@ func (g *Game) VehicleRestoreStaminaHandler(player *model.Player) {
if entity == nil {
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)
} else {
@@ -257,8 +252,7 @@ func (g *Game) SustainStaminaHandler(player *model.Player) {
return
}
// 确保实体类型是否为载具 且 根据玩家是否处于载具中更新耐力
gadgetEntity := entity.GetGadgetEntity()
if gadgetEntity != nil && gadgetEntity.GetGadgetVehicleEntity() != nil && g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
if g.IsPlayerInVehicle(player, entity) {
// 更新载具耐力
g.UpdateVehicleStamina(player, entity, player.StaminaInfo.CostStamina)
} else {
+3 -4
View File
@@ -270,8 +270,7 @@ func (g *Game) ChangeAvatar(player *model.Player, targetAvatarId uint32) {
}
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
newAvatarId := world.GetPlayerActiveAvatarId(player)
newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarId)
newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, targetAvatarId)
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
AppearType: proto.VisionType_VISION_REPLACE,
Param: oldAvatarEntity.GetId(),
@@ -357,8 +356,8 @@ func (g *Game) PacketSceneTeamUpdateNotify(world *World, player *model.Player) *
SceneEntityInfo: g.PacketSceneEntityInfoAvatar(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId()),
WeaponGuid: worldPlayerAvatar.EquipWeapon.Guid,
WeaponEntityId: world.GetPlayerWorldAvatarWeaponEntityId(worldPlayer, worldAvatar.GetAvatarId()),
IsPlayerCurAvatar: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.GetAvatarId(),
IsOnScene: world.GetPlayerActiveAvatarId(worldPlayer) == worldAvatar.GetAvatarId(),
IsPlayerCurAvatar: world.IsPlayerActiveAvatarEntity(worldPlayer, worldAvatar.GetAvatarEntityId()),
IsOnScene: world.IsPlayerActiveAvatarEntity(worldPlayer, worldAvatar.GetAvatarEntityId()),
AvatarAbilityInfo: &proto.AbilitySyncStateInfo{
IsInited: len(worldAvatar.GetAbilityList()) != 0,
DynamicValueMap: nil,
+9 -20
View File
@@ -3,6 +3,7 @@ package game
import (
"time"
"hk4e/common/constant"
"hk4e/gdconf"
"hk4e/gs/model"
"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.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
createVehicleRsp := &proto.CreateVehicleRsp{
@@ -132,7 +126,11 @@ func (g *Game) VehicleDestroyMotion(player *model.Player, entity *Entity, state
}
// 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 {
return false
}
@@ -165,7 +163,7 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
return
}
// 如果玩家正在载具中
if g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
if g.IsPlayerInVehicle(player, entity) {
// 离开载具
dbTeam := player.GetDbTeam()
dbAvatar := player.GetDbAvatar()
@@ -173,18 +171,9 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
}
// 删除已创建的载具
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)
// 删除房主的载具存档
world := scene.GetWorld()
owner := world.GetOwner()
if owner == player {
dbWorld := owner.GetDbWorld()
dbScene := dbWorld.GetSceneById(scene.GetId())
delete(dbScene.VehicleMap, vehicleId)
}
}
// 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) {
// 玩家是否进入载具
gadgetEntity := entity.GetGadgetEntity()
if !g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
if !g.IsPlayerInVehicle(player, entity) {
logger.Error("vehicle not has player, uid: %v", player.PlayerId)
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_NOT_IN_VEHICLE)
return
+18 -46
View File
@@ -728,7 +728,7 @@ func (g *Game) TeleportPlayer(
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
return
}
if WORLD_MANAGER.IsAiWorld(world) && player.CmdPerm != uint8(CommandPermGM) {
if WORLD_MANAGER.IsAiWorld(world) {
return
}
@@ -737,65 +737,37 @@ func (g *Game) TeleportPlayer(
newSceneId := sceneId
newPos := pos
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
if jumpScene {
delTeamEntityNotify := g.PacketDelTeamEntityNotify(oldScene, player)
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)
if newSceneId != oldSceneId {
player.SceneJump = true
logger.Debug("player jump scene, scene: %v, pos: %v", player.SceneId, newPos)
enterType = proto.EnterType_ENTER_JUMP
if enterReason == proto.EnterReason_ENTER_REASON_DUNGEON_ENTER {
logger.Debug("player tp to dungeon scene, sceneId: %v, pos: %v", player.SceneId, newPos)
enterType = proto.EnterType_ENTER_DUNGEON
}
delTeamEntityNotify := g.PacketDelTeamEntityNotify(world, player)
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerId, player.ClientSeq, delTeamEntityNotify)
} else {
player.SceneLoadState = model.SceneNone
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)
}
player.SceneJump = false
logger.Debug("player goto scene, scene: %v, pos: %v", player.SceneId, newPos)
enterType = proto.EnterType_ENTER_GOTO
}
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)
}
-20
View File
@@ -15,7 +15,6 @@ type DbScene struct {
UnlockPointMap map[uint32]bool
UnHidePointMap map[uint32]bool
SceneGroupMap map[uint32]*DbSceneGroup
VehicleMap map[uint32]*DbVehicle
}
type DbSceneGroup struct {
@@ -24,13 +23,6 @@ type DbSceneGroup struct {
GadgetStateMap map[uint32]uint8
}
type DbVehicle struct {
VehicleId uint32 // 载具Id
OwnerUid uint32 // 所有者Id
Pos *Vector // 位置
Rot *Vector // 旋转
}
type MapMark struct {
SceneId uint32
Pos *Vector
@@ -76,9 +68,6 @@ func (w *DbWorld) GetSceneById(sceneId uint32) *DbScene {
if scene.SceneGroupMap == nil {
scene.SceneGroupMap = make(map[uint32]*DbSceneGroup)
}
if scene.VehicleMap == nil {
scene.VehicleMap = make(map[uint32]*DbVehicle)
}
return scene
}
@@ -170,12 +159,3 @@ func (g *DbSceneGroup) CheckGadgetExist(configId uint32) bool {
_, exist := g.GadgetStateMap[configId]
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,
}
}