fix up BotMon, now has three options, each giving more info
This commit is contained in:
parent
2a726ec4d7
commit
9209a7125b
@ -11,26 +11,27 @@ namespace CWX_DebuggingTool
|
|||||||
{
|
{
|
||||||
public sealed class BotmonClass : MonoBehaviour, IDisposable
|
public sealed class BotmonClass : MonoBehaviour, IDisposable
|
||||||
{
|
{
|
||||||
private static BotmonClass _instance = null;
|
private static BotmonClass _instance;
|
||||||
private GUIContent _guiContent = null;
|
|
||||||
|
private GUIContent _guiContent;
|
||||||
private GUIStyle _textStyle;
|
private GUIStyle _textStyle;
|
||||||
private StringBuilder _stringBuilder = new StringBuilder(200);
|
|
||||||
private Player _player;
|
private Player _player;
|
||||||
private Dictionary<string, List<Player>> _zoneAndPlayers = new Dictionary<string, List<Player>>();
|
private Dictionary<string, List<Player>> _zoneAndPlayers = new Dictionary<string, List<Player>>();
|
||||||
private List<BotZone> _zones = null;
|
private List<BotZone> _zones;
|
||||||
private GameWorld _gameWorld = null;
|
private GameWorld _gameWorld;
|
||||||
private IBotGame _botGame;
|
private IBotGame _botGame;
|
||||||
private Rect _rect;
|
private Rect _rect;
|
||||||
private String _content = "";
|
private String _content = "";
|
||||||
private Vector2 _guiSize;
|
private Vector2 _guiSize;
|
||||||
private float _distance;
|
private float _distance;
|
||||||
private float _timer;
|
|
||||||
|
|
||||||
private BotmonClass()
|
private BotmonClass()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Mode { get; set; }
|
||||||
|
|
||||||
public static BotmonClass Instance
|
public static BotmonClass Instance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -61,21 +62,28 @@ namespace CWX_DebuggingTool
|
|||||||
|
|
||||||
public void Awake()
|
public void Awake()
|
||||||
{
|
{
|
||||||
// Set Basics
|
// Get GameWorld Instance
|
||||||
_gameWorld = Singleton<GameWorld>.Instance;
|
_gameWorld = Singleton<GameWorld>.Instance;
|
||||||
|
|
||||||
|
// Get BotGame Instance
|
||||||
_botGame = Singleton<IBotGame>.Instance;
|
_botGame = Singleton<IBotGame>.Instance;
|
||||||
|
|
||||||
|
// Get Player from GameWorld
|
||||||
|
_player = _gameWorld.MainPlayer;
|
||||||
|
|
||||||
|
// Make new rect to use for GUI
|
||||||
|
_rect = new Rect(0, 60, 0, 0);
|
||||||
|
|
||||||
|
// Get all BotZones
|
||||||
_zones = LocationScene.GetAllObjects<BotZone>().ToList();
|
_zones = LocationScene.GetAllObjects<BotZone>().ToList();
|
||||||
|
|
||||||
|
// Set up the Dictionary
|
||||||
foreach (var botZone in _zones)
|
foreach (var botZone in _zones)
|
||||||
{
|
{
|
||||||
_zoneAndPlayers.Add(botZone.name, new List<Player>());
|
_zoneAndPlayers.Add(botZone.name, new List<Player>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// get player
|
// Add existing Bots to list
|
||||||
_player = _gameWorld.AllPlayers.Find(x => x.IsYourPlayer);
|
|
||||||
|
|
||||||
if (_gameWorld.AllPlayers.Count > 1)
|
if (_gameWorld.AllPlayers.Count > 1)
|
||||||
{
|
{
|
||||||
foreach (var player in _gameWorld.AllPlayers)
|
foreach (var player in _gameWorld.AllPlayers)
|
||||||
@ -89,8 +97,7 @@ namespace CWX_DebuggingTool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_rect = new Rect(0, 60, 0, 0);
|
// Sub to Event to get and add Bot when they spawn
|
||||||
|
|
||||||
_botGame.BotsController.BotSpawner.OnBotCreated += owner =>
|
_botGame.BotsController.BotSpawner.OnBotCreated += owner =>
|
||||||
{
|
{
|
||||||
Player player = owner.GetPlayer;
|
Player player = owner.GetPlayer;
|
||||||
@ -117,25 +124,34 @@ namespace CWX_DebuggingTool
|
|||||||
_guiContent = new GUIContent();
|
_guiContent = new GUIContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
_content = string.Empty;
|
// If Mode Greater than or equal to 1 show total
|
||||||
|
if (Mode >= 1)
|
||||||
if (_zoneAndPlayers != null)
|
|
||||||
{
|
{
|
||||||
|
_content = string.Empty;
|
||||||
_content += $"Total = {_gameWorld.AllPlayers.Count - 1}\n";
|
_content += $"Total = {_gameWorld.AllPlayers.Count - 1}\n";
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var zone in _zoneAndPlayers)
|
// If Mode Greater than or equal to 2 show total for each zone
|
||||||
|
if (Mode >= 2)
|
||||||
|
{
|
||||||
|
if (_zoneAndPlayers != null)
|
||||||
{
|
{
|
||||||
_content += $"{zone.Key} = {_zoneAndPlayers[zone.Key].FindAll(x => x.HealthController.IsAlive).Count}\n";
|
foreach (var zone in _zoneAndPlayers)
|
||||||
|
|
||||||
foreach (var player in _zoneAndPlayers[zone.Key])
|
|
||||||
{
|
{
|
||||||
if (!player.HealthController.IsAlive)
|
if (_zoneAndPlayers[zone.Key].FindAll(x => x.HealthController.IsAlive).Count > 0)
|
||||||
{
|
{
|
||||||
continue;
|
_content += $"{zone.Key} = {_zoneAndPlayers[zone.Key].FindAll(x => x.HealthController.IsAlive).Count}\n";
|
||||||
}
|
|
||||||
|
|
||||||
_distance = Vector3.Distance(player.Position, _player.Position);
|
// If Mode Greater than or equal to 3 show Bots individually also
|
||||||
_content += $"> [{_distance:n2}m] [{player.Profile.Info.Settings.Role}] [{player.Profile.Side}] [{player.Profile.Info.Settings.BotDifficulty}] {player.Profile.Nickname}\n";
|
if (Mode >= 3)
|
||||||
|
{
|
||||||
|
foreach (var player in _zoneAndPlayers[zone.Key].Where(player => player.HealthController.IsAlive))
|
||||||
|
{
|
||||||
|
_distance = Vector3.Distance(player.Position, _player.Position);
|
||||||
|
_content += $"> [{_distance:n2}m] [{player.Profile.Info.Settings.Role}] [{player.Profile.Side}] [{player.Profile.Info.Settings.BotDifficulty}] {player.Profile.Nickname}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using BepInEx;
|
||||||
using BepInEx;
|
|
||||||
using Comfort.Common;
|
using Comfort.Common;
|
||||||
using EFT;
|
using EFT;
|
||||||
using EFT.Console.Core;
|
using EFT.Console.Core;
|
||||||
@ -16,7 +15,7 @@ namespace CWX_DebuggingTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ConsoleCommand("BotMonitor")]
|
[ConsoleCommand("BotMonitor")]
|
||||||
public static void BotMonitorConsoleCommand([ConsoleArgument("", "Options: 0 = off, 1 = on")] int value )
|
public static void BotMonitorConsoleCommand([ConsoleArgument("", "Options: 0 = off, 1 = Total bots, 2 = 1+Total bots per Zone, 3 = 2+Each bot")] int value )
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@ -25,12 +24,20 @@ namespace CWX_DebuggingTool
|
|||||||
ConsoleScreen.Log("BotMonitor disabled");
|
ConsoleScreen.Log("BotMonitor disabled");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
EnableBotMonitor();
|
EnableBotMonitor(1);
|
||||||
ConsoleScreen.Log("BotMonitor enabled");
|
ConsoleScreen.Log("BotMonitor enabled with only Total");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
EnableBotMonitor(2);
|
||||||
|
ConsoleScreen.Log("BotMonitor enabled with Total and per zone Total");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
EnableBotMonitor(3);
|
||||||
|
ConsoleScreen.Log("BotMonitor enabled with Total, per zone Total and each bot");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// fail to load, or wrong option used
|
// fail to load, or wrong option used
|
||||||
ConsoleScreen.LogError("Wrong Option used, please use 0 or 1");
|
ConsoleScreen.LogError("Wrong Option used, please use 0, 1, 2 or 3");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,13 +47,13 @@ namespace CWX_DebuggingTool
|
|||||||
BotmonClass.Instance.Dispose();
|
BotmonClass.Instance.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableBotMonitor()
|
public static void EnableBotMonitor(int option)
|
||||||
{
|
{
|
||||||
var botmon = BotmonClass.Instance;
|
|
||||||
|
|
||||||
var gameWorld = Singleton<GameWorld>.Instance;
|
var gameWorld = Singleton<GameWorld>.Instance;
|
||||||
|
|
||||||
gameWorld.GetOrAddComponent<BotmonClass>();
|
var btmInstance = gameWorld.GetOrAddComponent<BotmonClass>();
|
||||||
|
|
||||||
|
btmInstance.Mode = option;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user