From 8200256aff13a1a3c1f822aaffca13f95ec76e92 Mon Sep 17 00:00:00 2001 From: CWX Date: Mon, 9 Oct 2023 22:38:59 +0100 Subject: [PATCH] fix up botmonitor for 3.7.0 --- Live/CWX_DebuggingTool/BotmonClass.cs | 12 +++++------- Live/CWX_DebuggingTool/DebuggingTool.cs | 9 +++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Live/CWX_DebuggingTool/BotmonClass.cs b/Live/CWX_DebuggingTool/BotmonClass.cs index 43e505a..09eb257 100644 --- a/Live/CWX_DebuggingTool/BotmonClass.cs +++ b/Live/CWX_DebuggingTool/BotmonClass.cs @@ -29,7 +29,6 @@ namespace CWX_DebuggingTool private BotmonClass() { - } public int Mode { get; set; } @@ -59,7 +58,6 @@ namespace CWX_DebuggingTool ~BotmonClass() { - ConsoleScreen.Log("BotMonitor Disabled on game end"); } public void Awake() @@ -140,7 +138,7 @@ namespace CWX_DebuggingTool if (Mode >= 1) { _content = string.Empty; - //_content += $"Total = {_gameWorld.AllPlayers.Count - 1}\n"; + _content += $"Total = {_gameWorld.AllAlivePlayersList.Count - 1}\n"; } // If Mode Greater than or equal to 2 show total for each zone @@ -148,14 +146,14 @@ namespace CWX_DebuggingTool { foreach (var zone in _zoneAndPlayers) { - if (_zoneAndPlayers[zone.Key].FindAll(x => x.HealthController.IsAlive).Count <= 0) continue; + if (_zoneAndPlayers[zone.Key].FindAll(x => x != null && x.HealthController != null && x.HealthController.IsAlive).Count <= 0) continue; - _content += $"{zone.Key} = {_zoneAndPlayers[zone.Key].FindAll(x => x.HealthController.IsAlive).Count}\n"; + _content += $"{zone.Key} = {_zoneAndPlayers[zone.Key].FindAll(x => x != null && x.HealthController != null && x.HealthController.IsAlive).Count}\n"; // If Mode Greater than or equal to 3 show Bots individually also if (Mode < 3) continue; - foreach (var player in _zoneAndPlayers[zone.Key].Where(player => player.HealthController.IsAlive)) + foreach (var player in _zoneAndPlayers[zone.Key].Where(player => player != null && player.HealthController != null && player.HealthController.IsAlive)) { _distance = Vector3.Distance(player.Position, _player.Position); _content += $"> [{_distance:n2}m] [{_playerRoleAndDiff.First(x => x.Key == player.ProfileId).Value.Role}] " + @@ -163,7 +161,7 @@ namespace CWX_DebuggingTool } } } - + _guiContent.text = _content; _guiSize = _textStyle.CalcSize(_guiContent); diff --git a/Live/CWX_DebuggingTool/DebuggingTool.cs b/Live/CWX_DebuggingTool/DebuggingTool.cs index cbb089b..eeb3094 100644 --- a/Live/CWX_DebuggingTool/DebuggingTool.cs +++ b/Live/CWX_DebuggingTool/DebuggingTool.cs @@ -42,15 +42,20 @@ namespace CWX_DebuggingTool } } - public static void DisableBotMonitor() + private static void DisableBotMonitor() { BotmonClass.Instance.Dispose(); } - public static void EnableBotMonitor(int option) + private static void EnableBotMonitor(int option) { var gameWorld = Singleton.Instance; + var checkExists = gameWorld.gameObject.GetComponentInChildren(); + + if (checkExists != null) + Destroy(checkExists); + var btmInstance = gameWorld.gameObject.AddComponent(); btmInstance.Mode = option;