From be199850d1f00ac63ab4e5cb6cbecdcd4456be25 Mon Sep 17 00:00:00 2001 From: CWXDEV Date: Fri, 12 Jan 2024 14:08:58 +0000 Subject: [PATCH] update botmon from Drakiaxyz repo --- Live/CWX_DebuggingTool/.gitattributes | 63 +++ Live/CWX_DebuggingTool/.gitignore | 364 ++++++++++++++++++ Live/CWX_DebuggingTool/BotmonClass.cs | 69 ++-- .../BepInEx/plugins/CWX_DebuggingTool.dll | Bin 12288 -> 0 bytes .../CWX_DebuggingTool.csproj | 26 +- Live/CWX_DebuggingTool/CWX_DebuggingTool.sln | 25 ++ Live/CWX_DebuggingTool/DebuggingTool.cs | 92 +++-- .../Helpers/EnumExtension.cs | 30 ++ .../Models/BotMonitorMode.cs | 21 + Live/CWX_DebuggingTool/README.md | 4 +- 10 files changed, 603 insertions(+), 91 deletions(-) create mode 100644 Live/CWX_DebuggingTool/.gitattributes create mode 100644 Live/CWX_DebuggingTool/.gitignore delete mode 100644 Live/CWX_DebuggingTool/CWX_DebuggingTool 1.1.0/BepInEx/plugins/CWX_DebuggingTool.dll create mode 100644 Live/CWX_DebuggingTool/CWX_DebuggingTool.sln create mode 100644 Live/CWX_DebuggingTool/Helpers/EnumExtension.cs create mode 100644 Live/CWX_DebuggingTool/Models/BotMonitorMode.cs diff --git a/Live/CWX_DebuggingTool/.gitattributes b/Live/CWX_DebuggingTool/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/Live/CWX_DebuggingTool/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/Live/CWX_DebuggingTool/.gitignore b/Live/CWX_DebuggingTool/.gitignore new file mode 100644 index 0000000..c0f0c51 --- /dev/null +++ b/Live/CWX_DebuggingTool/.gitignore @@ -0,0 +1,364 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ +[Pp]ackage/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/Live/CWX_DebuggingTool/BotmonClass.cs b/Live/CWX_DebuggingTool/BotmonClass.cs index 09eb257..6e07386 100644 --- a/Live/CWX_DebuggingTool/BotmonClass.cs +++ b/Live/CWX_DebuggingTool/BotmonClass.cs @@ -10,10 +10,8 @@ using CWX_DebuggingTool.Models; namespace CWX_DebuggingTool { - public sealed class BotmonClass : MonoBehaviour, IDisposable + public sealed class BotmonClass : MonoBehaviour { - private static BotmonClass _instance; - private GUIContent _guiContent; private GUIStyle _textStyle; private Player _player; @@ -29,35 +27,14 @@ namespace CWX_DebuggingTool private BotmonClass() { + } - public int Mode { get; set; } - - public static BotmonClass Instance - { - get - { - if (_instance == null) - { - _instance = new BotmonClass(); - } - - return _instance; - } - } - - public void Dispose() - { - var gameWorld = Singleton.Instance; - - var gameobj = gameWorld.GetComponent(); - Destroy(gameobj); - _instance = null; - GC.SuppressFinalize(this); - } + public BotMonitorMode Mode { get; set; } ~BotmonClass() { + ConsoleScreen.Log("BotMonitor Disabled on game end"); } public void Awake() @@ -84,7 +61,7 @@ namespace CWX_DebuggingTool } // Add existing Bots to list - if (_gameWorld.RegisteredPlayers.Count > 1) + if (_gameWorld.AllAlivePlayersList.Count > 1) { foreach (var player in _gameWorld.AllAlivePlayersList) { @@ -102,17 +79,25 @@ namespace CWX_DebuggingTool _botGame.BotsController.BotSpawner.OnBotCreated += owner => { var player = owner.GetPlayer; - _zoneAndPlayers[player.AIData.BotOwner.BotsGroup.BotZone.NameZone].Add(player); + _zoneAndPlayers[owner.BotsGroup.BotZone.NameZone].Add(player); _playerRoleAndDiff.Add(player.ProfileId, GetBotRoleAndDiffClass(player.Profile.Info)); }; + + // Sub to event to gget and remove Bot when they despawn + _botGame.BotsController.BotSpawner.OnBotRemoved += owner => + { + var player = owner.GetPlayer; + _zoneAndPlayers[owner.BotsGroup.BotZone.NameZone].Remove(player); + _playerRoleAndDiff.Remove(player.ProfileId); + }; } public BotRoleAndDiffClass GetBotRoleAndDiffClass(InfoClass info) { - var settings = info.GetType().GetField("Settings", BindingFlags.Public | BindingFlags.Instance)?.GetValue(info); + var settings = info.GetType().GetField("Settings", BindingFlags.Public | BindingFlags.Instance).GetValue(info); - var role = settings.GetType().GetField("Role", BindingFlags.Instance | BindingFlags.Public)?.GetValue(settings).ToString(); - var diff = settings.GetType().GetField("BotDifficulty", BindingFlags.Instance | BindingFlags.Public)?.GetValue(settings).ToString(); + var role = settings.GetType().GetField("Role", BindingFlags.Instance | BindingFlags.Public).GetValue(settings).ToString(); + var diff = settings.GetType().GetField("BotDifficulty", BindingFlags.Instance | BindingFlags.Public).GetValue(settings).ToString(); return new BotRoleAndDiffClass(string.IsNullOrEmpty(role) ? "" : role, string.IsNullOrEmpty(diff) ? "" : diff); } @@ -134,26 +119,26 @@ namespace CWX_DebuggingTool _guiContent = new GUIContent(); } - // If Mode Greater than or equal to 1 show total - if (Mode >= 1) + // If Mode Greater than or equal to Total show total + if (Mode >= BotMonitorMode.Total) { _content = string.Empty; _content += $"Total = {_gameWorld.AllAlivePlayersList.Count - 1}\n"; } - // If Mode Greater than or equal to 2 show total for each zone - if (Mode >= 2 && _zoneAndPlayers != null) + // If Mode Greater than or equal to PerZoneTotal show total for each zone + if (Mode >= BotMonitorMode.PerZoneTotal && _zoneAndPlayers != null) { foreach (var zone in _zoneAndPlayers) { - if (_zoneAndPlayers[zone.Key].FindAll(x => x != null && x.HealthController != null && x.HealthController.IsAlive).Count <= 0) continue; + if (_zoneAndPlayers[zone.Key].FindAll(x => x.HealthController.IsAlive).Count <= 0) continue; - _content += $"{zone.Key} = {_zoneAndPlayers[zone.Key].FindAll(x => x != null && x.HealthController != null && x.HealthController.IsAlive).Count}\n"; + _content += $"{zone.Key} = {_zoneAndPlayers[zone.Key].FindAll(x => x.HealthController.IsAlive).Count}\n"; - // If Mode Greater than or equal to 3 show Bots individually also - if (Mode < 3) continue; + // If Mode Greater than or equal to FullList show Bots individually also + if (Mode < BotMonitorMode.FullList) continue; - foreach (var player in _zoneAndPlayers[zone.Key].Where(player => player != null && player.HealthController != null && player.HealthController.IsAlive)) + foreach (var player in _zoneAndPlayers[zone.Key].Where(player => player.HealthController.IsAlive)) { _distance = Vector3.Distance(player.Position, _player.Position); _content += $"> [{_distance:n2}m] [{_playerRoleAndDiff.First(x => x.Key == player.ProfileId).Value.Role}] " + @@ -161,7 +146,7 @@ namespace CWX_DebuggingTool } } } - + _guiContent.text = _content; _guiSize = _textStyle.CalcSize(_guiContent); diff --git a/Live/CWX_DebuggingTool/CWX_DebuggingTool 1.1.0/BepInEx/plugins/CWX_DebuggingTool.dll b/Live/CWX_DebuggingTool/CWX_DebuggingTool 1.1.0/BepInEx/plugins/CWX_DebuggingTool.dll deleted file mode 100644 index 5f1755d7ad8988a0290e484503298bf1de29fd19..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeHNeQ+Grk?;3rclJZ_TDy|v4;j3+!7TdNNU}|A<1c-zY+=i?E%}R>$gACvwDxL8 zp4qi6gdF(-zHvvpqN8O&Sq-a9+4T^d(&R*r?#I2UBPc zE&7`feIfAl;xCD@9zp6W1J~E8Ces8Y%5LSWL7swY0D?+oKDXeSu5^I5Qn4}tH z5_1br7NEmqfKfTYoQXPSV2V6)2@e4<)?UPjYy>tq3Ew@kHYQk081#?^e->Xj?i>1Vq9ll%PlWBmY4`+(7X;{ z?zF7*uYOQ@T;3K#+pLDe5iN!(4_139>@gA0V6`6B8)d^@Il&VLW&@ZK*G60?ngC*O zRX34bLGJS&Tum(2pxMHpmBDg=YOiB^*lVr;3CWeXz;Z2i1CXYZuw0w2g|4FIaF%0f zz8B5rDgZgHql0d*X2u!-suu{MB!lAj&}?=|(ld0tM<~3ySyQQx_=ia|Z$t;H12eFw z##{?rGuHtIb*EuhsX{; zKYbdri`hfYOaSxLObcZ4CS=e?C^6dr>~?@jZgfQEo3Jv!EXreeSfUc3M>W8#j@*GAY$DR zj@?x3;i{Y0TH#D*&9v4aYG(yjuf`~B2Ir@_1>)77RX*?{p4e8Vylz{>8|wkBlHfQB zg6G<%xyz2DNO-1otWe$FhSqDRxWz;zc9OPsTEcpjir!UEVC`XnDZ}rB;jTt!=!?{& zvXraGLNBW4mXdnM(d`(mWYYR0ku$*gjAuBCE&PHS1Y)Esn#B*Ss0vPUKyg7A&VLYC*j8 zi~7C~ePjC>+yb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8<(jrC znP&Ly{H?%V95KMoJc7O*7;O~$E8ZiH!y{)`&iXrO4}KFe06Dy#!fp&N8r(5>*T_3_ z{N`2ZD2~aJHuiUHOKB(f+v;jYO&2qf*bQA4v^l#$*3p7*7tJ##k6jCSj#ysF@_ss7 z=D}~aKaSmHR{0Ub>)L@*aCsJ)Q9r$Gi98*#7|^ V8=c>>eEfz#U>pBv+V3p_{|DH`i68&~ diff --git a/Live/CWX_DebuggingTool/CWX_DebuggingTool.csproj b/Live/CWX_DebuggingTool/CWX_DebuggingTool.csproj index df75912..013ec13 100644 --- a/Live/CWX_DebuggingTool/CWX_DebuggingTool.csproj +++ b/Live/CWX_DebuggingTool/CWX_DebuggingTool.csproj @@ -2,39 +2,45 @@ net472 + + 2.2.0.0 - ..\..\..\Shared\Aki.Common.dll + ..\..\EscapeFromTarkov_Data\Managed\Aki.Common.dll - ..\..\..\Shared\Aki.Reflection.dll + ..\..\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll - ..\..\..\Shared\Assembly-CSharp.dll + ..\..\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll - ..\..\..\Shared\BepInEx.dll + ..\..\BepInEx\Core\BepInEx.dll - ..\..\..\Shared\bsg.console.core.dll + ..\..\EscapeFromTarkov_Data\Managed\bsg.console.core.dll - ..\..\..\Shared\Comfort.dll + ..\..\EscapeFromTarkov_Data\Managed\Comfort.dll - ..\..\..\Shared\UnityEngine.dll + ..\..\EscapeFromTarkov_Data\Managed\UnityEngine.dll - ..\..\..\Shared\UnityEngine.CoreModule.dll + ..\..\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll - ..\..\..\Shared\UnityEngine.IMGUIModule.dll + ..\..\EscapeFromTarkov_Data\Managed\UnityEngine.IMGUIModule.dll - ..\..\..\Shared\UnityEngine.TextRenderingModule.dll + ..\..\EscapeFromTarkov_Data\Managed\UnityEngine.TextRenderingModule.dll + + + + diff --git a/Live/CWX_DebuggingTool/CWX_DebuggingTool.sln b/Live/CWX_DebuggingTool/CWX_DebuggingTool.sln new file mode 100644 index 0000000..8ae8a31 --- /dev/null +++ b/Live/CWX_DebuggingTool/CWX_DebuggingTool.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33801.468 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_DebuggingTool", "CWX_DebuggingTool.csproj", "{FC152A95-1628-4DE9-A92E-38B368C188D0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FC152A95-1628-4DE9-A92E-38B368C188D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC152A95-1628-4DE9-A92E-38B368C188D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC152A95-1628-4DE9-A92E-38B368C188D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC152A95-1628-4DE9-A92E-38B368C188D0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {37A296E5-8559-4E04-8B2B-02B32F793C6E} + EndGlobalSection +EndGlobal diff --git a/Live/CWX_DebuggingTool/DebuggingTool.cs b/Live/CWX_DebuggingTool/DebuggingTool.cs index eeb3094..4de6d42 100644 --- a/Live/CWX_DebuggingTool/DebuggingTool.cs +++ b/Live/CWX_DebuggingTool/DebuggingTool.cs @@ -1,64 +1,82 @@ -using BepInEx; +using Aki.Reflection.Patching; +using BepInEx; +using BepInEx.Configuration; using Comfort.Common; +using CWX_DebuggingTool.Helpers; +using CWX_DebuggingTool.Models; using EFT; using EFT.Console.Core; using EFT.UI; +using System.Reflection; namespace CWX_DebuggingTool { - [BepInPlugin("com.cwx.debuggingtool", "cwx-debuggingtool", "1.1.0")] + [BepInPlugin("com.cwx.debuggingtool-dxyz", "cwx-debuggingtool-dxyz", "2.2.1")] public class DebuggingTool : BaseUnityPlugin { + public static ConfigEntry DefaultMode; + private void Awake() { + DefaultMode = Config.Bind( + "Main Settings", + "DefaultMode", + BotMonitorMode.None, + "Default Mode on Startup"); + ConsoleScreen.Processor.RegisterCommandGroup(); + new MatchStartPatch().Enable(); } [ConsoleCommand("BotMonitor")] - public static void BotMonitorConsoleCommand([ConsoleArgument("", "Options: 0 = off, 1 = Total bots, 2 = 1+Total bots per Zone, 3 = 2+Each bot")] int value ) + public static void BotMonitorConsoleCommand([ConsoleArgument("", "Options: 0 = off, 1 = Total bots, 2 = 1+Total bots per Zone, 3 = 2+Each bot")] BotMonitorMode mode ) { - switch (value) + if (mode == BotMonitorMode.None) { - case 0: - DisableBotMonitor(); - ConsoleScreen.Log("BotMonitor disabled"); - break; - case 1: - EnableBotMonitor(1); - 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; - default: - // fail to load, or wrong option used - ConsoleScreen.LogError("Wrong Option used, please use 0, 1, 2 or 3"); - break; + DisableBotMonitor(); + ConsoleScreen.Log("BotMonitor disabled"); + } + else if (!mode.IsValid()) + { + ConsoleScreen.LogError("Wrong Option used, please use 0, 1, 2 or 3"); + } + else + { + ConsoleScreen.Log($"BotMonitor enabled with {mode.Description()}"); + EnableBotMonitor(mode); } } - private static void DisableBotMonitor() - { - BotmonClass.Instance.Dispose(); - } - - private static void EnableBotMonitor(int option) + public static void DisableBotMonitor() { var gameWorld = Singleton.Instance; + var btmInstance = gameWorld.GetComponent(); + if (btmInstance != null) + { + Destroy(btmInstance); + } + } - var checkExists = gameWorld.gameObject.GetComponentInChildren(); - - if (checkExists != null) - Destroy(checkExists); - - var btmInstance = gameWorld.gameObject.AddComponent(); + public static void EnableBotMonitor(BotMonitorMode mode) + { + var gameWorld = Singleton.Instance; + var btmInstance = gameWorld.GetOrAddComponent(); + btmInstance.Mode = mode; + } - btmInstance.Mode = option; + // Add the component every time a match starts if enabled + internal class MatchStartPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() => typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted)); + + [PatchPrefix] + public static void PatchPrefix() + { + if (DefaultMode.Value != BotMonitorMode.None) + { + EnableBotMonitor(DefaultMode.Value); + } + } } } } \ No newline at end of file diff --git a/Live/CWX_DebuggingTool/Helpers/EnumExtension.cs b/Live/CWX_DebuggingTool/Helpers/EnumExtension.cs new file mode 100644 index 0000000..bd388b7 --- /dev/null +++ b/Live/CWX_DebuggingTool/Helpers/EnumExtension.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace CWX_DebuggingTool.Helpers +{ + internal static class EnumExtension + { + public static string Description(this T src) where T : Enum + { + FieldInfo fi = src.GetType().GetField(src.ToString()); + DescriptionAttribute[] attributes = fi.GetCustomAttributes(false) as DescriptionAttribute[]; + if (attributes != null && attributes.Length > 0) + { + return attributes[0].Description; + } + + return ""; + } + + public static bool IsValid(this T src) where T : Enum + { + return Enum.GetValues(typeof(T)).Cast().Contains(src); + } + } +} diff --git a/Live/CWX_DebuggingTool/Models/BotMonitorMode.cs b/Live/CWX_DebuggingTool/Models/BotMonitorMode.cs new file mode 100644 index 0000000..24dc33a --- /dev/null +++ b/Live/CWX_DebuggingTool/Models/BotMonitorMode.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CWX_DebuggingTool.Models +{ + public enum BotMonitorMode + { + [Description("Disabled")] + None = 0, + [Description("Only Total")] + Total = 1, + [Description("Total and Per Zone Total")] + PerZoneTotal = 2, + [Description("Total, Per Zone Total, and Bot List")] + FullList = 3 + } +} diff --git a/Live/CWX_DebuggingTool/README.md b/Live/CWX_DebuggingTool/README.md index ca1f2dd..9c98cbe 100644 --- a/Live/CWX_DebuggingTool/README.md +++ b/Live/CWX_DebuggingTool/README.md @@ -1,5 +1,5 @@ # DebuggingTool ## CWX-DEBUGGINGTOOL for EFT - SPT-AKI -### CURRENT AKI VERSION: 3.5.1 -### GAMEVERSION: 22032 +### CURRENT AKI VERSION: 3.5.7 +### GAMEVERSION: 23399 ### USING BEPINEX