using 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 CruiserImproved.Patches; using GameNetcodeStuff; using HarmonyLib; using JLL.Components; using Microsoft.CodeAnalysis; using ScandalsTweaks.Compatibility; using ScandalsTweaks.Patches; using ScandalsTweaks.Patches.Enemies; using ScandalsTweaks.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("DiggC.CruiserImproved")] [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.scandalstweaks")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.4.3.0")] [assembly: AssemblyInformationalVersion("1.4.3")] [assembly: AssemblyProduct("ScandalsTweaks")] [assembly: AssemblyTitle("scandal.scandalstweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.3.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 ScandalsTweaks { [BepInPlugin("scandal.scandalstweaks", "ScandalsTweaks", "1.4.3")] [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.scandalstweaks v1.4.3 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.scandalstweaks"); } LogDebug("Patching..."); CompatibilityUtils.Init(Harmony); Harmony.PatchAll(typeof(BaboonBirdAIPatches)); Harmony.PatchAll(typeof(BushWolfEnemyPatches)); Harmony.PatchAll(typeof(EnemyAIPatches)); Harmony.PatchAll(typeof(ForestGiantAIPatches)); Harmony.PatchAll(typeof(GiantKiwiAIPatches)); Harmony.PatchAll(typeof(MouthDogAIPatches)); Harmony.PatchAll(typeof(RadMechAIPatches)); Harmony.PatchAll(typeof(ItemDropshipPatches)); Harmony.PatchAll(typeof(LandminePatches)); Harmony.PatchAll(typeof(PlayerControllerBPatches)); Harmony.PatchAll(typeof(StartOfRoundPatches)); Harmony.PatchAll(typeof(TerminalPatches)); Harmony.PatchAll(typeof(TimeOfDayPatches)); 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.scandalstweaks"; public const string PLUGIN_NAME = "ScandalsTweaks"; public const string PLUGIN_VERSION = "1.4.3"; } } namespace ScandalsTweaks.Utils { internal static class CompatibilityUtils { internal const string GUID_CRUISER_IMPROVED = "DiggC.CruiserImproved"; internal const string GUID_JLL = "JacobG5.JLL"; internal static bool INSTALLED_CRUISER_IMPROVED; internal static bool INSTALLED_JLL; internal static void Init(Harmony harmony) { if (Chainloader.PluginInfos.ContainsKey("DiggC.CruiserImproved")) { INSTALLED_CRUISER_IMPROVED = true; harmony.PatchAll(typeof(CruiserImprovedCompatibility)); Plugin.LogDebug("CROSS-COMPATIBILITY - CruiserImproved detected"); } if (Chainloader.PluginInfos.ContainsKey("JacobG5.JLL")) { INSTALLED_JLL = true; harmony.PatchAll(typeof(JLLCompatibility)); 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 searchSpace, List 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; } } internal static class References { internal static ParticleSystem? rainParticles; internal static ParticleSystem? rainHitParticles; internal static ParticleSystem? stormyRainParticles; internal static ParticleSystem? stormyRainHitParticles; internal static TriggerModule rainParticlesTrigger = default(TriggerModule); internal static TriggerModule rainHitParticlesTrigger = default(TriggerModule); internal static TriggerModule stormyRainParticlesTrigger = default(TriggerModule); internal static TriggerModule stormyRainHitParticlesTrigger = default(TriggerModule); internal static ItemDropship itemShip = null; internal static GameObject? magnetLever; internal static AnimatedObjectTrigger? magnetTrigger; internal static GameObject? wesleyHurricaneRainObj; internal static ParticleSystem? wesleyHurricaneRainParticles; internal static ParticleSystem? wesleyHurricaneSandParticles; internal static ParticleSystem? wesleyHurricaneRainHitParticles; internal static GameObject? wesleyForsakenRainObj; internal static ParticleSystem? wesleyForsakenRainParticles; internal static ParticleSystem? wesleyForsakenRainHitParticles; internal static GameObject? kenjiAcidRainObj; internal static GameObject? kenjiAcidStormyRainObj; internal static ParticleSystem? kenjiAcidRainParticles; internal static ParticleSystem? kenjiAcidRainHitParticles; internal static ParticleSystem? kenjiAcidStormyRainParticles; internal static ParticleSystem? kenjiAcidStormyRainHitParticles; internal static GameObject? kenjiAcidStormyRainHurtZoneObj; } public static class Utilities { public static void SetParticleEffects(ParticleSystem particleSystem) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)particleSystem == (Object)null)) { CollisionModule collision = particleSystem.collision; ((CollisionModule)(ref collision)).enabled = true; ((CollisionModule)(ref collision)).collidesWith = LayerMask.op_Implicit(LayerMask.op_Implicit(((CollisionModule)(ref collision)).collidesWith) | 0x40000000); TriggerModule trigger = particleSystem.trigger; ((TriggerModule)(ref trigger)).enabled = true; ((TriggerModule)(ref trigger)).colliderQueryMode = (ParticleSystemColliderQueryMode)1; ((TriggerModule)(ref trigger)).enter = (ParticleSystemOverlapAction)1; ((TriggerModule)(ref trigger)).exit = (ParticleSystemOverlapAction)1; ((TriggerModule)(ref trigger)).inside = (ParticleSystemOverlapAction)1; } } public static bool ShouldAllowSightThroughVehicle(PlayerControllerB player, EnemyAI enemy) { return false; } public static bool IsItRaining() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Invalid comparison between Unknown and I4 if (((Object)(object)References.wesleyHurricaneRainObj != (Object)null && References.wesleyHurricaneRainObj.activeSelf) || ((Object)(object)References.wesleyForsakenRainObj != (Object)null && References.wesleyForsakenRainObj.activeSelf)) { return true; } if ((Object)(object)References.kenjiAcidRainObj != (Object)null && (Object)(object)References.kenjiAcidStormyRainObj != (Object)null && References.kenjiAcidStormyRainObj.activeSelf) { return true; } return (int)TimeOfDay.Instance.currentLevelWeather == 1 || (int)TimeOfDay.Instance.currentLevelWeather == 4 || (int)TimeOfDay.Instance.currentLevelWeather == 2; } } } namespace ScandalsTweaks.Patches { [HarmonyPatch(typeof(ItemDropship))] public static class ItemDropshipPatches { [HarmonyPatch("Start")] [HarmonyPrefix] private static void ItemDropship_Pre_Start(ItemDropship __instance) { if (!((Object)(object)__instance == (Object)null)) { References.itemShip = __instance; } } } [HarmonyPatch(typeof(Landmine))] public static class LandminePatches { public static bool ShouldCheckCustomKnockback() { return false; } public static bool CanPlayerBeKnockedBack() { return true; } public static float CurrentForceMultiplier() { return 1f; } public static bool ShouldDealKnockback(PlayerControllerB instance) { return CanPlayerBeKnockedBack(); } [HarmonyPatch("SpawnExplosion")] [HarmonyTranspiler] private static IEnumerable Landmine_Trans_SpawnExplosion(IEnumerable instructions) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown List list = instructions.ToList(); if (CompatibilityUtils.INSTALLED_CRUISER_IMPROVED) { Plugin.LogDebug("Skipping Landmine transpiler as CruiserImproved is present"); return list; } MethodInfo operand = PatchUtils.Method(typeof(Vector3), "get_magnitude"); List searchFor = new List { new PatchUtils.OpcodeMatch(OpCodes.Ldloca_S, 16), new PatchUtils.OpcodeMatch(OpCodes.Call, operand), new PatchUtils.OpcodeMatch(OpCodes.Ldc_R4, 2), new PatchUtils.OpcodeMatch(OpCodes.Ble_Un), new PatchUtils.OpcodeMatch(OpCodes.Ldloca_S, 16), new PatchUtils.OpcodeMatch(OpCodes.Call, operand), new PatchUtils.OpcodeMatch(OpCodes.Ldc_R4, 10) }; int num = PatchUtils.LocateCodeSegment(0, list, searchFor); if (num == -1) { Plugin.LogWarning("Could not find Landmine vehicle knockback check!"); return list; } object operand2 = list[num + 3].operand; list.InsertRange(num + 4, new <>z__ReadOnlyArray((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloc_S, (object)4), new CodeInstruction(OpCodes.Call, (object)PatchUtils.Method(typeof(LandminePatches), "ShouldDealKnockback")), new CodeInstruction(OpCodes.Brfalse_S, operand2) })); return list; } } [HarmonyPatch(typeof(PlayerControllerB))] public static class PlayerControllerBPatches { [HarmonyPatch("PlaceGrabbableObject")] [HarmonyPostfix] private static void PlayerControllerB_Post_PlaceGrabbableObject(GrabbableObject placeObject) { if (!CompatibilityUtils.INSTALLED_CRUISER_IMPROVED) { ScanNodeProperties componentInChildren = ((Component)placeObject).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren) && !Object.op_Implicit((Object)(object)((Component)componentInChildren).GetComponent())) { Rigidbody val = ((Component)componentInChildren).gameObject.AddComponent(); val.isKinematic = true; } } } [HarmonyPatch("Crouch")] [HarmonyTranspiler] private static IEnumerable PlayerControllerB_Trans_Crouch(IEnumerable instructions) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown List list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'Crouch' for 'PlayerControllerB'"); FieldInfo operand = PatchUtils.Field(typeof(PlayerControllerB), "playersManager"); FieldInfo operand2 = PatchUtils.Field(typeof(StartOfRound), "collidersAndRoomMask"); int num = 1107302656; List searchFor = new List { new PatchUtils.OpcodeMatch(OpCodes.Ldfld, operand), new PatchUtils.OpcodeMatch(OpCodes.Ldfld, operand2) }; int num2 = PatchUtils.LocateCodeSegment(0, list, searchFor); if (num2 == -1) { Plugin.LogError("Failed to transpile Raycast mask on 'PlayerControllerB.Crouch'!"); return list; } list.RemoveRange(num2, 2); list.InsertRange(num2, new <>z__ReadOnlyArray((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Pop, (object)null), new CodeInstruction(OpCodes.Ldc_I4, (object)num) })); return list; } [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 PlayerControllerB_Trans_SetHoverTipAndCurrentInteractTrigger(IEnumerable instructions) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown List list = new List(instructions); 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 searchFor = new List { 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!"); return list; } object operand2 = list[num + 2].operand; num += 3; MethodInfo methodInfo = PatchUtils.Method(typeof(PlayerControllerBPatches), "ValidRayHit"); list.InsertRange(num, new <>z__ReadOnlyArray((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(StartOfRound))] public static class StartOfRoundPatches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void StartOfRound_Post_Awake(StartOfRound __instance) { SetCustomWeather(); References.magnetLever = GameObject.Find("Environment/HangarShip/MagnetLever"); if ((Object)(object)References.magnetLever == (Object)null) { Plugin.LogError("Magnet-lever is null"); return; } References.magnetTrigger = References.magnetLever.GetComponent(); if ((Object)(object)References.magnetTrigger == (Object)null) { Plugin.LogError("Magnet-trigger is null"); } } private static void SetCustomWeather() { if (CompatibilityUtils.INSTALLED_JLL) { References.wesleyHurricaneRainObj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((GameObject hw) => ((Object)hw).name == "HurricaneWeatherRainEffect(Clone)")); if ((Object)(object)References.wesleyHurricaneRainObj != (Object)null) { References.wesleyHurricaneRainParticles = ((Component)References.wesleyHurricaneRainObj.transform.Find("Particle System (2)")).GetComponent(); References.wesleyHurricaneRainHitParticles = ((Component)References.wesleyHurricaneRainObj.transform.Find("Particle System (2)/RainHitParticle")).GetComponent(); References.wesleyHurricaneSandParticles = ((Component)References.wesleyHurricaneRainObj.transform.Find("SandParticles")).GetComponent(); Utilities.SetParticleEffects(References.wesleyHurricaneRainParticles); Utilities.SetParticleEffects(References.wesleyHurricaneRainHitParticles); Utilities.SetParticleEffects(References.wesleyHurricaneSandParticles); } else { Plugin.LogDebug("Could not find Hurricane weather effects"); } References.wesleyForsakenRainObj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((GameObject fw) => ((Object)fw).name == "ForsakenWeatherRainEffect(Clone)")); if ((Object)(object)References.wesleyForsakenRainObj != (Object)null) { References.wesleyForsakenRainParticles = ((Component)References.wesleyForsakenRainObj.transform.Find("Particle System")).GetComponent(); References.wesleyForsakenRainHitParticles = ((Component)References.wesleyForsakenRainObj.transform.Find("Particle System/RainHitParticle")).GetComponent(); Utilities.SetParticleEffects(References.wesleyForsakenRainParticles); Utilities.SetParticleEffects(References.wesleyForsakenRainHitParticles); } else { Plugin.LogDebug("Could not find Forsaken weather effects"); } References.kenjiAcidRainObj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((GameObject arf) => ((Object)arf).name == "AcidRainFinal(Clone)")); if ((Object)(object)References.kenjiAcidRainObj != (Object)null) { References.kenjiAcidRainParticles = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/RainParticleContainer/Particle System")).GetComponent(); References.kenjiAcidRainHitParticles = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/RainParticleContainer/Particle System/RainHitParticle")).GetComponent(); References.kenjiAcidStormyRainParticles = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/StormyRainParticleContainer/Particle System")).GetComponent(); References.kenjiAcidStormyRainHitParticles = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/StormyRainParticleContainer/Particle System/RainHitParticle")).GetComponent(); References.kenjiAcidStormyRainObj = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/StormyRainParticleContainer")).gameObject; References.kenjiAcidStormyRainHurtZoneObj = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/StormyRainParticleContainer/HurtZone")).gameObject; Utilities.SetParticleEffects(References.kenjiAcidRainParticles); Utilities.SetParticleEffects(References.kenjiAcidRainHitParticles); Utilities.SetParticleEffects(References.kenjiAcidStormyRainParticles); Utilities.SetParticleEffects(References.kenjiAcidStormyRainHitParticles); JLLCompatibility.TrySetDamageTrigger(References.kenjiAcidStormyRainHurtZoneObj); } else { Plugin.LogDebug("Could not find Acid-Rain weather effects"); } } } } [HarmonyPatch(typeof(Terminal))] public static class TerminalPatches { [HarmonyPatch("Awake")] [HarmonyPrefix] private static void Terminal_Pre_Awake(Terminal __instance) { __instance.terminalNodes.specialNodes[26].displayText = "For the safety of your crew, the Company only allows one vehicle to be in operation at any given time, but a vehicle has been detected.\r\n\r\n"; __instance.terminalNodes.specialNodes[25].displayText = "The delivery pod is busy transporting your vehicle. You cannot purchase items until it arrives.\r\n"; } } [HarmonyPatch(typeof(TimeOfDay))] public static class TimeOfDayPatches { [HarmonyPatch("Awake")] [HarmonyPrefix] private static void TimeOfDay_Pre_Awake(TimeOfDay __instance) { References.rainParticles = ((Component)((Component)__instance).transform.Find("RainParticleContainer/Particle System")).GetComponent(); References.rainHitParticles = ((Component)((Component)__instance).transform.Find("RainParticleContainer/Particle System/RainHitParticle")).GetComponent(); References.stormyRainParticles = ((Component)((Component)__instance).transform.Find("StormyRainParticleContainer/Particle System")).GetComponent(); References.stormyRainHitParticles = ((Component)((Component)__instance).transform.Find("StormyRainParticleContainer/Particle System/RainHitParticle")).GetComponent(); if (!((Object)(object)References.rainParticles == (Object)null) && !((Object)(object)References.rainHitParticles == (Object)null) && !((Object)(object)References.stormyRainParticles == (Object)null) && !((Object)(object)References.stormyRainHitParticles == (Object)null)) { Utilities.SetParticleEffects(References.rainParticles); Utilities.SetParticleEffects(References.rainHitParticles); Utilities.SetParticleEffects(References.stormyRainParticles); Utilities.SetParticleEffects(References.stormyRainHitParticles); } } } } namespace ScandalsTweaks.Patches.Enemies { [HarmonyPatch(typeof(BaboonBirdAI))] public static class BaboonBirdAIPatches { [HarmonyPatch("DoAIInterval")] [HarmonyTranspiler] private static IEnumerable BaboonBirdAI_Trans_DoAIInterval(IEnumerable instructions) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown List list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'DoAIInterval' for 'BaboonBirdAI'"); MethodInfo operand = PatchUtils.Method(typeof(StartOfRound), "get_Instance"); FieldInfo operand2 = PatchUtils.Field(typeof(StartOfRound), "collidersAndRoomMaskAndDefault"); int num = 33554433; List searchFor = new List { new PatchUtils.OpcodeMatch(OpCodes.Call, operand), new PatchUtils.OpcodeMatch(OpCodes.Ldfld, operand2) }; int num2 = PatchUtils.LocateCodeSegment(0, list, searchFor); if (num2 == -1) { Plugin.LogError("Failed to transpile Raycast mask on 'BaboonBirdAI.DoAIInterval'!"); return list; } list.RemoveRange(num2, 2); list.InsertRange(num2, new <>z__ReadOnlySingleElementList(new CodeInstruction(OpCodes.Ldc_I4, (object)num))); return list; } [HarmonyPatch("DoLOSCheck")] [HarmonyTranspiler] private static IEnumerable BaboonBirdAI_Trans_DoLOSCheck(IEnumerable instructions) { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown List list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'DoLOSCheck' for 'BaboonBirdAI'"); MethodInfo operand = PatchUtils.Method(typeof(StartOfRound), "get_Instance"); FieldInfo operand2 = PatchUtils.Field(typeof(StartOfRound), "collidersAndRoomMaskAndDefault"); MethodInfo methodInfo = PatchUtils.Method(typeof(RoundManager), "get_Instance"); FieldInfo fieldInfo = PatchUtils.Field(typeof(RoundManager), "tempColliderResults"); MethodInfo methodInfo2 = PatchUtils.Method(typeof(BaboonBirdAIPatches), "GetLayerMaskForLineOfSight"); List searchFor = new List { new PatchUtils.OpcodeMatch(OpCodes.Call, operand), new PatchUtils.OpcodeMatch(OpCodes.Ldfld, operand2) }; int num = PatchUtils.LocateCodeSegment(0, list, searchFor); if (num == -1) { Plugin.LogError("Failed to transpile Linecast mask on 'BaboonBirdAI.DoLOSCheck'!"); return list; } list.RemoveRange(num, 2); list.InsertRange(num, new <>z__ReadOnlyArray((CodeInstruction[])(object)new CodeInstruction[6] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo), new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)11), new CodeInstruction(OpCodes.Ldelem_Ref, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo2) })); return list; } public static int GetLayerMaskForLineOfSight(BaboonBirdAI baboonBird, Collider threatCollider) { if ((Object)(object)baboonBird == (Object)null) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } if ((Object)(object)threatCollider == (Object)null) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } if (((Component)threatCollider).gameObject.layer != 3) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } PlayerControllerB player = default(PlayerControllerB); if (!((Component)((Component)threatCollider).transform).TryGetComponent(ref player)) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } if (!Utilities.ShouldAllowSightThroughVehicle(player, (EnemyAI)(object)baboonBird)) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } return 33554433; } } [HarmonyPatch(typeof(BushWolfEnemy))] public static class BushWolfEnemyPatches { [HarmonyPatch("Update")] [HarmonyTranspiler] private static IEnumerable BushWolfEnemy_Trans_Update(IEnumerable instructions, ILGenerator generator) { //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown List list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'Update' for 'BushWolfEnemy'"); FieldInfo fieldInfo = PatchUtils.Field(typeof(EnemyAI), "targetPlayer"); FieldInfo operand = PatchUtils.Field(typeof(BushWolfEnemy), "dragging"); FieldInfo operand2 = PatchUtils.Field(typeof(VehicleController), "backDoorOpen"); MethodInfo methodInfo = PatchUtils.Method(typeof(BushWolfEnemyPatches), "IsTargetPlayerProtected"); List searchFor = new List { new PatchUtils.OpcodeMatch(OpCodes.Ldfld, operand2) }; int num = PatchUtils.LocateCodeSegment(0, list, searchFor); if (num == -1) { Plugin.LogError("Failed to locate body!"); return list; } num += 2; List searchFor2 = new List { new PatchUtils.OpcodeMatch(OpCodes.Ldarg_0), new PatchUtils.OpcodeMatch(OpCodes.Ldfld, operand) }; int num2 = PatchUtils.LocateCodeSegment(0, list, searchFor2); if (num2 == -1) { Plugin.LogError("Failed to locate continue block!"); return list; } Label label = list[num].labels[0]; List