diff --git a/Projects/GeneburnFullPack/GeneburnFullPack.sln b/Projects/GeneburnFullPack/GeneburnFullPack.sln new file mode 100644 index 0000000..aff567e --- /dev/null +++ b/Projects/GeneburnFullPack/GeneburnFullPack.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32002.261 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeneburnFullPack", "GeneburnFullPack\GeneburnFullPack.csproj", "{3D58CD1F-7F05-4C84-869E-2E2BEECB92E2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3D58CD1F-7F05-4C84-869E-2E2BEECB92E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D58CD1F-7F05-4C84-869E-2E2BEECB92E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D58CD1F-7F05-4C84-869E-2E2BEECB92E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D58CD1F-7F05-4C84-869E-2E2BEECB92E2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7686535A-69E6-4BF6-BD67-2476871388B0} + EndGlobalSection +EndGlobal diff --git a/Projects/GeneburnFullPack/GeneburnFullPack/GeneburnFullPack.csproj b/Projects/GeneburnFullPack/GeneburnFullPack/GeneburnFullPack.csproj new file mode 100644 index 0000000..a322db6 --- /dev/null +++ b/Projects/GeneburnFullPack/GeneburnFullPack/GeneburnFullPack.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {3D58CD1F-7F05-4C84-869E-2E2BEECB92E2} + Library + Properties + GeneburnFullPack + GeneburnFullPack + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + False + ..\..\..\References\Aki.Reflection.dll + + + False + ..\..\..\References\Assembly-CSharp.dll + + + False + ..\..\..\References\BepInEx.dll + + + + False + ..\..\..\References\UnityEngine.dll + + + False + ..\..\..\References\UnityEngine.AssetBundleModule.dll + + + False + ..\..\..\References\UnityEngine.AudioModule.dll + + + False + ..\..\..\References\UnityEngine.CoreModule.dll + + + + \ No newline at end of file diff --git a/Projects/GeneburnFullPack/GeneburnFullPack/GeneburnMusicPlugin.cs b/Projects/GeneburnFullPack/GeneburnFullPack/GeneburnMusicPlugin.cs new file mode 100644 index 0000000..a059383 --- /dev/null +++ b/Projects/GeneburnFullPack/GeneburnFullPack/GeneburnMusicPlugin.cs @@ -0,0 +1,14 @@ +using BepInEx; + +namespace GeneburnFullPack +{ + [BepInPlugin("com.samswat.geneburnmusic", "SamSWAT.GeneburnFullPack", "1.1.0")] + public class GeneburnMusicPlugin : BaseUnityPlugin + { + private void Awake() + { + Logger.LogInfo("Loading: SamSWAT-GeneburnPack"); + new MusicPatch().Enable(); + } + } +} diff --git a/Projects/GeneburnFullPack/GeneburnFullPack/MusicPatch.cs b/Projects/GeneburnFullPack/GeneburnFullPack/MusicPatch.cs new file mode 100644 index 0000000..509b271 --- /dev/null +++ b/Projects/GeneburnFullPack/GeneburnFullPack/MusicPatch.cs @@ -0,0 +1,30 @@ +using Aki.Reflection.Patching; +using EFT.UI; +using System.Linq; +using System.Reflection; +using UnityEngine; + +namespace GeneburnFullPack +{ + public class MusicPatch : ModulePatch + { + private static AudioClip[] musicClips; + + public MusicPatch() + { + var path = (BepInEx.Paths.PluginPath + "/SamSWAT.GeneburnFullPack");//.Replace("\\", "/"); + var Geneburn = AssetBundle.LoadFromFile(System.IO.Path.Combine(path, "bundles/geneburnpack.bundle")); + musicClips = Geneburn.LoadAllAssets(); + } + protected override MethodBase GetTargetMethod() + { + return typeof(GUISounds).GetMethod("method_1", BindingFlags.NonPublic | BindingFlags.Instance); + } + + [PatchPrefix] + private static void PatchPrefix(ref AudioClip[] ___audioClip_0) + { + ___audioClip_0 = ___audioClip_0.Concat(musicClips).ToArray(); + } + } +} diff --git a/Projects/GeneburnFullPack/GeneburnFullPack/Properties/AssemblyInfo.cs b/Projects/GeneburnFullPack/GeneburnFullPack/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c03bd89 --- /dev/null +++ b/Projects/GeneburnFullPack/GeneburnFullPack/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные со сборкой. +[assembly: AssemblyTitle("GeneburnFullPack")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GeneburnFullPack")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("3d58cd1f-7f05-4c84-869e-2e2beecb92e2")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic.sln b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic.sln new file mode 100644 index 0000000..12d4b79 --- /dev/null +++ b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32002.261 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamSWAT.CustomMusic", "SamSWAT.CustomMusic\SamSWAT.CustomMusic.csproj", "{8EAD7664-C80F-40D3-AED1-1FE561A0023E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8EAD7664-C80F-40D3-AED1-1FE561A0023E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EAD7664-C80F-40D3-AED1-1FE561A0023E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EAD7664-C80F-40D3-AED1-1FE561A0023E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EAD7664-C80F-40D3-AED1-1FE561A0023E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D743D95D-5A68-4C6B-B9D9-6FA28602F4E1} + EndGlobalSection +EndGlobal diff --git a/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/CustomMusicPatch.cs b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/CustomMusicPatch.cs new file mode 100644 index 0000000..294c9b7 --- /dev/null +++ b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/CustomMusicPatch.cs @@ -0,0 +1,101 @@ +using Aki.Reflection.Patching; +using EFT.UI; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using UnityEngine; +using UnityEngine.Networking; +using BepInEx; + +namespace SamSWAT.CustomMusic +{ + public class CustomMusicPatch : ModulePatch + { + private static Dictionary ReplaceOriginal; + private static string CurrDir { get; set; } + + private static List musicClips = new List(); + + public CustomMusicPatch() + { + CurrDir = BepInEx.Paths.PluginPath + "/SamSWAT.CustomMusic"; + string json = new StreamReader(Path.Combine(CurrDir, "config.json")).ReadToEnd(); + ReplaceOriginal = JsonConvert.DeserializeObject>(json); + + string[] files = Directory.GetFiles(CurrDir + "/music"); + + foreach (var song in files) + { + Logger.LogInfo(song); + string url = "file:///" + song.Replace("\\", "/"); + if (song.Contains(".mp3")) + LoadAudio(url, AudioType.MPEG); + else if (song.Contains(".wav")) + LoadAudio(url, AudioType.WAV); + else if (song.Contains(".ogg")) + LoadAudio(url, AudioType.OGGVORBIS); + else + LoadAudio(url, AudioType.UNKNOWN); + } + } + + private async void LoadAudio(string url, AudioType audioType) + { + using (UnityWebRequest web = UnityWebRequestMultimedia.GetAudioClip(url, audioType)) + { + Logger.LogInfo("url: " + url); + var operation = web.SendWebRequest(); + while (!operation.isDone) + { + Logger.LogInfo("operation pending.."); + await Task.Yield(); + } + + if (!web.isNetworkError && !web.isHttpError) + { + var clip = DownloadHandlerAudioClip.GetContent(web); + Logger.LogInfo("AudioClip: " + clip.loadState + " " + clip.frequency); + string audioclipname = url.Replace("file:///"+ (CurrDir + "/music/").Replace("\\","/"), ""); + clip.name = audioclipname; + musicClips.Add(clip); + } + else + { + var Error = web.error; + Debug.LogErrorFormat("Can't load audio at path:'{0}', error:{1}", new object[] + { + url, + Error + }); + } + } + } + + protected override MethodBase GetTargetMethod() + { + return typeof(GUISounds).GetMethod("method_1", BindingFlags.NonPublic | BindingFlags.Instance); + } + + [PatchPostfix] + private static void PatchPostfix(ref AudioClip[] ___audioClip_0, object __instance) + { + if (ReplaceOriginal["ReplaceOriginalMusic"]) + ___audioClip_0 = musicClips.ToArray(); + else + ___audioClip_0 = ___audioClip_0.Concat(musicClips).ToArray(); + + foreach (var clip in musicClips) + { + Logger.LogInfo("clip in array: " + clip.name); + } + + foreach (var clip2 in ___audioClip_0) + { + Logger.LogInfo("\n \n \n" + "original cips: " + clip2.name); + } + } + } +} diff --git a/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/CustomMusicPlugin.cs b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/CustomMusicPlugin.cs new file mode 100644 index 0000000..4c9932e --- /dev/null +++ b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/CustomMusicPlugin.cs @@ -0,0 +1,13 @@ +using BepInEx; + +namespace SamSWAT.CustomMusic +{ + [BepInPlugin("com.samswat.custommusic", "SamSWAT.CustomMusic", "1.1.0")] + public class CustomMusicPlugin : BaseUnityPlugin + { + private void Awake() + { + new CustomMusicPatch().Enable(); + } + } +} diff --git a/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/Properties/AssemblyInfo.cs b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e9e9d73 --- /dev/null +++ b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные со сборкой. +[assembly: AssemblyTitle("SamSWAT.CustomMusic")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SamSWAT.CustomMusic")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("8ead7664-c80f-40d3-aed1-1fe561a0023e")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/SamSWAT.CustomMusic.csproj b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/SamSWAT.CustomMusic.csproj new file mode 100644 index 0000000..5d56c74 --- /dev/null +++ b/Projects/SamSWAT.CustomMusic/SamSWAT.CustomMusic/SamSWAT.CustomMusic.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {8EAD7664-C80F-40D3-AED1-1FE561A0023E} + Library + Properties + SamSWAT.CustomMusic + SamSWAT.CustomMusic + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\References\Aki.Reflection.dll + + + False + ..\..\..\References\Assembly-CSharp.dll + + + ..\..\..\References\BepInEx.dll + + + ..\..\..\References\Newtonsoft.Json.dll + + + + ..\..\..\References\UnityEngine.dll + + + ..\..\..\References\UnityEngine.AudioModule.dll + + + ..\..\..\References\UnityEngine.CoreModule.dll + + + ..\..\..\References\UnityEngine.UnityWebRequestAudioModule.dll + + + ..\..\..\References\UnityEngine.UnityWebRequestModule.dll + + + + + + + + + \ No newline at end of file diff --git a/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds.sln b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds.sln new file mode 100644 index 0000000..7f67089 --- /dev/null +++ b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32002.261 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamSWAT.GUISounds", "SamSWAT.GUISounds\SamSWAT.GUISounds.csproj", "{92DBD895-3902-46F1-9878-73FBBFB08DF4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {92DBD895-3902-46F1-9878-73FBBFB08DF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92DBD895-3902-46F1-9878-73FBBFB08DF4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92DBD895-3902-46F1-9878-73FBBFB08DF4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92DBD895-3902-46F1-9878-73FBBFB08DF4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {70FA50F1-C65E-45CB-91E6-53E8B76618EE} + EndGlobalSection +EndGlobal diff --git a/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/GUISoundsModule.cs b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/GUISoundsModule.cs new file mode 100644 index 0000000..021826b --- /dev/null +++ b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/GUISoundsModule.cs @@ -0,0 +1,32 @@ +using BepInEx; +using Newtonsoft.Json; +using System.IO; +using UnityEngine; + +namespace SamSWAT.GUISounds +{ + [BepInPlugin("com.samswat.olduisounds", "SamSWAT.OldUISounds", "1.1.0")] + public class GUISoundsModule : BaseUnityPlugin + { + //creating class with info from config.json to be able to refer to it in future patches + public static Sounds sounds; + //asset bundle with custom sounds + public static AssetBundle UISoundsBundle; + private void Awake() + { + Logger.LogInfo("Loading: SamSWAT-OldUISounds 1.1.0"); + + string directory = BepInEx.Paths.PluginPath + "/SamSWAT.OldUISounds"; + //deserializing info from config.json into class with fields + string json = new StreamReader(Path.Combine(directory, "uisounds.json")).ReadToEnd(); + sounds = JsonConvert.DeserializeObject(json); + + //loading asset bundle with sounds + UISoundsBundle = AssetBundle.LoadFromFile(Path.Combine(directory, "assets/olduisounds.bundle")); + + //enabling patches + new UISoundsPatch().Enable(); + //new ItemSoundsPatch().Enable(); + } + } +} diff --git a/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/ItemSoundsPatch.cs b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/ItemSoundsPatch.cs new file mode 100644 index 0000000..02dfb3c --- /dev/null +++ b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/ItemSoundsPatch.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using System.Collections.Generic; +using System.Reflection; +using Aki.Reflection.Patching; +using EFT.UI; +using System.Linq; + +namespace SamSWAT.GUISounds +{ + public class ItemSoundsPatch : ModulePatch + { + private static readonly Dictionary ItemSounds = new Dictionary(); + + public ItemSoundsPatch() + { + foreach (var key in GUISoundsModule.sounds.ItemSounds.Keys) + { + GUISoundsModule.sounds.ItemSounds.TryGetValue(key, out var name); + + if (!ItemSounds.ContainsValue(ItemSounds.Values.FirstOrDefault(x => x.name == name))) + { + ItemSounds.Add(key, GUISoundsModule.UISoundsBundle.LoadAsset(name)); + } + else + { + KeyValuePair searchResult = ItemSounds.FirstOrDefault(x => x.Value.name == name); + ItemSounds.Add(key, searchResult.Value); + } + } + } + + protected override MethodBase GetTargetMethod() + { + return typeof(EFT.UI.GUISounds).GetMethod("GetItemClip"); + } + + [PatchPostfix] + private static void PatchPostfix(ref AudioClip __result, string soundGroup, EInventorySoundType soundType) + { + string key = soundGroup + "_" + soundType; + + if (ItemSounds.ContainsKey(key)) + { + __result = ItemSounds[key]; + } + } + } +} diff --git a/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/Properties/AssemblyInfo.cs b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0238b31 --- /dev/null +++ b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные со сборкой. +[assembly: AssemblyTitle("SamSWAT.GUISounds")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SamSWAT.GUISounds")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("92dbd895-3902-46f1-9878-73fbbfb08df4")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/SamSWAT.GUISounds.csproj b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/SamSWAT.GUISounds.csproj new file mode 100644 index 0000000..a8b64d6 --- /dev/null +++ b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/SamSWAT.GUISounds.csproj @@ -0,0 +1,69 @@ + + + + + Debug + AnyCPU + {92DBD895-3902-46F1-9878-73FBBFB08DF4} + Library + Properties + SamSWAT.GUISounds + SamSWAT.GUISounds + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\References\Aki.Reflection.dll + + + ..\..\..\References\Assembly-CSharp.dll + + + ..\..\..\References\BepInEx.dll + + + ..\..\..\References\Newtonsoft.Json.dll + + + + False + ..\..\..\References\UnityEngine.dll + + + ..\..\..\References\UnityEngine.AssetBundleModule.dll + + + ..\..\..\References\UnityEngine.AudioModule.dll + + + ..\..\..\References\UnityEngine.CoreModule.dll + + + + + + + + + + + \ No newline at end of file diff --git a/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/Sounds.cs b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/Sounds.cs new file mode 100644 index 0000000..d595ca3 --- /dev/null +++ b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/Sounds.cs @@ -0,0 +1,12 @@ +using EFT.UI; +using System.Collections.Generic; + +namespace SamSWAT.GUISounds +{ + // Class to hold our deserialized info from config.json + public class Sounds + { + public Dictionary UISounds { get; set; } + public Dictionary ItemSounds { get; set; } + } +} diff --git a/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/UISoundsPatch.cs b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/UISoundsPatch.cs new file mode 100644 index 0000000..63a5266 --- /dev/null +++ b/Projects/SamSWAT.GUISounds/SamSWAT.GUISounds/UISoundsPatch.cs @@ -0,0 +1,73 @@ +using UnityEngine; +using System.Collections.Generic; +using System.Reflection; +using Aki.Reflection.Patching; +using EFT.UI; +using System.Linq; + +namespace SamSWAT.GUISounds +{ + public class UISoundsPatch : ModulePatch + { + //local dictionary that holds converted info from config.json + private static readonly Dictionary UISounds = new Dictionary(); + + public UISoundsPatch() + { + //iterating through each parameter in converted class from config.json + foreach (var key in GUISoundsModule.sounds.UISounds.Keys) + { + //getting value from dictionary in class, so if you have: "BackpackClose": "inv_close", we'll get "inv_close" + GUISoundsModule.sounds.UISounds.TryGetValue(key, out var name); + + //check if the audioclip is already exists in the local dictionary so we won't cause memory duplication via loading same clip multiple times + if (!UISounds.ContainsValue(UISounds.Values.FirstOrDefault(x => x.name == name))) + { + //if it doesn't exist in local dictionary, load audioclip with the name (for example "inv_close") from config.json that was converted into class + UISounds.Add(key, GUISoundsModule.UISoundsBundle.LoadAsset(name)); + } + else + { + //if it already exists, getting audio clip with the same name + KeyValuePair searchResult = UISounds.FirstOrDefault(x => x.Value.name == name); + UISounds.Add(key, searchResult.Value); + } + } + } + + //getting method to patch via reflection, since it's public we just search it by name without using bindingflags + protected override MethodBase GetTargetMethod() + { + return typeof(UISoundsWrapper).GetMethod("GetUIClip"); + } + + /* method we patch is: + + public AudioClip GetUIClip(EUISoundType soundType) + { + if (!this.dictionary_0.ContainsKey(soundType)) + { + UISoundsWrapper.class273_0.LogMissingSound(soundType); + return null; + } + return this.dictionary_0[soundType]; + } + so this method on execute will return value typeof AudioClip, by using Harmony we will patch it + + */ + //patchpostfix means that we will alter result after the method is executed + [PatchPostfix] //get the audioclip after the game executes the method to be able to change this result, and also get the passed value that the game calls + private static void PatchPostfix(ref AudioClip __result, EUISoundType soundType) + { + //after the unchanged method is executed with some parameter typeof EUISoundType, it will return audioclip from the standard game database, so for BackpackClose it will return + //clip named backpack_close from the resources.assets and we want to change that. earlier, we specified that we wanted to access the result after the method was executed, + //and to get exactly what value was passed to the method. Accordingly, if the received value is in our local dictionary derived from the Sounds class, + //which in turn was created from deserialized config.json, we change the return audioclip to custom one + + if (UISounds.ContainsKey(soundType)) + { + __result = UISounds[soundType]; + } + } + } +} diff --git a/Projects/SamSWAT.HelmetLights/Plugin.cs b/Projects/SamSWAT.HelmetLights/Plugin.cs new file mode 100644 index 0000000..39427db --- /dev/null +++ b/Projects/SamSWAT.HelmetLights/Plugin.cs @@ -0,0 +1,101 @@ +using BepInEx; +using BepInEx.Configuration; +using Comfort.Common; +using EFT; +using EFT.AssetsManager; +using System; +using System.Linq; +using UnityEngine; + +namespace SamSWAT.HelmetLights +{ + [BepInPlugin("com.samswat.helmetlights", "SamSWAT.HelmetLights", "1.0.0")] + public class Plugin : BaseUnityPlugin + { + private static GameObject _flashlight; + private static GameObject[] _modes; + private static int _currentMode = 1; + internal static ConfigEntry HeadlightToggleKey; + internal static ConfigEntry HeadlightModeKey; + + private void Awake() + { + HeadlightToggleKey = Config.Bind( + "Main Settings", + "Helmet Light Toggle", + new KeyboardShortcut(KeyCode.Y), + "Key for helmet light toggle"); + + HeadlightModeKey = Config.Bind( + "Main Settings", + "Helmet Light Mode", + new KeyboardShortcut(KeyCode.Y, KeyCode.LeftShift), + "Key for helemt light mode change"); + } + + private void Update() + { + var gameWorld = Singleton.Instance; + + if (gameWorld == null || gameWorld.RegisteredPlayers == null) + { + return; + } + + if (_flashlight != null && _flashlight.GetComponent().IsInPool) + { + _flashlight = null; + _currentMode = 1; + } + + if (HeadlightToggleKey.Value.IsUp() && PlayerHasFlashlight()) + ToggleLight(); + if (HeadlightModeKey.Value.IsUp() && PlayerHasFlashlight()) + ChangeMode(); + } + + private void ToggleLight() + { + _modes[0].SetActive(!_modes[0].activeSelf); + _modes[_currentMode].SetActive(!_modes[_currentMode].activeSelf); + } + + private void ChangeMode() + { + if (_modes[0].activeSelf == false) + { + if (_currentMode < _modes.Length - 1) + { + _modes[_currentMode].SetActive(!_modes[_currentMode].activeSelf); + _currentMode++; + _modes[_currentMode].SetActive(!_modes[_currentMode].activeSelf); + } + else + { + _modes[_currentMode].SetActive(!_modes[_currentMode].activeSelf); + _currentMode = 1; + _modes[_currentMode].SetActive(!_modes[_currentMode].activeSelf); + } + } + } + + private bool PlayerHasFlashlight() + { + if (_flashlight == null) + { + Player player = Singleton.Instance.RegisteredPlayers.Find(p => p.IsYourPlayer); + _flashlight = player.GetComponentInChildren()?.gameObject; + + if (_flashlight == null) + return false; + + _modes = Array.ConvertAll(_flashlight.GetComponentsInChildren(true), y => y.gameObject).Where(x => x.name.Contains("mode_")).ToArray(); + return true; + } + else + { + return true; + } + } + } +} diff --git a/Projects/SamSWAT.HelmetLights/Properties/AssemblyInfo.cs b/Projects/SamSWAT.HelmetLights/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5fa62aa --- /dev/null +++ b/Projects/SamSWAT.HelmetLights/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные со сборкой. +[assembly: AssemblyTitle("SamSWAT.HelmetLights")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SamSWAT.HelmetLights")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("571d8c06-d2f0-4f9a-b3f8-0fd109e3e0bc")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Projects/SamSWAT.HelmetLights/SamSWAT.HelmetLights.csproj b/Projects/SamSWAT.HelmetLights/SamSWAT.HelmetLights.csproj new file mode 100644 index 0000000..8105b23 --- /dev/null +++ b/Projects/SamSWAT.HelmetLights/SamSWAT.HelmetLights.csproj @@ -0,0 +1,69 @@ + + + + + Debug + AnyCPU + {571D8C06-D2F0-4F9A-B3F8-0FD109E3E0BC} + Library + Properties + SamSWAT.HelmetLights + SamSWAT.HelmetLights + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\References\Aki.Reflection.dll + + + False + ..\..\References\Assembly-CSharp.dll + + + False + ..\..\References\BepInEx.dll + + + False + ..\..\References\Comfort.dll + + + + False + ..\..\References\UnityEngine.dll + + + False + ..\..\References\UnityEngine.CoreModule.dll + + + False + ..\..\References\UnityEngine.InputLegacyModule.dll + + + + + + + + \ No newline at end of file diff --git a/Projects/SamSWAT.HelmetLights/SamSWAT.HelmetLights.sln b/Projects/SamSWAT.HelmetLights/SamSWAT.HelmetLights.sln new file mode 100644 index 0000000..0c734b1 --- /dev/null +++ b/Projects/SamSWAT.HelmetLights/SamSWAT.HelmetLights.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32002.261 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamSWAT.HelmetLights", "SamSWAT.HelmetLights.csproj", "{571D8C06-D2F0-4F9A-B3F8-0FD109E3E0BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {571D8C06-D2F0-4F9A-B3F8-0FD109E3E0BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {571D8C06-D2F0-4F9A-B3F8-0FD109E3E0BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {571D8C06-D2F0-4F9A-B3F8-0FD109E3E0BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {571D8C06-D2F0-4F9A-B3F8-0FD109E3E0BC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {75461682-9284-4C9C-8F3B-8D4C63519504} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md index 1601779..c35a8a8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Deadass +my other BepInEx plugins \ No newline at end of file diff --git a/References/0Harmony.dll b/References/0Harmony.dll new file mode 100644 index 0000000..99daef7 Binary files /dev/null and b/References/0Harmony.dll differ diff --git a/References/Aki.Common.dll b/References/Aki.Common.dll new file mode 100644 index 0000000..8cd80ca Binary files /dev/null and b/References/Aki.Common.dll differ diff --git a/References/Aki.Reflection.dll b/References/Aki.Reflection.dll new file mode 100644 index 0000000..72b9cbe Binary files /dev/null and b/References/Aki.Reflection.dll differ diff --git a/References/Assembly-CSharp.dll b/References/Assembly-CSharp.dll new file mode 100644 index 0000000..23cbaaa Binary files /dev/null and b/References/Assembly-CSharp.dll differ diff --git a/References/BepInEx.dll b/References/BepInEx.dll new file mode 100644 index 0000000..8aedff0 Binary files /dev/null and b/References/BepInEx.dll differ diff --git a/References/Comfort.dll b/References/Comfort.dll new file mode 100644 index 0000000..96d7476 Binary files /dev/null and b/References/Comfort.dll differ diff --git a/References/Newtonsoft.Json.dll b/References/Newtonsoft.Json.dll new file mode 100644 index 0000000..6aa69df Binary files /dev/null and b/References/Newtonsoft.Json.dll differ diff --git a/References/UnityEngine.AssetBundleModule.dll b/References/UnityEngine.AssetBundleModule.dll new file mode 100644 index 0000000..ebe4176 Binary files /dev/null and b/References/UnityEngine.AssetBundleModule.dll differ diff --git a/References/UnityEngine.AudioModule.dll b/References/UnityEngine.AudioModule.dll new file mode 100644 index 0000000..04a092a Binary files /dev/null and b/References/UnityEngine.AudioModule.dll differ diff --git a/References/UnityEngine.CoreModule.dll b/References/UnityEngine.CoreModule.dll new file mode 100644 index 0000000..7d585db Binary files /dev/null and b/References/UnityEngine.CoreModule.dll differ diff --git a/References/UnityEngine.InputLegacyModule.dll b/References/UnityEngine.InputLegacyModule.dll new file mode 100644 index 0000000..1067ff9 Binary files /dev/null and b/References/UnityEngine.InputLegacyModule.dll differ diff --git a/References/UnityEngine.UnityWebRequestAssetBundleModule.dll b/References/UnityEngine.UnityWebRequestAssetBundleModule.dll new file mode 100644 index 0000000..0024d85 Binary files /dev/null and b/References/UnityEngine.UnityWebRequestAssetBundleModule.dll differ diff --git a/References/UnityEngine.UnityWebRequestAudioModule.dll b/References/UnityEngine.UnityWebRequestAudioModule.dll new file mode 100644 index 0000000..d4f9220 Binary files /dev/null and b/References/UnityEngine.UnityWebRequestAudioModule.dll differ diff --git a/References/UnityEngine.UnityWebRequestWWWModule.dll b/References/UnityEngine.UnityWebRequestWWWModule.dll new file mode 100644 index 0000000..b8b8314 Binary files /dev/null and b/References/UnityEngine.UnityWebRequestWWWModule.dll differ diff --git a/References/UnityEngine.dll b/References/UnityEngine.dll new file mode 100644 index 0000000..6ff1d0f Binary files /dev/null and b/References/UnityEngine.dll differ