可能修复玩家位置同步异常,修复ai世界动态更新天气

This commit is contained in:
unkown committed 2023-10-18 23:26:04 +08:00
1 parent e08e9579bd
commit 944369b05e
2 files changed
+15 -7

No files matched your search

+13 -5
View File
@@ -96,11 +96,19 @@ func (s *Scene) CreateEntityAvatar(player *model.Player, avatarId uint32) uint32
return 0
}
entity := &Entity{
id: entityId,
scene: s,
lifeState: avatar.LifeState,
pos: player.Pos, // 所有角色实体暂时公用玩家的位置信息
rot: player.Rot,
id: entityId,
scene: s,
lifeState: avatar.LifeState,
pos: &model.Vector{
X: player.Pos.X,
Y: player.Pos.Y,
Z: player.Pos.Z,
}, // 所有角色实体暂时公用玩家的位置信息
rot: &model.Vector{
X: player.Rot.X,
Y: player.Rot.Y,
Z: player.Rot.Z,
},
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
+2 -2
View File
@@ -244,6 +244,8 @@ func (g *Game) handleEntityMove(player *model.Player, world *World, scene *Scene
} else {
g.AiWorldAoiPlayerMove(player, world, scene, player.Pos, pos)
}
// 场景天气区域变更检测
g.SceneWeatherAreaCheck(player, player.Pos, pos)
// 更新玩家的位置信息
player.Pos.X, player.Pos.Y, player.Pos.Z = pos.X, pos.Y, pos.Z
player.Rot.X, player.Rot.Y, player.Rot.Z = rot.X, rot.Y, rot.Z
@@ -382,8 +384,6 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
}
// 场景区域触发器检测
g.SceneRegionTriggerCheck(player, oldPos, newPos, avatarEntityId)
// 场景天气区域变更检测
g.SceneWeatherAreaCheck(player, oldPos, newPos)
}
func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *Scene, oldPos *model.Vector, newPos *model.Vector) {