This commit is contained in:
SamSWAT 2022-08-10 23:08:40 +03:00
parent 7b68b72925
commit ece6de1d69
37 changed files with 947 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3D58CD1F-7F05-4C84-869E-2E2BEECB92E2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GeneburnFullPack</RootNamespace>
<AssemblyName>GeneburnFullPack</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="MusicPatch.cs" />
<Compile Include="GeneburnMusicPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Aki.Reflection, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\Aki.Reflection.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx, Version=5.4.19.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\BepInEx.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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();
}
}
}

View File

@ -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<AudioClip>();
}
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();
}
}
}

View File

@ -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")]

View File

@ -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

View File

@ -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<string, bool> ReplaceOriginal;
private static string CurrDir { get; set; }
private static List<AudioClip> musicClips = new List<AudioClip>();
public CustomMusicPatch()
{
CurrDir = BepInEx.Paths.PluginPath + "/SamSWAT.CustomMusic";
string json = new StreamReader(Path.Combine(CurrDir, "config.json")).ReadToEnd();
ReplaceOriginal = JsonConvert.DeserializeObject<Dictionary<string, bool>>(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);
}
}
}
}

View File

@ -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();
}
}
}

View File

@ -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")]

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8EAD7664-C80F-40D3-AED1-1FE561A0023E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SamSWAT.CustomMusic</RootNamespace>
<AssemblyName>SamSWAT.CustomMusic</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Aki.Reflection">
<HintPath>..\..\..\References\Aki.Reflection.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\..\References\BepInEx.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\References\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\References\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>..\..\..\References\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\References\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestAudioModule">
<HintPath>..\..\..\References\UnityEngine.UnityWebRequestAudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestModule">
<HintPath>..\..\..\References\UnityEngine.UnityWebRequestModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CustomMusicPatch.cs" />
<Compile Include="CustomMusicPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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

View File

@ -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<Sounds>(json);
//loading asset bundle with sounds
UISoundsBundle = AssetBundle.LoadFromFile(Path.Combine(directory, "assets/olduisounds.bundle"));
//enabling patches
new UISoundsPatch().Enable();
//new ItemSoundsPatch().Enable();
}
}
}

View File

@ -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<string, AudioClip> ItemSounds = new Dictionary<string, AudioClip>();
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<AudioClip>(name));
}
else
{
KeyValuePair<string, AudioClip> 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];
}
}
}
}

View File

@ -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")]

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{92DBD895-3902-46F1-9878-73FBBFB08DF4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SamSWAT.GUISounds</RootNamespace>
<AssemblyName>SamSWAT.GUISounds</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Aki.Reflection">
<HintPath>..\..\..\References\Aki.Reflection.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\References\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\..\References\BepInEx.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\References\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\References\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>..\..\..\References\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>..\..\..\References\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\References\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ItemSoundsPatch.cs" />
<Compile Include="GUISoundsModule.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sounds.cs" />
<Compile Include="UISoundsPatch.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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<EUISoundType, string> UISounds { get; set; }
public Dictionary<string, string> ItemSounds { get; set; }
}
}

View File

@ -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<EUISoundType, AudioClip> UISounds = new Dictionary<EUISoundType, AudioClip>();
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<AudioClip>(name));
}
else
{
//if it already exists, getting audio clip with the same name
KeyValuePair<EUISoundType, AudioClip> 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];
}
}
}
}

View File

@ -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<KeyboardShortcut> HeadlightToggleKey;
internal static ConfigEntry<KeyboardShortcut> 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<GameWorld>.Instance;
if (gameWorld == null || gameWorld.RegisteredPlayers == null)
{
return;
}
if (_flashlight != null && _flashlight.GetComponent<WeaponModPoolObject>().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<GameWorld>.Instance.RegisteredPlayers.Find(p => p.IsYourPlayer);
_flashlight = player.GetComponentInChildren<TacticalComboVisualController>()?.gameObject;
if (_flashlight == null)
return false;
_modes = Array.ConvertAll(_flashlight.GetComponentsInChildren<Transform>(true), y => y.gameObject).Where(x => x.name.Contains("mode_")).ToArray();
return true;
}
else
{
return true;
}
}
}
}

View File

@ -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")]

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{571D8C06-D2F0-4F9A-B3F8-0FD109E3E0BC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SamSWAT.HelmetLights</RootNamespace>
<AssemblyName>SamSWAT.HelmetLights</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Aki.Reflection, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\Aki.Reflection.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx, Version=5.4.19.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\BepInEx.dll</HintPath>
</Reference>
<Reference Include="Comfort, Version=1.0.0.4, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\Comfort.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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

View File

@ -1,2 +1,3 @@
# Deadass
my other BepInEx plugins

BIN
References/0Harmony.dll Normal file

Binary file not shown.

BIN
References/Aki.Common.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
References/BepInEx.dll Normal file

Binary file not shown.

BIN
References/Comfort.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
References/UnityEngine.dll Normal file

Binary file not shown.