Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Scandals Fixes v1.0.0
BepInEx/plugins/scandalsfixes/scandal.scandalsfixes.dll
Decompiled 7 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using JLL.Components; using Microsoft.CodeAnalysis; using ScandalsFixes.Patches; using ScandalsFixes.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("JLL")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: AssemblyCompany("scandal.scandalsfixes")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ScandalsFixes")] [assembly: AssemblyTitle("scandal.scandalsfixes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ScandalsFixes { [BepInPlugin("scandal.scandalsfixes", "ScandalsFixes", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static bool initialized; public static Plugin Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } public void Awake() { if (!initialized) { initialized = true; Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Patch(); LogInfo("scandal.scandalsfixes v1.0.0 has loaded!"); } } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("scandal.scandalsfixes"); } LogDebug("Patching..."); CompatibilityUtils.Init(Harmony); Harmony.PatchAll(typeof(PlayAudioAnimationEventPatches)); if (!CompatibilityUtils.INSTALLED_SCANDALS_TWEAKS) { Harmony.PatchAll(typeof(PlayerControllerBPatches)); } Harmony.PatchAll(typeof(SoundManagerPatches)); Harmony.PatchAll(typeof(StartOfRoundPatches)); LogDebug("Finished patching!"); } internal static void Unpatch() { LogDebug("Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } LogDebug("Finished unpatching!"); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogMessage(string messageLog) { Logger.LogMessage((object)messageLog); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogDebug(string debugLog) { Logger.LogDebug((object)debugLog); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogInfo(string infoLog) { Logger.LogInfo((object)infoLog); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogWarning(string warningLog) { Logger.LogWarning((object)warningLog); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogError(string errorLog) { Logger.LogError((object)errorLog); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "scandal.scandalsfixes"; public const string PLUGIN_NAME = "ScandalsFixes"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ScandalsFixes.Utils { internal static class CompatibilityUtils { internal const string GUID_CRUISER_IMPROVED = "DiggC.CruiserImproved"; internal const string GUID_JLL = "JacobG5.JLL"; internal const string GUID_SCANDALS_TWEAKS = "scandal.scandalstweaks"; internal static bool INSTALLED_CRUISER_IMPROVED; internal static bool INSTALLED_JLL; internal static bool INSTALLED_SCANDALS_TWEAKS; internal static void Init(Harmony harmony) { if (Chainloader.PluginInfos.ContainsKey("DiggC.CruiserImproved")) { INSTALLED_CRUISER_IMPROVED = true; Plugin.LogDebug("CROSS-COMPATIBILITY - CruiserImproved detected"); } if (Chainloader.PluginInfos.ContainsKey("scandal.scandalstweaks")) { INSTALLED_SCANDALS_TWEAKS = true; Plugin.LogDebug("CROSS-COMPATIBILITY - Scandal's Tweaks detected"); } if (Chainloader.PluginInfos.ContainsKey("JacobG5.JLL")) { INSTALLED_JLL = true; if (INSTALLED_SCANDALS_TWEAKS) { Plugin.LogDebug("CROSS-COMPATIBILITY - JLL & Scandal's Tweaks detected"); return; } harmony.PatchAll(typeof(JLLPatches)); Plugin.LogDebug("CROSS-COMPATIBILITY - JLL detected"); } } } public class NullMemberException : Exception { private NullMemberException(string message) : base(message) { } public static NullMemberException Method(Type type, string methodName, Type[] parameters = null, Type[] generics = null) { string text = ""; string text2 = ""; if (parameters != null && parameters.Length != 0) { text = string.Join(", ", parameters.Select((Type param) => param.ToString())); } if (generics != null && generics.Length != 0) { text2 = "<" + string.Join(", ", generics.Select((Type param) => param.ToString())) + ">"; } return new NullMemberException("Could not find method " + type.Name + ":" + text2 + methodName + "(" + text + ")"); } public static NullMemberException Field(Type type, string fieldName) { return new NullMemberException("Could not find field " + type.Name + "." + fieldName); } } internal static class PatchUtils { public struct OpcodeMatch { public OpCode opcode; public object operandOrNull; public OpcodeMatch(OpCode opcode) { operandOrNull = null; this.opcode = opcode; } public OpcodeMatch(OpCode opcode, object operand) { operandOrNull = null; this.opcode = opcode; operandOrNull = operand; } } public static bool OperandCompare(object inputOperand, object codeInstructionOperand) { if (inputOperand.Equals(codeInstructionOperand)) { return true; } Type type = codeInstructionOperand.GetType(); if (type == typeof(LocalBuilder)) { return inputOperand.Equals(((LocalBuilder)codeInstructionOperand).LocalIndex); } if (!(inputOperand is IConvertible) || !(codeInstructionOperand is IConvertible)) { return false; } return Convert.ChangeType(inputOperand, codeInstructionOperand.GetType())?.Equals(codeInstructionOperand) ?? false; } public static int LocateCodeSegment(int startIndex, List<CodeInstruction> searchSpace, List<OpcodeMatch> searchFor) { if (startIndex < 0 || startIndex >= searchSpace.Count) { return -1; } int num = 0; for (int i = startIndex; i < searchSpace.Count; i++) { CodeInstruction val = searchSpace[i]; OpcodeMatch opcodeMatch = searchFor[num]; bool flag = val.opcode == opcodeMatch.opcode; if (flag && opcodeMatch.operandOrNull != null) { flag = OperandCompare(opcodeMatch.operandOrNull, val.operand); } if (flag) { num++; if (num == searchFor.Count) { return i - num + 1; } } else { num = 0; } } return -1; } public static string GetAllMaskLayers(LayerMask _mask) { int value = ((LayerMask)(ref _mask)).value; string text = ""; for (int i = 0; i < 32; i++) { if (((1 << i) & value) != 0) { text = text + " " + LayerMask.LayerToName(i); } } return text; } public static bool TryMethod(Type type, string name, out MethodInfo methodInfo) { return TryMethod(type, name, null, null, out methodInfo); } public static bool TryMethod(Type type, string name, Type[] parameters, out MethodInfo methodInfo) { return TryMethod(type, name, parameters, null, out methodInfo); } public static bool TryMethod(Type type, string name, Type[] parameters, Type[] generics, out MethodInfo methodInfo) { if (parameters == null && generics == null) { methodInfo = type.GetMethod(name, AccessTools.all); } else { if (generics == null) { generics = Type.EmptyTypes; } if (parameters == null) { parameters = Type.EmptyTypes; } methodInfo = type.GetMethod(name, generics.Length, AccessTools.all, null, parameters, null); if (generics.Length != 0) { methodInfo = methodInfo.MakeGenericMethod(generics); } } return methodInfo != null; } public static MethodInfo Method(Type type, string name, Type[] parameters = null, Type[] generics = null) { if (!TryMethod(type, name, parameters, generics, out MethodInfo methodInfo)) { throw NullMemberException.Method(type, name, parameters, generics); } return methodInfo; } public static bool TryField(Type type, string name, out FieldInfo fieldInfo) { fieldInfo = AccessTools.Field(type, name); return fieldInfo != null; } public static FieldInfo Field(Type type, string name) { if (!TryField(type, name, out FieldInfo fieldInfo)) { throw NullMemberException.Field(type, name); } return fieldInfo; } } } namespace ScandalsFixes.Patches { [HarmonyPatch] public static class JLLPatches { [HarmonyPatch(typeof(JBlowerFan), "OnTriggerStay")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> JBlowerFan_Trans_OnTriggerStay(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); if (CompatibilityUtils.INSTALLED_SCANDALS_TWEAKS) { Plugin.LogDebug("Skipping OnTriggerStay transpiler as Scandal's Tweaks is present"); return list; } Plugin.LogDebug("Attempting to transpile 'OnTriggerStay' for 'JBlowerFan'"); MethodInfo methodInfo = AccessTools.Method(typeof(JLLPatches), "ShouldBlowPlayer", (Type[])null, (Type[])null); FieldInfo operand = AccessTools.Field(typeof(PlayerControllerB), "externalForceAutoFade"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { new PatchUtils.OpcodeMatch(OpCodes.Ldloc_0), new PatchUtils.OpcodeMatch(OpCodes.Dup), new PatchUtils.OpcodeMatch(OpCodes.Ldfld, operand) }; int num = PatchUtils.LocateCodeSegment(0, list, searchFor); if (num == -1) { Plugin.LogError("Failed to transpile 'OnTriggerStay' on 'JBlowerFan.OnTriggerStay'!"); return list; } Label label = generator.DefineLabel(); list[num + 10].labels.Add(label); list.InsertRange(num, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloc_0, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo), new CodeInstruction(OpCodes.Brfalse_S, (object)label) })); return list; } private static bool ShouldBlowPlayer(PlayerControllerB instance) { return !instance.isInHangarShipRoom; } } [HarmonyPatch(typeof(PlayAudioAnimationEvent))] public static class PlayAudioAnimationEventPatches { [HarmonyPatch("PlayAudio1")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio1(PlayAudioAnimationEvent __instance) { if ((Object)(object)RoundManager.Instance == (Object)null) { return false; } if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioClip == (Object)null) { return false; } return true; } [HarmonyPatch("PlayAudio1RandomClip")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio1RandomClip(PlayAudioAnimationEvent __instance) { if ((Object)(object)RoundManager.Instance == (Object)null) { return false; } if ((Object)(object)__instance.audioToPlay == (Object)null || __instance.randomClips == null || __instance.randomClips.Length == 0) { return false; } return true; } [HarmonyPatch("PlayAudio2RandomClip")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio2RandomClip(PlayAudioAnimationEvent __instance) { if ((Object)(object)RoundManager.Instance == (Object)null) { return false; } if ((Object)(object)__instance.audioToPlayB == (Object)null || __instance.randomClips2 == null || __instance.randomClips2.Length == 0) { return false; } return true; } [HarmonyPatch("PlayAudioB1")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudioB1(PlayAudioAnimationEvent __instance) { if ((Object)(object)RoundManager.Instance == (Object)null) { return false; } if ((Object)(object)__instance.audioToPlayB == (Object)null || (Object)(object)__instance.audioClip == (Object)null) { return false; } return true; } [HarmonyPatch("PlayAudio1Oneshot")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio1Oneshot(PlayAudioAnimationEvent __instance) { if ((Object)(object)RoundManager.Instance == (Object)null) { return false; } if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioClip == (Object)null) { return false; } return true; } [HarmonyPatch("PlayAudio2")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio2(PlayAudioAnimationEvent __instance) { if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioClip2 == (Object)null) { return false; } return true; } [HarmonyPatch("PlayAudioB2")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudioB2(PlayAudioAnimationEvent __instance) { if ((Object)(object)__instance.audioToPlayB == (Object)null || (Object)(object)__instance.audioClip2 == (Object)null) { return false; } return true; } [HarmonyPatch("PlayAudio2Oneshot")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio2Oneshot(PlayAudioAnimationEvent __instance) { if ((Object)(object)RoundManager.Instance == (Object)null) { return false; } if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioClip2 == (Object)null) { return false; } return true; } [HarmonyPatch("PlayAudio3Oneshot")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio3Oneshot(PlayAudioAnimationEvent __instance) { if ((Object)(object)RoundManager.Instance == (Object)null) { return false; } if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioClip3 == (Object)null) { return false; } return true; } [HarmonyPatch("StopAudio")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_StopAudio(PlayAudioAnimationEvent __instance) { if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioToPlay.clip == (Object)null) { return false; } return true; } [HarmonyPatch("PauseAudio")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PauseAudio(PlayAudioAnimationEvent __instance) { if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioToPlay.clip == (Object)null) { return false; } return true; } [HarmonyPatch("PlayAudio1DefaultClip")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio1DefaultClip(PlayAudioAnimationEvent __instance) { if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioToPlay.clip == (Object)null) { return false; } return true; } [HarmonyPatch("PlayAudio1DefaultClipIfNotPlaying")] [HarmonyPrefix] private static bool PlayAudioAnimationEvent_Pre_PlayAudio1DefaultClipIfNotPlaying(PlayAudioAnimationEvent __instance) { if ((Object)(object)__instance.audioToPlay == (Object)null || (Object)(object)__instance.audioToPlay.clip == (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(PlayerControllerB))] public static class PlayerControllerBPatches { [HarmonyPatch("PlaceGrabbableObject")] [HarmonyPostfix] private static void PlayerControllerB_Post_PlaceGrabbableObject(GrabbableObject placeObject) { if (!CompatibilityUtils.INSTALLED_SCANDALS_TWEAKS && !CompatibilityUtils.INSTALLED_CRUISER_IMPROVED) { ScanNodeProperties componentInChildren = ((Component)placeObject).GetComponentInChildren<ScanNodeProperties>(); if (Object.op_Implicit((Object)(object)componentInChildren) && !Object.op_Implicit((Object)(object)((Component)componentInChildren).GetComponent<Rigidbody>())) { Rigidbody val = ((Component)componentInChildren).gameObject.AddComponent<Rigidbody>(); val.isKinematic = true; } } } [HarmonyPatch("Update")] [HarmonyPrefix] public static void PlayerControllerB_Pre_Update(PlayerControllerB __instance) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null) && __instance.isPlayerControlled && !__instance.isPlayerDead && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController) && (__instance.inVehicleAnimation || __instance.inSpecialInteractAnimation)) { if (((Vector3)(ref __instance.externalForces)).magnitude > 0.05f) { __instance.externalForces = Vector3.Lerp(__instance.externalForces, Vector3.zero, 2f * Time.deltaTime); } if (((Vector3)(ref __instance.externalForceAutoFade)).magnitude > 0.05f) { __instance.externalForceAutoFade = Vector3.Lerp(__instance.externalForceAutoFade, Vector3.zero, 2f * Time.deltaTime); } } } [HarmonyPatch("SetHoverTipAndCurrentInteractTrigger")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> PlayerControllerB_Trans_SetHoverTipAndCurrentInteractTrigger(IEnumerable<CodeInstruction> instructions) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); if (CompatibilityUtils.INSTALLED_SCANDALS_TWEAKS) { Plugin.LogDebug("Skipping HoverTip transpiler as Scandal's Tweaks is present"); return list; } if (CompatibilityUtils.INSTALLED_CRUISER_IMPROVED) { Plugin.LogDebug("Skipping HoverTip transpiler as CruiserImproved is present"); return list; } Plugin.LogDebug("Attempting to transpile 'SetHoverTipAndCurrentInteractTrigger' for 'PlayerControllerB'"); MethodInfo operand = PatchUtils.Method(typeof(GameObject), "get_layer"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { new PatchUtils.OpcodeMatch(OpCodes.Callvirt, operand), new PatchUtils.OpcodeMatch(OpCodes.Ldc_I4_S, 30), new PatchUtils.OpcodeMatch(OpCodes.Beq) }; int num = PatchUtils.LocateCodeSegment(0, list, searchFor); if (num == -1) { Plugin.LogWarning("Could not transpile 'SetHoverTipAndCurrentInteractTrigger' on 'PlayerControllerB.SetHoverTipAndCurrentInteractTrigger'!"); return list; } object operand2 = list[num + 2].operand; num += 3; MethodInfo methodInfo = PatchUtils.Method(typeof(PlayerControllerBPatches), "ValidRayHit"); list.InsertRange(num, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo), new CodeInstruction(OpCodes.Brfalse, operand2) })); return list; } private static bool ValidRayHit(PlayerControllerB player) { string tag = ((Component)((RaycastHit)(ref player.hit)).collider).tag; return tag == "PhysicsProp" || tag == "InteractTrigger"; } } [HarmonyPatch(typeof(SoundManager))] public static class SoundManagerPatches { [HarmonyPatch("PlayNonDiageticSound")] [HarmonyPrefix] private static bool SoundManager_Pre_PlayNonDiageticSound(SoundManager __instance) { if (!__instance.isInsanityMusicPlaying && __instance.localPlayerAmbientMusicTimer >= 13f && (__instance.currentLevelAmbience.insanityMusicAudios == null || __instance.currentLevelAmbience.insanityMusicAudios.Length == 0)) { __instance.localPlayerAmbientMusicTimer = 0f; return false; } return true; } } [HarmonyPatch(typeof(StartOfRound))] public static class StartOfRoundPatches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartOfRound_Post_Start(StartOfRound __instance) { OccludeAudio val2 = default(OccludeAudio); for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.currentVoiceChatIngameSettings?.voiceAudio == (Object)null) && ((Component)val.currentVoiceChatIngameSettings.voiceAudio).TryGetComponent<OccludeAudio>(ref val2)) { val.voiceMuffledByEnemy = false; val2.overridingLowPass = false; val2.lowPassOverride = 20000f; } } __instance.UpdatePlayerVoiceEffects(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }