forked from CWX/CWX-mods
attempt three
This commit is contained in:
parent
6e5e89a604
commit
55f12324f5
@ -6,7 +6,6 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Comfort.Common;
|
using Comfort.Common;
|
||||||
using EFT;
|
using EFT;
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace CWX_DebuggingTool
|
namespace CWX_DebuggingTool
|
||||||
{
|
{
|
||||||
@ -20,11 +19,7 @@ namespace CWX_DebuggingTool
|
|||||||
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 = null;
|
||||||
private GameWorld _gameWorld = null;
|
private GameWorld _gameWorld = null;
|
||||||
|
private IBotGame _botGame;
|
||||||
private float updateTimer;
|
|
||||||
private float updateRate = 5f;
|
|
||||||
private float GuiTimer;
|
|
||||||
private float GuiRate = 5f;
|
|
||||||
|
|
||||||
private BotmonClass()
|
private BotmonClass()
|
||||||
{
|
{
|
||||||
@ -64,56 +59,42 @@ namespace CWX_DebuggingTool
|
|||||||
// Set Basics
|
// Set Basics
|
||||||
_gameWorld = Singleton<GameWorld>.Instance;
|
_gameWorld = Singleton<GameWorld>.Instance;
|
||||||
|
|
||||||
// get all zones
|
_botGame = Singleton<IBotGame>.Instance;
|
||||||
|
|
||||||
_zones = LocationScene.GetAllObjects<BotZone>().ToList();
|
_zones = LocationScene.GetAllObjects<BotZone>().ToList();
|
||||||
|
|
||||||
foreach (var zone in _zones)
|
foreach (var botZone in _zones)
|
||||||
{
|
{
|
||||||
// add zones and a new list of players
|
_zoneAndPlayers.Add(botZone.name, new List<Player>());
|
||||||
_zoneAndPlayers.Add(zone.NameZone, new List<Player>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get player
|
// get player
|
||||||
_player = _gameWorld.AllPlayers.Find(x => x.IsYourPlayer);
|
_player = _gameWorld.AllPlayers.Find(x => x.IsYourPlayer);
|
||||||
|
|
||||||
}
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
if (!Application.isFocused) return;
|
|
||||||
|
|
||||||
updateTimer += Time.deltaTime;
|
|
||||||
|
|
||||||
if (updateTimer < updateRate) return;
|
|
||||||
|
|
||||||
updateTimer = 0;
|
|
||||||
|
|
||||||
if (_gameWorld == null) return;
|
|
||||||
|
|
||||||
if (_gameWorld.AllPlayers.Count > 1)
|
if (_gameWorld.AllPlayers.Count > 1)
|
||||||
{
|
{
|
||||||
foreach (var player in _gameWorld.AllPlayers)
|
foreach (var player in _gameWorld.AllPlayers)
|
||||||
{
|
{
|
||||||
if (!player.IsYourPlayer)
|
if (!player.IsYourPlayer)
|
||||||
{
|
{
|
||||||
var zoneName = player.AIData.BotOwner.BotsGroup.BotZone.NameZone;
|
var theirZone = player.AIData.BotOwner.BotsGroup.BotZone.NameZone;
|
||||||
|
|
||||||
if (_zoneAndPlayers.ContainsKey(zoneName) && !_zoneAndPlayers[zoneName].Contains(player))
|
_zoneAndPlayers[theirZone].Add(player);
|
||||||
{
|
|
||||||
_zoneAndPlayers[zoneName].Add(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_botGame.BotsController.BotSpawner.OnBotCreated += owner =>
|
||||||
|
{
|
||||||
|
Player player = owner.GetPlayer;
|
||||||
|
var theirZone = player.AIData.BotOwner.BotsGroup.BotZone.NameZone;
|
||||||
|
|
||||||
|
_zoneAndPlayers[theirZone].Add(player);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGUI()
|
public void OnGUI()
|
||||||
{
|
{
|
||||||
GuiTimer += Time.deltaTime;
|
|
||||||
|
|
||||||
if (GuiRate < GuiTimer) return;
|
|
||||||
|
|
||||||
GuiTimer = 0;
|
|
||||||
|
|
||||||
// set basics on GUI
|
// set basics on GUI
|
||||||
if (_textStyle == null)
|
if (_textStyle == null)
|
||||||
{
|
{
|
||||||
@ -133,7 +114,7 @@ namespace CWX_DebuggingTool
|
|||||||
|
|
||||||
if (_zoneAndPlayers != null)
|
if (_zoneAndPlayers != null)
|
||||||
{
|
{
|
||||||
var total = 0;
|
_stringBuilder.AppendLine($"Total = {_gameWorld.AllPlayers.Count - 1}");
|
||||||
|
|
||||||
foreach (var zone in _zoneAndPlayers)
|
foreach (var zone in _zoneAndPlayers)
|
||||||
{
|
{
|
||||||
@ -149,13 +130,10 @@ namespace CWX_DebuggingTool
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
total++;
|
|
||||||
var distance = Vector3.Distance(player.Position, _player.Position);
|
var distance = Vector3.Distance(player.Position, _player.Position);
|
||||||
_stringBuilder.AppendLine($"> [{distance:n2}m] [{player.Profile.Info.Settings.Role}] [{player.Profile.Side}] {player.Profile.Nickname}");
|
_stringBuilder.AppendLine($"> [{distance:n2}m] [{player.Profile.Info.Settings.Role}] [{player.Profile.Side}] [{player.Profile.Info.Settings.BotDifficulty}]{player.Profile.Nickname}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_stringBuilder.PrependLine($"Total = {total}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_guiContent.text = _stringBuilder.ToString();
|
_guiContent.text = _stringBuilder.ToString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user