forked from CWX/CWX-mods
added new mod CWX_AlarmChanger, gives the ability to load sounds for the reserve alarm. updated botmon to hopefully be less version specific
This commit is contained in:
parent
546269e10d
commit
094300ec84
25
Live/CWX_AlarmChanger/AlarmChanger.cs
Normal file
25
Live/CWX_AlarmChanger/AlarmChanger.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using BepInEx;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace CWX_AlarmChanger
|
||||
{
|
||||
[BepInPlugin("com.cwx.alarmchanger", "cwx-alarmchanger", "1.0.0")]
|
||||
public class AlarmChanger : BaseUnityPlugin
|
||||
{
|
||||
public static GameObject CWX_GameObject;
|
||||
public static AlarmChangerScript CWX_Component;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
CWX_GameObject = new GameObject("CWX_GameObject");
|
||||
DontDestroyOnLoad(CWX_GameObject);
|
||||
CWX_Component = CWX_GameObject.AddComponent<AlarmChangerScript>();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
new AlarmChangerPatch().Enable();
|
||||
}
|
||||
}
|
||||
}
|
26
Live/CWX_AlarmChanger/AlarmChangerPatch.cs
Normal file
26
Live/CWX_AlarmChanger/AlarmChangerPatch.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
using System.Reflection;
|
||||
|
||||
namespace CWX_AlarmChanger
|
||||
{
|
||||
public class AlarmChangerPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return typeof(GameWorld).GetMethod("OnGameStarted", BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void PatchPostFix()
|
||||
{
|
||||
var gameWorld = Singleton<GameWorld>.Instance;
|
||||
|
||||
if (gameWorld != null && gameWorld.MainPlayer.Location.ToLower() == "rezervbase")
|
||||
{
|
||||
AlarmChanger.CWX_Component.SetSounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
71
Live/CWX_AlarmChanger/AlarmChangerScript.cs
Normal file
71
Live/CWX_AlarmChanger/AlarmChangerScript.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using EFT.Interactive;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace CWX_AlarmChanger
|
||||
{
|
||||
public class AlarmChangerScript : MonoBehaviour
|
||||
{
|
||||
private List<AudioClip> _clips = new List<AudioClip>();
|
||||
|
||||
public void Start()
|
||||
{
|
||||
LoadAudioFilePaths();
|
||||
}
|
||||
|
||||
public void SetSounds()
|
||||
{
|
||||
if (_clips.Count <= 0) return;
|
||||
|
||||
var subscribers = FindObjectsOfType<InteractiveSubscriber>().Where(x => x.name.Contains("Siren_")).ToList();
|
||||
|
||||
foreach (var sub in subscribers)
|
||||
{
|
||||
sub.Sounds[0].Clip = _clips[UnityEngine.Random.Range(0, _clips.Count)];
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAudioFilePaths()
|
||||
{
|
||||
var AudioFiles = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "/BepInEx/plugins/CWX_AlarmChanger/Sounds/");
|
||||
foreach (var File in AudioFiles)
|
||||
{
|
||||
LoadAudioClip(File);
|
||||
}
|
||||
}
|
||||
|
||||
private async void LoadAudioClip(string path)
|
||||
{
|
||||
var audioClip = await RequestAudioClip(path);
|
||||
|
||||
_clips.Add(audioClip);
|
||||
}
|
||||
|
||||
private async Task<AudioClip> RequestAudioClip(string path)
|
||||
{
|
||||
|
||||
UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.WAV);
|
||||
|
||||
var sendWeb = www.SendWebRequest();
|
||||
|
||||
while (!sendWeb.isDone)
|
||||
{
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
if (www.isNetworkError || www.isHttpError)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
AudioClip audioclip = DownloadHandlerAudioClip.GetContent(www);
|
||||
|
||||
return audioclip;
|
||||
}
|
||||
}
|
||||
}
|
37
Live/CWX_AlarmChanger/CWX_AlarmChanger.csproj
Normal file
37
Live/CWX_AlarmChanger/CWX_AlarmChanger.csproj
Normal file
@ -0,0 +1,37 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Aki.Reflection">
|
||||
<HintPath>..\..\..\Shared\Aki.Reflection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\..\Shared\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BepInEx">
|
||||
<HintPath>..\..\..\Shared\BepInEx.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort">
|
||||
<HintPath>..\..\..\Shared\Comfort.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\..\..\Shared\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.AudioModule">
|
||||
<HintPath>..\..\..\Shared\UnityEngine.AudioModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\..\..\Shared\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UnityWebRequestAudioModule">
|
||||
<HintPath>..\..\..\Shared\UnityEngine.UnityWebRequestAudioModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UnityWebRequestModule">
|
||||
<HintPath>..\..\..\Shared\UnityEngine.UnityWebRequestModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -5,6 +5,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using System.Reflection;
|
||||
using CWX_DebuggingTool.Models;
|
||||
|
||||
namespace CWX_DebuggingTool
|
||||
{
|
||||
@ -16,11 +18,12 @@ namespace CWX_DebuggingTool
|
||||
private GUIStyle _textStyle;
|
||||
private Player _player;
|
||||
private Dictionary<string, List<Player>> _zoneAndPlayers = new Dictionary<string, List<Player>>();
|
||||
private Dictionary<string, BotRoleAndDiffClass> _playerRoleAndDiff = new Dictionary<string, BotRoleAndDiffClass>();
|
||||
private List<BotZone> _zones;
|
||||
private GameWorld _gameWorld;
|
||||
private IBotGame _botGame;
|
||||
private Rect _rect;
|
||||
private String _content = "";
|
||||
private string _content = "";
|
||||
private Vector2 _guiSize;
|
||||
private float _distance;
|
||||
|
||||
@ -87,25 +90,35 @@ namespace CWX_DebuggingTool
|
||||
{
|
||||
foreach (var player in _gameWorld.AllPlayers)
|
||||
{
|
||||
if (!player.IsYourPlayer)
|
||||
{
|
||||
if (player.IsYourPlayer) continue;
|
||||
|
||||
_playerRoleAndDiff.Add(player.ProfileId, GetBotRoleAndDiffClass(player.Profile.Info));
|
||||
|
||||
var theirZone = player.AIData.BotOwner.BotsGroup.BotZone.NameZone;
|
||||
|
||||
_zoneAndPlayers[theirZone].Add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sub to Event to get and add Bot when they spawn
|
||||
_botGame.BotsController.BotSpawner.OnBotCreated += owner =>
|
||||
{
|
||||
Player player = owner.GetPlayer;
|
||||
var theirZone = player.AIData.BotOwner.BotsGroup.BotZone.NameZone;
|
||||
|
||||
_zoneAndPlayers[theirZone].Add(player);
|
||||
var player = owner.GetPlayer;
|
||||
_zoneAndPlayers[player.AIData.BotOwner.BotsGroup.BotZone.NameZone].Add(player);
|
||||
_playerRoleAndDiff.Add(player.ProfileId, GetBotRoleAndDiffClass(player.Profile.Info));
|
||||
};
|
||||
}
|
||||
|
||||
public BotRoleAndDiffClass GetBotRoleAndDiffClass(InfoClass 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();
|
||||
|
||||
return new BotRoleAndDiffClass(string.IsNullOrEmpty(role) ? "" : role, string.IsNullOrEmpty(diff) ? "" : diff);
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
// set basics on GUI
|
||||
@ -131,26 +144,22 @@ namespace CWX_DebuggingTool
|
||||
}
|
||||
|
||||
// If Mode Greater than or equal to 2 show total for each zone
|
||||
if (Mode >= 2)
|
||||
{
|
||||
if (_zoneAndPlayers != null)
|
||||
if (Mode >= 2 && _zoneAndPlayers != null)
|
||||
{
|
||||
foreach (var zone in _zoneAndPlayers)
|
||||
{
|
||||
if (_zoneAndPlayers[zone.Key].FindAll(x => x.HealthController.IsAlive).Count > 0)
|
||||
{
|
||||
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";
|
||||
|
||||
// If Mode Greater than or equal to 3 show Bots individually also
|
||||
if (Mode >= 3)
|
||||
{
|
||||
if (Mode < 3) continue;
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
_content += $"> [{_distance:n2}m] [{_playerRoleAndDiff.First(x => x.Key == player.ProfileId).Value.Role}] " +
|
||||
$"[{player.Profile.Side}] [{_playerRoleAndDiff.First(x => x.Key == player.ProfileId).Value.Difficulty}] {player.Profile.Nickname}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace CWX_DebuggingTool
|
||||
{
|
||||
var gameWorld = Singleton<GameWorld>.Instance;
|
||||
|
||||
var btmInstance = gameWorld.GetOrAddComponent<BotmonClass>();
|
||||
var btmInstance = gameWorld.gameObject.AddComponent<BotmonClass>();
|
||||
|
||||
btmInstance.Mode = option;
|
||||
}
|
||||
|
14
Live/CWX_DebuggingTool/Models/BotRoleAndDiffClass.cs
Normal file
14
Live/CWX_DebuggingTool/Models/BotRoleAndDiffClass.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace CWX_DebuggingTool.Models
|
||||
{
|
||||
public class BotRoleAndDiffClass
|
||||
{
|
||||
public BotRoleAndDiffClass(string role = "", string difficulty = "")
|
||||
{
|
||||
Role = role;
|
||||
Difficulty = difficulty;
|
||||
}
|
||||
|
||||
public string Role { get; set; }
|
||||
public string Difficulty { get; set; }
|
||||
}
|
||||
}
|
@ -11,11 +11,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_DeSharpener", "CWX_DeSh
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_MasterKey", "CWX_MasterKey\CWX_MasterKey.csproj", "{40BE277F-55BE-4579-9535-D1F5ED9CC549}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CWX_DebuggingTool", "CWX_DebuggingTool\CWX_DebuggingTool.csproj", "{E439D92F-26FD-42A2-9EA5-38A318EB5403}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_DebuggingTool", "CWX_DebuggingTool\CWX_DebuggingTool.csproj", "{E439D92F-26FD-42A2-9EA5-38A318EB5403}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CWX_ColourAdderPrePatch", "CWX_ColourAdderPrePatch\CWX_ColourAdderPrePatch.csproj", "{B0AE824D-7308-47DD-B0BF-08D48B33CBD7}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_ColourAdderPrePatch", "CWX_ColourAdderPrePatch\CWX_ColourAdderPrePatch.csproj", "{B0AE824D-7308-47DD-B0BF-08D48B33CBD7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CWX_ColourAdderPatcher", "CWX_ColourAdderPatcher\CWX_ColourAdderPatcher.csproj", "{6D696C6A-011B-4D53-8D97-D62105B20E0E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_ColourAdderPatcher", "CWX_ColourAdderPatcher\CWX_ColourAdderPatcher.csproj", "{6D696C6A-011B-4D53-8D97-D62105B20E0E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CWX_AlarmChanger", "CWX_AlarmChanger\CWX_AlarmChanger.csproj", "{518D3743-AE98-41CD-8A6A-7B537C3FC293}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -51,6 +53,10 @@ Global
|
||||
{6D696C6A-011B-4D53-8D97-D62105B20E0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6D696C6A-011B-4D53-8D97-D62105B20E0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6D696C6A-011B-4D53-8D97-D62105B20E0E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{518D3743-AE98-41CD-8A6A-7B537C3FC293}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{518D3743-AE98-41CD-8A6A-7B537C3FC293}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{518D3743-AE98-41CD-8A6A-7B537C3FC293}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{518D3743-AE98-41CD-8A6A-7B537C3FC293}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Loading…
x
Reference in New Issue
Block a user