mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 02:50:45 -05:00
Added 2 missing patches
This commit is contained in:
parent
4fd2a48972
commit
a62df7c9be
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Company>Aki</Company>
|
<Company>Aki</Company>
|
||||||
<Copyright>Copyright @ Aki 2022</Copyright>
|
<Copyright>Copyright @ Aki 2023</Copyright>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -17,6 +17,9 @@
|
|||||||
<Reference Include="ItemComponent.Types" HintPath="..\Shared\Managed\ItemComponent.Types.dll" Private="False" />
|
<Reference Include="ItemComponent.Types" HintPath="..\Shared\Managed\ItemComponent.Types.dll" Private="False" />
|
||||||
<Reference Include="Comfort" HintPath="..\Shared\Managed\Comfort.dll" Private="False" />
|
<Reference Include="Comfort" HintPath="..\Shared\Managed\Comfort.dll" Private="False" />
|
||||||
<Reference Include="UnityEngine" HintPath="..\Shared\Managed\UnityEngine.dll" Private="False" />
|
<Reference Include="UnityEngine" HintPath="..\Shared\Managed\UnityEngine.dll" Private="False" />
|
||||||
|
<Reference Include="UnityEngine.AudioModule">
|
||||||
|
<HintPath>..\Shared\Managed\UnityEngine.AudioModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="UnityEngine.CoreModule" HintPath="..\Shared\Managed\UnityEngine.CoreModule.dll" Private="False" />
|
<Reference Include="UnityEngine.CoreModule" HintPath="..\Shared\Managed\UnityEngine.CoreModule.dll" Private="False" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ namespace Aki.SinglePlayer
|
|||||||
new LighthouseBridgePatch().Enable();
|
new LighthouseBridgePatch().Enable();
|
||||||
new LighthouseTransmitterPatch().Enable();
|
new LighthouseTransmitterPatch().Enable();
|
||||||
new EmptyInfilFixPatch().Enable();
|
new EmptyInfilFixPatch().Enable();
|
||||||
|
new SmokeGrenadeFuseSoundFixPatch().Enable();
|
||||||
|
new PlayerToggleSoundFixPatch().Enable();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using Aki.Reflection.Patching;
|
||||||
|
using Comfort.Common;
|
||||||
|
using EFT;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Aki.SinglePlayer.Patches.RaidFix
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fixes an issue with the visor toggle sound not following the player in offline raids
|
||||||
|
/// </summary>
|
||||||
|
public class PlayerToggleSoundFixPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return typeof(Player).GetMethod("PlayToggleSound", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
private static bool PatchPrefix(ref bool previousState, bool isOn, AudioClip toggleOn, AudioClip toggleOff, Player __instance)
|
||||||
|
{
|
||||||
|
// Don't change anything and execute original method if it's not the player that triggers the method
|
||||||
|
if (!__instance.IsYourPlayer)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousState != isOn)
|
||||||
|
{
|
||||||
|
Singleton<BetterAudio>.Instance.PlayNonspatial(isOn ? toggleOn : toggleOff, BetterAudio.AudioSourceGroupType.Character);
|
||||||
|
}
|
||||||
|
|
||||||
|
previousState = isOn;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Reflection.Emit;
|
||||||
|
using Aki.Reflection.CodeWrapper;
|
||||||
|
using Aki.Reflection.Patching;
|
||||||
|
using HarmonyLib;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Aki.SinglePlayer.Patches.RaidFix
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fixes an issue with smoke grenades not playing the fuse popping sound when thrown
|
||||||
|
/// </summary>
|
||||||
|
public class SmokeGrenadeFuseSoundFixPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return typeof(GrenadeEmission).GetMethod(nameof(GrenadeEmission.StartEmission));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchTranspiler]
|
||||||
|
private static IEnumerable<CodeInstruction> PatchTranspile(IEnumerable<CodeInstruction> instructions)
|
||||||
|
{
|
||||||
|
var codes = new List<CodeInstruction>(instructions);
|
||||||
|
var searchCode = new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(AudioClip), "get_length"));
|
||||||
|
var searchIndex = -1;
|
||||||
|
|
||||||
|
for (var i = 0; i < codes.Count; i++)
|
||||||
|
{
|
||||||
|
if (codes[i].opcode == searchCode.opcode && codes[i].operand == searchCode.operand)
|
||||||
|
{
|
||||||
|
searchIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchIndex == -1)
|
||||||
|
{
|
||||||
|
Logger.LogError($"{nameof(SmokeGrenadeFuseSoundFixPatch)} failed: Could not find reference code.");
|
||||||
|
return instructions;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newCodes = CodeGenerator.GenerateInstructions(new List<Code>
|
||||||
|
{
|
||||||
|
new Code(OpCodes.Ldarg_0),
|
||||||
|
new Code(OpCodes.Ldfld, typeof(GrenadeEmission), "betterSource_0"),
|
||||||
|
new Code(OpCodes.Ldfld, typeof(BetterSource), "source1"),
|
||||||
|
new Code(OpCodes.Callvirt, typeof(AudioSource), "Play")
|
||||||
|
});
|
||||||
|
|
||||||
|
searchIndex -= 4;
|
||||||
|
|
||||||
|
codes.InsertRange(searchIndex, newCodes);
|
||||||
|
return codes.AsEnumerable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user