From 2059af53046f10e74943b4c6def4d97a625be5fa Mon Sep 17 00:00:00 2001 From: flswld Date: Wed, 18 Oct 2023 17:18:48 +0800 Subject: [PATCH] =?UTF-8?q?ai=E4=B8=96=E7=95=8Caoi=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=99=A8=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gs/game/game_tick_manager.go | 16 +++++++++++----- gs/game/player_fight_sync.go | 2 ++ gs/game/player_multiplayer.go | 1 + gs/game/player_scene.go | 1 + gs/game/player_world.go | 8 ++++---- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gs/game/game_tick_manager.go b/gs/game/game_tick_manager.go index 5fa1bc38..5b949e05 100644 --- a/gs/game/game_tick_manager.go +++ b/gs/game/game_tick_manager.go @@ -270,12 +270,18 @@ func (t *TickManager) onTick5Second(now int64) { GAME.ScenePlayerLocationNotify(world) } } + iPlugin, err := PLUGIN_MANAGER.GetPlugin(&PluginPubg{}) + if err != nil { + logger.Error("get plugin pubg error: %v", err) + return + } + pluginPubg := iPlugin.(*PluginPubg) + if pluginPubg.IsStartPubg() { + return + } aiWorld := WORLD_MANAGER.GetAiWorld() - if WORLD_MANAGER.IsAiWorld(aiWorld) { - // todo pubg允许超过100人 - if len(aiWorld.GetAllPlayer()) >= 100 { - return - } + if aiWorld.GetWorldPlayerNum() >= 100 { + return } for applyUid := range aiWorld.GetOwner().CoopApplyMap { GAME.PlayerDealEnterWorld(aiWorld.GetOwner(), applyUid, true) diff --git a/gs/game/player_fight_sync.go b/gs/game/player_fight_sync.go index f80eb955..4d59a947 100644 --- a/gs/game/player_fight_sync.go +++ b/gs/game/player_fight_sync.go @@ -431,6 +431,7 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S activeAvatarId := world.GetPlayerActiveAvatarId(player) activeWorldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId) // 老格子移除玩家 + 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, player.Pos) @@ -481,6 +482,7 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S } } // 新格子添加玩家 + logger.Debug("ai world aoi add player, newPos: %+v, uid: %v", newPos, player.PlayerId) ok = aiWorldAoi.AddObjectToGridByPos(int64(player.PlayerId), activeWorldAvatar, float32(newPos.X), float32(newPos.Y), float32(newPos.Z)) if !ok { logger.Error("ai world aoi add player fail, uid: %v, pos: %+v", player.PlayerId, player.Pos) diff --git a/gs/game/player_multiplayer.go b/gs/game/player_multiplayer.go index cc6dc317..f841ab39 100644 --- a/gs/game/player_multiplayer.go +++ b/gs/game/player_multiplayer.go @@ -450,6 +450,7 @@ func (g *Game) WorldRemovePlayer(world *World, player *model.Player) { if WORLD_MANAGER.IsAiWorld(world) { aiWorldAoi := world.GetAiWorldAoi() + logger.Debug("ai world aoi remove player, oldPos: %+v, uid: %v", player.Pos, player.PlayerId) ok := aiWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z)) if !ok { logger.Error("ai world aoi remove player fail, uid: %v, pos: %+v", player.PlayerId, player.Pos) diff --git a/gs/game/player_scene.go b/gs/game/player_scene.go index 4025d64c..5672daed 100644 --- a/gs/game/player_scene.go +++ b/gs/game/player_scene.go @@ -312,6 +312,7 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) { if WORLD_MANAGER.IsAiWorld(world) { aiWorldAoi := world.GetAiWorldAoi() + logger.Debug("ai world aoi add player, newPos: %+v, uid: %v", player.Pos, player.PlayerId) ok := aiWorldAoi.AddObjectToGridByPos(int64(player.PlayerId), activeWorldAvatar, float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z)) if !ok { logger.Error("ai world aoi add player fail, uid: %v, pos: %+v", player.PlayerId, player.Pos) diff --git a/gs/game/player_world.go b/gs/game/player_world.go index a8fbed43..08c5ec6a 100644 --- a/gs/game/player_world.go +++ b/gs/game/player_world.go @@ -677,8 +677,7 @@ func (g *Game) TeleportPlayer( return } - if WORLD_MANAGER.IsAiWorld(world) && sceneId != 3 { - logger.Error("ai world scene not support now, sceneId: %v, uid: %v", sceneId, player.PlayerId) + if WORLD_MANAGER.IsAiWorld(world) { return } @@ -697,9 +696,10 @@ func (g *Game) TeleportPlayer( if WORLD_MANAGER.IsAiWorld(world) { aiWorldAoi := world.GetAiWorldAoi() - ok := aiWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z)) + 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, player.Pos) + logger.Error("ai world aoi remove player fail, uid: %v, pos: %+v", player.PlayerId, oldPos) } }