大世界AOI广播域隔离

This commit is contained in:
flswld
2023-04-10 19:32:16 +08:00
parent 5a043a9482
commit b5faba4151
22 changed files with 677 additions and 666 deletions

View File

@@ -375,9 +375,9 @@ func (g *Game) SendToWorldA(world *World, cmdId uint16, seq uint32, msg pb.Messa
}
// SendToWorldAEC 给世界内除某玩家(一般是自己)以外的所有玩家发消息
func (g *Game) SendToWorldAEC(world *World, cmdId uint16, seq uint32, msg pb.Message, uid uint32) {
func (g *Game) SendToWorldAEC(world *World, cmdId uint16, seq uint32, msg pb.Message, aecUid uint32) {
for _, v := range world.GetAllPlayer() {
if uid == v.PlayerID {
if aecUid == v.PlayerID {
continue
}
GAME.SendMsg(cmdId, v.PlayerID, seq, msg)
@@ -389,6 +389,44 @@ func (g *Game) SendToWorldH(world *World, cmdId uint16, seq uint32, msg pb.Messa
GAME.SendMsg(cmdId, world.GetOwner().PlayerID, seq, msg)
}
// SendToSceneA 给场景内所有玩家发消息
func (g *Game) SendToSceneA(scene *Scene, cmdId uint16, seq uint32, msg pb.Message) {
world := scene.GetWorld()
if WORLD_MANAGER.IsBigWorld(world) {
bigWorldAoi := world.GetBigWorldAoi()
otherWorldAvatarMap := bigWorldAoi.GetObjectListByPos(float32(SELF.Pos.X), float32(SELF.Pos.Y), float32(SELF.Pos.Z))
for uid := range otherWorldAvatarMap {
GAME.SendMsg(cmdId, uint32(uid), seq, msg)
}
} else {
for _, v := range scene.GetAllPlayer() {
GAME.SendMsg(cmdId, v.PlayerID, seq, msg)
}
}
}
// SendToSceneAEC 给场景内除某玩家(一般是自己)以外的所有玩家发消息
func (g *Game) SendToSceneAEC(scene *Scene, cmdId uint16, seq uint32, msg pb.Message, aecUid uint32) {
world := scene.GetWorld()
if WORLD_MANAGER.IsBigWorld(world) {
bigWorldAoi := world.GetBigWorldAoi()
otherWorldAvatarMap := bigWorldAoi.GetObjectListByPos(float32(SELF.Pos.X), float32(SELF.Pos.Y), float32(SELF.Pos.Z))
for uid := range otherWorldAvatarMap {
if aecUid == uint32(uid) {
continue
}
GAME.SendMsg(cmdId, uint32(uid), seq, msg)
}
} else {
for _, v := range scene.GetAllPlayer() {
if aecUid == v.PlayerID {
continue
}
GAME.SendMsg(cmdId, v.PlayerID, seq, msg)
}
}
}
func (g *Game) ReLoginPlayer(userId uint32, isQuitMp bool) {
reason := proto.ClientReconnectReason_CLIENT_RECONNNECT_NONE
if isQuitMp {