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 Tweaks v1.4.8
BepInEx/plugins/scandalstweaks/scandal.scandalstweaks.dll
Decompiled 2 weeks 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 ScandalsTweaks.Compatibility; using ScandalsTweaks.Scripts; using ScandalsTweaks.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [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: IgnoresAccessChecksTo("WeatherRegistry")] [assembly: AssemblyCompany("scandal.scandalstweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.8.0")] [assembly: AssemblyInformationalVersion("1.4.8")] [assembly: AssemblyProduct("ScandalsTweaks")] [assembly: AssemblyTitle("scandal.scandalstweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.8.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.8")] [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.8 has loaded!"); } } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("scandal.scandalstweaks"); } LogDebug("Patching..."); CompatibilityUtils.Init(Harmony); Harmony.PatchAll(); 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.8"; } } namespace ScandalsTweaks.Utils { internal static class CompatibilityUtils { internal const string GUID_JLL = "JacobG5.JLL"; internal const string GUID_WEATHERREGISTRY = "mrov.WeatherRegistry"; internal static bool INSTALLED_JLL; internal static bool INSTALLED_WEATHERREGISTRY; internal static void Init(Harmony harmony) { if (Chainloader.PluginInfos.ContainsKey("JacobG5.JLL")) { INSTALLED_JLL = true; harmony.PatchAll(typeof(JLLCompatibility)); Plugin.LogDebug("CROSS-COMPATIBILITY - JLL detected"); } if (Chainloader.PluginInfos.ContainsKey("mrov.WeatherRegistry")) { INSTALLED_WEATHERREGISTRY = true; Plugin.LogDebug("CROSS-COMPATIBILITY - WeatherRegistry 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; } } 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 List<SVehicleEnemyManager> vehicleEnemyManagers = new List<SVehicleEnemyManager>(); 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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); ((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit(1f); 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 ShouldAllowSightThroughVehicleMask(EnemyAI enemyScript, PlayerControllerB playerScript) { List<SVehicleEnemyManager> vehicleEnemyManagers = References.vehicleEnemyManagers; for (int i = 0; i < vehicleEnemyManagers.Count; i++) { SVehicleEnemyManager sVehicleEnemyManager = vehicleEnemyManagers[i]; if (sVehicleEnemyManager.ShouldAllowSightThroughVehicle(enemyScript, playerScript)) { return true; } } return false; } public static bool IsItRaining() { if (((Object)(object)References.wesleyHurricaneRainParticles != (Object)null && References.wesleyHurricaneRainParticles.isEmitting) || ((Object)(object)References.wesleyForsakenRainParticles != (Object)null && References.wesleyForsakenRainParticles.isEmitting)) { return true; } if ((Object)(object)References.kenjiAcidRainParticles != (Object)null && References.kenjiAcidRainParticles.isEmitting) { return true; } if (!TimeOfDay.Instance.effects[1].effectEnabled && !TimeOfDay.Instance.effects[2].effectEnabled) { return TimeOfDay.Instance.effects[4].effectEnabled; } return true; } } } namespace ScandalsTweaks.Scripts { public class SVehicleEnemyManager : MonoBehaviour { public virtual void OnEnable() { if (!References.vehicleEnemyManagers.Contains(this)) { References.vehicleEnemyManagers.Add(this); } } public virtual void OnDisable() { if (References.vehicleEnemyManagers.Contains(this)) { References.vehicleEnemyManagers.Remove(this); } } public virtual bool ShouldAllowSightThroughVehicle(EnemyAI enemyScript, PlayerControllerB playerScript) { return false; } } } namespace ScandalsTweaks.Patches { [HarmonyPatch] public static class ItemDropshipPatches { [HarmonyPatch(typeof(ItemDropship), "Start")] [HarmonyPrefix] private static void ItemDropship_Pre_Start(ItemDropship __instance) { if (!((Object)(object)__instance == (Object)null)) { References.itemShip = __instance; } } } [HarmonyPatch] public static class StartOfRoundPatches { [HarmonyPatch(typeof(StartOfRound), "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<AnimatedObjectTrigger>(); if ((Object)(object)References.magnetTrigger == (Object)null) { Plugin.LogError("Magnet-trigger is null"); } } private static void SetCustomWeather() { if (CompatibilityUtils.INSTALLED_WEATHERREGISTRY) { References.wesleyHurricaneRainObj = ((IEnumerable<GameObject>)Resources.FindObjectsOfTypeAll<GameObject>()).FirstOrDefault((Func<GameObject, bool>)((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<ParticleSystem>(); References.wesleyHurricaneRainHitParticles = ((Component)References.wesleyHurricaneRainObj.transform.Find("Particle System (2)/RainHitParticle")).GetComponent<ParticleSystem>(); References.wesleyHurricaneSandParticles = ((Component)References.wesleyHurricaneRainObj.transform.Find("SandParticles")).GetComponent<ParticleSystem>(); Utilities.SetParticleEffects(References.wesleyHurricaneRainParticles); Utilities.SetParticleEffects(References.wesleyHurricaneRainHitParticles); Utilities.SetParticleEffects(References.wesleyHurricaneSandParticles); } else { Plugin.LogDebug("Could not find Hurricane weather effects"); } References.wesleyForsakenRainObj = ((IEnumerable<GameObject>)Resources.FindObjectsOfTypeAll<GameObject>()).FirstOrDefault((Func<GameObject, bool>)((GameObject fw) => ((Object)fw).name == "ForsakenWeatherRainEffect(Clone)")); if ((Object)(object)References.wesleyForsakenRainObj != (Object)null) { References.wesleyForsakenRainParticles = ((Component)References.wesleyForsakenRainObj.transform.Find("Particle System")).GetComponent<ParticleSystem>(); References.wesleyForsakenRainHitParticles = ((Component)References.wesleyForsakenRainObj.transform.Find("Particle System/RainHitParticle")).GetComponent<ParticleSystem>(); Utilities.SetParticleEffects(References.wesleyForsakenRainParticles); Utilities.SetParticleEffects(References.wesleyForsakenRainHitParticles); } else { Plugin.LogDebug("Could not find Forsaken weather effects"); } References.kenjiAcidRainObj = ((IEnumerable<GameObject>)Resources.FindObjectsOfTypeAll<GameObject>()).FirstOrDefault((Func<GameObject, bool>)((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<ParticleSystem>(); References.kenjiAcidRainHitParticles = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/RainParticleContainer/Particle System/RainHitParticle")).GetComponent<ParticleSystem>(); References.kenjiAcidStormyRainParticles = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/StormyRainParticleContainer/Particle System")).GetComponent<ParticleSystem>(); References.kenjiAcidStormyRainHitParticles = ((Component)References.kenjiAcidRainObj.transform.Find("AcidRainTimer/AcidAnimCont/StormyRainParticleContainer/Particle System/RainHitParticle")).GetComponent<ParticleSystem>(); 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] public static class TerminalPatches { [HarmonyPatch(typeof(Terminal), "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] public static class TimeOfDayPatches { [HarmonyPatch(typeof(TimeOfDay), "Awake")] [HarmonyPrefix] private static void TimeOfDay_Pre_Awake(TimeOfDay __instance) { References.rainParticles = ((Component)((Component)__instance).transform.Find("RainParticleContainer/Particle System")).GetComponent<ParticleSystem>(); References.rainHitParticles = ((Component)((Component)__instance).transform.Find("RainParticleContainer/Particle System/RainHitParticle")).GetComponent<ParticleSystem>(); References.stormyRainParticles = ((Component)((Component)__instance).transform.Find("StormyRainParticleContainer/Particle System")).GetComponent<ParticleSystem>(); References.stormyRainHitParticles = ((Component)((Component)__instance).transform.Find("StormyRainParticleContainer/Particle System/RainHitParticle")).GetComponent<ParticleSystem>(); 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] public static class BaboonBirdAIPatches { public static int collidersAndRoomMaskAndDefault = 33556737; [HarmonyPatch(typeof(BaboonBirdAI), "DoAIInterval")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> BaboonBirdAI_Trans_DoAIInterval(IEnumerable<CodeInstruction> instructions) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown List<CodeInstruction> 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"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { 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 Raycast mask on 'BaboonBirdAI.DoAIInterval'!"); return list; } list.RemoveRange(num, 2); list.InsertRange(num, new <>z__ReadOnlySingleElementList<CodeInstruction>(new CodeInstruction(OpCodes.Ldc_I4, (object)collidersAndRoomMaskAndDefault))); return list; } [HarmonyPatch(typeof(BaboonBirdAI), "DoLOSCheck")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> BaboonBirdAI_Trans_DoLOSCheck(IEnumerable<CodeInstruction> instructions) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown List<CodeInstruction> 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<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { 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>((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 || (Object)(object)threatCollider == (Object)null || ((Component)threatCollider).gameObject.layer != 3) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } PlayerControllerB val = default(PlayerControllerB); if (!((Component)((Component)threatCollider).transform).TryGetComponent<PlayerControllerB>(ref val)) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } if (Utilities.ShouldAllowSightThroughVehicleMask((EnemyAI)(object)baboonBird, val)) { return collidersAndRoomMaskAndDefault; } if (!Utilities.ShouldAllowSightThroughVehicle(val, (EnemyAI)(object)baboonBird)) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } return collidersAndRoomMaskAndDefault; } } [HarmonyPatch] public static class EnemyAIPatches { public static int collidersAndRoomMaskAndDefault = 33556737; [HarmonyPatch(typeof(EnemyAI), "CheckLineOfSightForPosition")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> EnemyAI_Trans_CheckLineOfSightForPosition(IEnumerable<CodeInstruction> instructions) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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 List<CodeInstruction> list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'CheckLineOfSightForPosition' for 'EnemyAI'"); MethodInfo operand = PatchUtils.Method(typeof(StartOfRound), "get_Instance"); FieldInfo operand2 = PatchUtils.Field(typeof(StartOfRound), "collidersAndRoomMaskAndDefault"); MethodInfo methodInfo = PatchUtils.Method(typeof(EnemyAIPatches), "GetLayerMaskForLineOfSight"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { 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 first Linecast mask on 'EnemyAI.CheckLineOfSightForPosition'!"); return list; } list.RemoveRange(num, 2); list.InsertRange(num, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo) })); int num2 = PatchUtils.LocateCodeSegment(num + 1, list, searchFor); if (num2 == -1) { Plugin.LogError("Failed to transpile second Linecast mask on 'EnemyAI.CheckLineOfSightForPosition'!"); return list; } list.RemoveRange(num2, 2); list.InsertRange(num2, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo) })); return list; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> EnemyAI_Trans_CurrentSearchCoroutine(IEnumerable<CodeInstruction> instructions, MethodBase method) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //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 FieldInfo field = method.DeclaringType.GetField("<>4__this", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { Plugin.LogError("Failed to find the enumerator field pointing to EnemyAI (<>4__this)"); return instructions; } List<CodeInstruction> list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'CurrentSearchCoroutine' for 'EnemyAI'"); MethodInfo operand = PatchUtils.Method(typeof(StartOfRound), "get_Instance"); FieldInfo operand2 = PatchUtils.Field(typeof(StartOfRound), "collidersAndRoomMaskAndDefault"); MethodInfo methodInfo = PatchUtils.Method(typeof(EnemyAIPatches), "GetLayerMaskForLineOfSight"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { 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 'EnemyAI.CurrentSearchCoroutine'!"); return list; } list.RemoveRange(num, 2); list.InsertRange(num, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)field), new CodeInstruction(OpCodes.Call, (object)methodInfo) })); return list; } public static int GetLayerMaskForLineOfSight(EnemyAI enemy) { if (enemy is BaboonBirdAI) { return 33554433; } RadMechAI val = (RadMechAI)(object)((enemy is RadMechAI) ? enemy : null); if (val == null || (Object)(object)val.targetedThreatCollider == (Object)null || ((Component)val.targetedThreatCollider).gameObject.layer != 3) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } PlayerControllerB val2 = default(PlayerControllerB); if (!((Component)((Component)val.targetedThreatCollider).transform).TryGetComponent<PlayerControllerB>(ref val2)) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } if (Utilities.ShouldAllowSightThroughVehicleMask(enemy, val2)) { return collidersAndRoomMaskAndDefault; } if (!Utilities.ShouldAllowSightThroughVehicle(val2, enemy)) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } return collidersAndRoomMaskAndDefault; } } [HarmonyPatch] public static class ForestGiantAIPatches { public static int collidersAndRoomMaskAndDefault = 33556737; [HarmonyPatch(typeof(ForestGiantAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ForestGiantAI_Trans_OnCollideWithPlayer(IEnumerable<CodeInstruction> instructions) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'OnCollideWithPlayer' for 'ForestGiantAI'"); MethodInfo operand = PatchUtils.Method(typeof(StartOfRound), "get_Instance"); FieldInfo operand2 = PatchUtils.Field(typeof(StartOfRound), "collidersAndRoomMaskAndDefault"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { 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 'ForestGiantAI.OnCollideWithPlayer'!"); return list; } list.RemoveRange(num, 2); list.InsertRange(num, new <>z__ReadOnlySingleElementList<CodeInstruction>(new CodeInstruction(OpCodes.Ldc_I4, (object)collidersAndRoomMaskAndDefault))); return list; } } [HarmonyPatch] public static class MouthDogAIPatches { public static int collidersAndRoomMask = 33556736; [HarmonyPatch(typeof(MouthDogAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> MouthDogAI_Trans_OnCollideWithPlayer(IEnumerable<CodeInstruction> instructions) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'OnCollideWithPlayer' for 'MouthDogAI'"); MethodInfo operand = PatchUtils.Method(typeof(StartOfRound), "get_Instance"); FieldInfo operand2 = PatchUtils.Field(typeof(StartOfRound), "collidersAndRoomMask"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { 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 'MouthDogAI.OnCollideWithPlayer'!"); return list; } list.RemoveRange(num, 2); list.InsertRange(num, new <>z__ReadOnlySingleElementList<CodeInstruction>(new CodeInstruction(OpCodes.Ldc_I4, (object)collidersAndRoomMask))); return list; } [HarmonyPatch(typeof(MouthDogAI), "EnterLunge")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> MouthDogAI_Trans_EnterLunge(IEnumerable<CodeInstruction> instructions) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'EnterLunge' for 'MouthDogAI'"); MethodInfo operand = PatchUtils.Method(typeof(StartOfRound), "get_Instance"); FieldInfo operand2 = PatchUtils.Field(typeof(StartOfRound), "collidersAndRoomMask"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { 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 Raycast mask on 'MouthDogAI.EnterLunge'!"); return list; } list.RemoveRange(num, 2); list.InsertRange(num, new <>z__ReadOnlySingleElementList<CodeInstruction>(new CodeInstruction(OpCodes.Ldc_I4, (object)collidersAndRoomMask))); return list; } } [HarmonyPatch] public static class RadMechAIPatches { public static int collidersAndRoomMaskAndDefault = 33556737; [HarmonyPatch(typeof(RadMechAI), "CheckSightForThreat")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> RadMechAI_Trans_CheckSightForThreat(IEnumerable<CodeInstruction> instructions) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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 //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'CheckSightForThreat' for 'RadMechAI'"); 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(RadMechAIPatches), "GetLayerMaskForLineOfSight"); List<PatchUtils.OpcodeMatch> searchFor = new List<PatchUtils.OpcodeMatch> { 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 first Linecast mask on 'RadMechAI.CheckSightForThreat'!"); return list; } list.RemoveRange(num, 2); list.InsertRange(num, new <>z__ReadOnlyArray<CodeInstruction>((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)5), new CodeInstruction(OpCodes.Ldelem_Ref, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo2) })); int num2 = PatchUtils.LocateCodeSegment(num + 1, list, searchFor); if (num2 == -1) { Plugin.LogError("Failed to transpile second Linecast mask on 'RadMechAI.CheckSightForThreat'!"); return list; } list.RemoveRange(num2, 2); list.InsertRange(num2, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)4), new CodeInstruction(OpCodes.Call, (object)methodInfo2) })); return list; } public static int GetLayerMaskForLineOfSight(RadMechAI radMech, Collider threatCollider) { if ((Object)(object)radMech == (Object)null || (Object)(object)threatCollider == (Object)null || ((Component)threatCollider).gameObject.layer != 3) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } PlayerControllerB val = default(PlayerControllerB); if (!((Component)((Component)threatCollider).transform).TryGetComponent<PlayerControllerB>(ref val)) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } if (Utilities.ShouldAllowSightThroughVehicleMask((EnemyAI)(object)radMech, val)) { return collidersAndRoomMaskAndDefault; } if (!Utilities.ShouldAllowSightThroughVehicle(val, (EnemyAI)(object)radMech)) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } return collidersAndRoomMaskAndDefault; } } } namespace ScandalsTweaks.Compatibility { public static class JLLCompatibility { public static GameObject? acidRainTriggerObgj; [HarmonyPatch(typeof(JBlowerFan), "OnTriggerStay")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> JBlowerFan_Trans_OnTriggerStay(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); Plugin.LogDebug("Attempting to transpile 'OnTriggerStay' for 'JBlowerFan'"); MethodInfo methodInfo = AccessTools.Method(typeof(JLLCompatibility), "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; } public static void TrySetDamageTrigger(GameObject hurtObject) { DamageTrigger val = default(DamageTrigger); if (!((Object)(object)hurtObject == (Object)null) && hurtObject.TryGetComponent<DamageTrigger>(ref val)) { acidRainTriggerObgj = hurtObject; } } public static bool CanDamagePlayer(PlayerControllerB player) { return true; } [HarmonyPatch(typeof(DamageTrigger), "DamagePlayer")] [HarmonyPrefix] public static bool DamageTrigger_Pre_DamagePlayer(DamageTrigger __instance, PlayerControllerB player) { if ((Object)(object)((Component)__instance).gameObject == (Object)(object)acidRainTriggerObgj && !CanDamagePlayer(player)) { return false; } return true; } public static bool CanBlowPlayer(PlayerControllerB player) { return true; } private static bool ShouldBlowPlayer(PlayerControllerB instance) { if (instance.isInHangarShipRoom) { return false; } return CanBlowPlayer(instance); } } } 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(); } } internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer<T>.Default.Equals(_item, (T)value)) { return -1; } return 0; } 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 new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { if (!EqualityComparer<T>.Default.Equals(_item, item)) { return -1; } return 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }