using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AIGraph; using Agents; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using GTFO.API; using GTFO.API.Utilities; using GTFODoorMod.CustomWorldEvents; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using LevelGeneration; using Microsoft.CodeAnalysis; using ModifierAPI; using Player; using SNetwork; 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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("GTFODoorMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Giginss's first plugin, designed to modify door controls")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyInformationalVersion("0.0.1+684a9f58bcfc820aa1f4ec904e63a025203c73e2")] [assembly: AssemblyProduct("GTFODoorMod")] [assembly: AssemblyTitle("GTFODoorMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 GTFODoorMod { public class AllowNegativeInfectionFogPatch { private static ManualLogSource logger; public AllowNegativeInfectionFogPatch(Harmony harmony, ManualLogSource loggerParent) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown logger = loggerParent; MethodInfo method = typeof(LocalPlayerAgentSettings).GetMethod("UpdateBlendTowardsTargetFogSetting"); harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(AllowNegativeInfectionFogPatch), "AllowBlendNegativeInfectionPlane", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)typeof(LocalPlayerAgentSettings).GetMethod("SetFogSettings"), (HarmonyMethod)null, new HarmonyMethod(typeof(AllowNegativeInfectionFogPatch), "AllowSetNegativeInfectionPlane", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); logger.LogInfo((object)"Patched infection plane functions!"); } private static void AllowSetNegativeInfectionPlane(LocalPlayerAgentSettings __instance, ref FogSettingsDataBlock fogSettings) { if (fogSettings != null && (double)fogSettings.Infection < 0.0) { logger.LogInfo((object)"Set infection plane to one that has negative infection."); ((EffectVolume)LocalPlayerAgentSettings.Current.infectionPlane).invert = (double)fogSettings.DensityHeightMaxBoost > (double)fogSettings.FogDensity; ((EffectVolume)LocalPlayerAgentSettings.Current.infectionPlane).contents = (eEffectVolumeContents)2; ((EffectVolume)LocalPlayerAgentSettings.Current.infectionPlane).modification = (eEffectVolumeModification)0; ((EffectVolume)LocalPlayerAgentSettings.Current.infectionPlane).modificationScale = fogSettings.Infection; LocalPlayerAgentSettings.Current.infectionPlane.lowestAltitude = fogSettings.DensityHeightAltitude; LocalPlayerAgentSettings.Current.infectionPlane.highestAltitude = fogSettings.DensityHeightAltitude + fogSettings.DensityHeightRange; EffectVolumeManager.RegisterVolume((EffectVolume)(object)LocalPlayerAgentSettings.Current.infectionPlane); LocalPlayerAgentSettings.Current.isInfectionPlaneRegistered = true; } } private static void AllowBlendNegativeInfectionPlane(LocalPlayerAgentSettings __instance, float amount) { float currentInfection = LocalPlayerAgentSettings.Current.currentInfection; if ((double)currentInfection < 0.0 && !LocalPlayerAgentSettings.Current.isInfectionPlaneRegistered) { EffectVolumeManager.RegisterVolume((EffectVolume)(object)LocalPlayerAgentSettings.Current.infectionPlane); LocalPlayerAgentSettings.Current.isInfectionPlaneRegistered = true; } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.giginss.rundownmod", "Giginss's Rundown Mod", "1.0.0")] public class DoorPlugin : BasePlugin { private ConfigEntry lurkerNerf; private ConfigEntry psychoBuff; private ConfigEntry rajNerf; public override void Load() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown ((BasePlugin)this).Log.LogInfo((object)"Plugin Giginss's Rundown Mod is loading!"); ((BasePlugin)this).Log.LogInfo((object)"Hello Complex!"); lurkerNerf = ((BasePlugin)this).Config.Bind("Easter Egg", "LurkerNerf", true, "Easter Egg to prevent anyone named Lurker from picking a hammer"); psychoBuff = ((BasePlugin)this).Config.Bind("Easter Egg", "PsychoBuff", true, "Easter Egg to allow anyone named PsychoMadEye to gain enough ammo on D3."); rajNerf = ((BasePlugin)this).Config.Bind("Easter Egg", "RajNerf", true, "Easter Egg to prevent anyone named Raj from picking a spear"); Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("GTFODoorMod.resources.red-x.png"); Texture2D val = new Texture2D(2, 2); if (manifestResourceStream != null) { byte[] array = new byte[32768]; using MemoryStream memoryStream = new MemoryStream(); int count; while ((count = manifestResourceStream.Read(array, 0, array.Length)) > 0) { memoryStream.Write(array, 0, count); } byte[] array2 = memoryStream.ToArray(); ImageConversion.LoadImage(val, Il2CppStructArray.op_Implicit(array2)); } Harmony val2 = new Harmony("com.giginss.rundownmod"); WorldEventsPatcher worldEventsPatcher = new WorldEventsPatcher(val2, val); DoorPatcher doorPatcher = new DoorPatcher(val2); PabloHeavyHitreactPatch pabloHeavyHitreactPatch = new PabloHeavyHitreactPatch(val2, ((BasePlugin)this).Log); AllowNegativeInfectionFogPatch allowNegativeInfectionFogPatch = new AllowNegativeInfectionFogPatch(val2, ((BasePlugin)this).Log); FixWardenObjectiveManager fixWardenObjectiveManager = new FixWardenObjectiveManager(val2, ((BasePlugin)this).Log); OnlyBreakLocksPatch onlyBreakLocksPatch = new OnlyBreakLocksPatch(val2, ((BasePlugin)this).Log); FixProgressionPuzzleNotUsingDimensionIndexPatch fixProgressionPuzzleNotUsingDimensionIndexPatch = new FixProgressionPuzzleNotUsingDimensionIndexPatch(val2, ((BasePlugin)this).Log); FixBaseGameBugs fixBaseGameBugs = new FixBaseGameBugs(val2, ((BasePlugin)this).Log); if (psychoBuff.Value) { InfiniteAmmoEasterEgg infiniteAmmoEasterEgg = new InfiniteAmmoEasterEgg(val2, ((BasePlugin)this).Log); } bool flag = default(bool); if (lurkerNerf.Value) { ManualLogSource log = ((BasePlugin)this).Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(22, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Lurker Nerf is enabled"); } log.LogInfo(val3); EventAPI.OnManagersSetup += CheckAndDisableHammers; } if (rajNerf.Value) { ManualLogSource log2 = ((BasePlugin)this).Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(19, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Raj Nerf is enabled"); } log2.LogInfo(val3); EventAPI.OnManagersSetup += CheckAndDisableSpears; } MethodInfo method = typeof(SNet_Replication).GetMethod("AllocateKey", new Type[2] { typeof(SNet_ReplicatorType), typeof(ushort) }); val2.Patch((MethodBase)method, new HarmonyMethod(typeof(ReplicationPatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void CheckAndDisableHammers() { if (SteamManager.LocalPlayerName.Equals("Lurker", StringComparison.OrdinalIgnoreCase)) { ((GameDataBlockBase)(object)GameDataBlockBase.GetBlock(9u)).internalEnabled = false; ((GameDataBlockBase)(object)GameDataBlockBase.GetBlock(26u)).internalEnabled = false; ((GameDataBlockBase)(object)GameDataBlockBase.GetBlock(27u)).internalEnabled = false; ((GameDataBlockBase)(object)GameDataBlockBase.GetBlock(28u)).internalEnabled = false; ((GameDataBlockBase)(object)GameDataBlockBase.GetBlock(57u)).internalEnabled = false; } } private static void CheckAndDisableSpears() { if (SteamManager.LocalPlayerName.Equals("RAJ", StringComparison.OrdinalIgnoreCase)) { ((GameDataBlockBase)(object)GameDataBlockBase.GetBlock(54u)).internalEnabled = false; ((GameDataBlockBase)(object)GameDataBlockBase.GetBlock(70u)).internalEnabled = false; } } } public class FixBaseGameBugs { private static ManualLogSource logger; public FixBaseGameBugs(Harmony harmony, ManualLogSource loggerParent) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown logger = loggerParent; MethodInfo method = typeof(LocalPlayerAgentSettings).GetMethod("UpdateBlendTowardsTargetFogSetting"); harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(FixBaseGameBugs), "FixInfectionPlanesInDimensions", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)typeof(LG_LightCollection).GetMethod("ResetUpdateValues"), new HarmonyMethod(typeof(FixBaseGameBugs), "FixEmptyLightCollection", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); logger.LogInfo((object)"Patched blend method for dimensions and for empty light collection!"); } private static void FixInfectionPlanesInDimensions(LocalPlayerAgentSettings __instance, float amount) { PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent(); if ((Object)(object)localPlayerAgent != (Object)null) { Dimension dimension = ((Agent)localPlayerAgent).Dimension; if (dimension != null && !dimension.IsMainDimension) { float groundY = dimension.GroundY; EV_Plane infectionPlane = LocalPlayerAgentSettings.Current.infectionPlane; infectionPlane.highestAltitude -= groundY; EV_Plane infectionPlane2 = LocalPlayerAgentSettings.Current.infectionPlane; infectionPlane2.lowestAltitude -= groundY; } } } private static bool FixEmptyLightCollection(LG_LightCollection __instance, bool toStart) { if (__instance.collectedLights.Count == 0 && !toStart) { logger.LogWarning((object)"Light collection has an empty light array! Skipping Reset..."); return false; } return true; } } public class FixProgressionPuzzleNotUsingDimensionIndexPatch { private static ManualLogSource logger; private static LG_Layer lgLayer; public FixProgressionPuzzleNotUsingDimensionIndexPatch(Harmony harmony, ManualLogSource loggerParent) { //IL_0033: 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_0055: Expected O, but got Unknown //IL_0055: Expected O, but got Unknown logger = loggerParent; harmony.Patch((MethodBase)typeof(LG_Distribute_ProgressionPuzzles).GetMethod("CreateKeyItemDistribution"), new HarmonyMethod(typeof(FixProgressionPuzzleNotUsingDimensionIndexPatch), "OverrideLayerIfNeededPrefix", (Type[])null), new HarmonyMethod(typeof(FixProgressionPuzzleNotUsingDimensionIndexPatch), "ResetProgressionPuzzleMainLayer", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); logger.LogInfo((object)"Patched progression puzzle distribution function!"); } private static bool OverrideLayerIfNeededPrefix(LG_Distribute_ProgressionPuzzles __instance, GateKeyItem keyItem, ZonePlacementData placementData) { //IL_000c: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Invalid comparison between I4 and Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_layer.m_dimension.DimensionIndex != placementData.DimensionIndex) { ManualLogSource val = logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(101, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Found dimension mismatch between layer dimension and placement data dimension for Keycard "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(keyItem.m_keyName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", fixing..."); } val.LogInfo(val2); Dimension val3 = default(Dimension); Dimension.GetDimension(placementData.DimensionIndex, ref val3); if (val3 == null) { ManualLogSource val4 = logger; BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Dimension "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(placementData.DimensionIndex); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" not found! Aborting..."); } val4.LogError(val5); return true; } if (val3.MainLayer.m_zones._size <= (int)placementData.LocalIndex) { ManualLogSource val6 = logger; val2 = new BepInExInfoLogInterpolatedStringHandler(101, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Cannot place keycard in "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.DimensionIndex); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("! Not enough zones, dimension has "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.MainLayer.m_zones._size); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" zones and Placement Index is "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(placementData.LocalIndex); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". Aborting..."); } val6.LogInfo(val2); return true; } lgLayer = __instance.m_layer; __instance.m_layer = val3.MainLayer; ManualLogSource val7 = logger; val2 = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Replaced with "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val3.DimensionIndex); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'s MainLayer."); } val7.LogInfo(val2); } return true; } private static void ResetProgressionPuzzleMainLayer(LG_Distribute_ProgressionPuzzles __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (lgLayer != null) { ManualLogSource val = logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(67, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Resetting LG_Layer in Distribute Progression Puzzles to Dimension "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(lgLayer.m_dimension.DimensionIndex); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } val.LogInfo(val2); __instance.m_layer = lgLayer; lgLayer = null; } } } public class FixWardenObjectiveManager { private static ManualLogSource logger; public FixWardenObjectiveManager(Harmony harmony, ManualLogSource loggerParent) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown logger = loggerParent; harmony.Patch((MethodBase)typeof(WardenObjectiveManager).GetMethod("OnLevelCleanup"), (HarmonyMethod)null, new HarmonyMethod(typeof(FixWardenObjectiveManager), "OnLevelCleanupPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); logger.LogInfo((object)"Patched Level Cleanup function!"); } private static void OnLevelCleanupPostfix(WardenObjectiveManager __instance) { logger.LogInfo((object)"Resetting value of exitEventsTriggered."); WardenObjectiveManager.m_exitEventsTriggered = false; } } public class InfiniteAmmoEasterEgg { private static ManualLogSource logger; public InfiniteAmmoEasterEgg(Harmony harmony, ManualLogSource loggerParent) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown logger = loggerParent; harmony.Patch((MethodBase)typeof(CommunicationMenu).GetMethod("BroadcastDialog"), (HarmonyMethod)null, new HarmonyMethod(typeof(InfiniteAmmoEasterEgg), "InfiniteAmmoPatch", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); logger.LogInfo((object)"Setup easter egg!"); } private static void InfiniteAmmoPatch(PlayerAgent src, uint textUID, PlayerAgent dst) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown if (!GameStateManager.IsInExpedition || !RundownManager.ActiveExpedition.Descriptive.PublicName.Equals("Breach")) { return; } uint num = 1309u; if (textUID != num || !SteamManager.LocalPlayerName.Equals("PsychoMadEye", StringComparison.OrdinalIgnoreCase) || !SNet.IsMaster) { return; } PlayerBackpack backpack = PlayerBackpackManager.GetBackpack(src.Owner); if (backpack != null) { PlayerAmmoStorage ammoStorage = backpack.AmmoStorage; ammoStorage.StandardAmmo.AddAmmo(ammoStorage.StandardAmmo.AmmoMaxCap); ammoStorage.SpecialAmmo.AddAmmo(ammoStorage.SpecialAmmo.AmmoMaxCap); ManualLogSource val = logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(21, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Gave easter egg ammo."); } val.LogInfo(val2); } } } public class OnlyBreakLocksPatch { public OnlyBreakLocksPatch(Harmony harmony, ManualLogSource loggerParent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown MethodInfo method = typeof(LG_WeakResourceContainer).GetMethod("SetupWeakLock"); harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(OnlyBreakLocksPatch), "SetBreakLock", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo method2 = typeof(LG_ResourceContainerBuilder).GetMethod("SetupFunctionGO"); harmony.Patch((MethodBase)method2, new HarmonyMethod(typeof(OnlyBreakLocksPatch), "ForceAllLocks", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); loggerParent.LogInfo((object)"Patched weak lock setup function!"); } [HarmonyPrefix] [HarmonyPatch(typeof(LG_ResourceContainerBuilder), "SetupFunctionGO")] private static bool ForceAllLocks(LG_ResourceContainerBuilder __instance, LG_LayerType layer, GameObject GO) { uint persistentID = ((GameDataBlockBase)(object)RundownManager.ActiveExpeditionBalanceData).persistentID; if (persistentID == 5) { __instance.m_locked = true; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(LG_WeakResourceContainer), "SetupWeakLock")] private static bool SetBreakLock(LG_WeakResourceContainer __instance, ref eWeakLockType type) { uint persistentID = ((GameDataBlockBase)(object)RundownManager.ActiveExpeditionBalanceData).persistentID; if (persistentID == 5) { type = (eWeakLockType)1; } return true; } } public class PabloHeavyHitreactPatch { private static ManualLogSource logger; public PabloHeavyHitreactPatch(Harmony harmony, ManualLogSource loggerParent) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown logger = loggerParent; MethodInfo method = typeof(Dam_EnemyDamageBase).GetMethod("ProcessReceivedDamage"); harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(PabloHeavyHitreactPatch), "HavePabloStagger", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); logger.LogInfo((object)"Patched damage received function!"); } [HarmonyPrefix] private static bool HavePabloStagger(Dam_EnemyDamageBase __instance, ref ES_HitreactType hitreact, ref bool tryForceHitreact, float damage, float staggerDamageMulti) { if (__instance.Owner.EnemyDataID == 47) { logger.LogDebug((object)"Forcing a pablo stagger"); hitreact = (ES_HitreactType)4; tryForceHitreact = true; } return true; } } internal static class ReplicationPatch { public static bool OverrideSelfManaged => OverrideCount != 0; public static uint OverrideCount { get; internal set; } public static bool Prefix(SNet_ReplicatorType type, ushort key, ref ushort __result) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (!OverrideSelfManaged) { return true; } if ((int)type != 2) { return true; } __result = (ushort)SNet_Replication.s_highestSlotUsed_SelfManaged; SNet_Replication.s_highestSlotUsed_SelfManaged += 1; return false; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "GTFODoorMod"; public const string PLUGIN_NAME = "GTFODoorMod"; public const string PLUGIN_VERSION = "0.0.1"; } } namespace GTFODoorMod.CustomWorldEvents { public abstract class AbstractWorldEvent { protected static readonly ManualLogSource eventLogger; public abstract string Identifier { get; } static AbstractWorldEvent() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown eventLogger = new ManualLogSource("giginss-doormod-events"); Logger.Sources.Add((ILogSource)(object)eventLogger); } public abstract void OnEventTrigger(ref WardenObjectiveEventData eventData); protected bool TryGetZone(WardenObjectiveEventData eventData, out LG_Zone zone) { //IL_000c: 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: Unknown result type (might be due to invalid IL or missing references) if (!Builder.Current.m_currentFloor.TryGetZoneByLocalIndex(eventData.DimensionIndex, eventData.Layer, eventData.LocalIndex, ref zone)) { zone = null; return false; } return true; } public bool CheckWorldEventCondition(WardenObjectiveEventData eventData) { int conditionIndex = eventData.Condition.ConditionIndex; if (conditionIndex == -1) { return true; } bool isTrue = eventData.Condition.IsTrue; bool condition = WorldEventManager.GetCondition(conditionIndex); return isTrue == condition; } protected LG_WeakDoor[] GetAllWeakDoorsInZone(LG_Zone zone) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 Dictionary dictionary = new Dictionary(); Enumerator enumerator = zone.m_courseNodes.GetEnumerator(); while (enumerator.MoveNext()) { AIG_CourseNode current = enumerator.Current; Enumerator enumerator2 = current.m_portals.GetEnumerator(); while (enumerator2.MoveNext()) { AIG_CoursePortal current2 = enumerator2.Current; iLG_Door_Core door = current2.m_door; if (door != null && (int)door.DoorType == 1) { LG_WeakDoor val = ((Il2CppObjectBase)current2.m_door).TryCast(); if ((Object)(object)val != (Object)null) { dictionary.TryAdd(val.MapperDataID, val); } } } } return dictionary.Values.ToArray(); } } public class AddMovementSpeed : AbstractWorldEvent { public override string Identifier => "AddMovementSpeed"; public override void OnEventTrigger(ref WardenObjectiveEventData eventData) { MoveSpeedAPI.AddModifier(eventData.Duration, (StackLayer)1, "Maintenance"); } } public class ChangeLastKnownMainDimPosition : AbstractWorldEvent { public override string Identifier => "ForgetLastKnownMainDimPosition"; public override void OnEventTrigger(ref WardenObjectiveEventData eData) { //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown Il2CppArrayBase items = PlayerManager.PlayerAgentsInLevel._items; TryGetZone(eData, out var zone); bool flag = default(bool); for (int i = 0; i < items.Count; i++) { PlayerAgent val = items[i]; if (!((Object)(object)val != (Object)null)) { continue; } if (eData.Enabled) { if (zone.m_courseNodes._items.Count > 0) { AIG_CourseNode val2 = zone.m_courseNodes._items[0]; val.HasLastKnownMainDimensionPosition = true; val.LastKnownMainDimensionPosition = val2.GetRandomPositionInside(); val.LastKnownMainDimensionCourseNode = val2; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(99, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val.PlayerName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" has had their last known dimension position changed to a random position inside courseNode 0 for "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)zone).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } AbstractWorldEvent.eventLogger.LogInfo(val3); } else { BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(81, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("No course nodes found for zone "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)zone).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("! Resetting last known dimension position instead."); } AbstractWorldEvent.eventLogger.LogInfo(val3); val.HasLastKnownMainDimensionPosition = false; } } else { val.HasLastKnownMainDimensionPosition = false; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val.PlayerName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" has forgotten their last known dim position!"); } AbstractWorldEvent.eventLogger.LogInfo(val3); } } } } public class CloseAllWeakDoorsInZone : AbstractWorldEvent { public override string Identifier => "CloseAllWeakDoorsInZone"; public override void OnEventTrigger(ref WardenObjectiveEventData eData) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!SNet.IsMaster) { return; } if (TryGetZone(eData, out var zone)) { LG_WeakDoor[] allWeakDoorsInZone = GetAllWeakDoorsInZone(zone); LG_WeakDoor[] array = allWeakDoorsInZone; foreach (LG_WeakDoor val in array) { val.m_sync.AttemptDoorInteraction((eDoorInteractionType)6, 0f, 0f, default(Vector3), (Agent)null); } } else { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Identifier); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" event failed to get target zone!"); } AbstractWorldEvent.eventLogger.LogError(val2); } } } public class DoorLockTracker { private static readonly HashSet LockedDoors = new HashSet(); public static bool IsDoorLocked(uint doorId) { return LockedDoors.Contains(doorId); } public static void LockDoor(uint doorId) { LockedDoors.Add(doorId); } public static void UnlockDoor(uint doorId) { LockedDoors.Remove(doorId); } public static void ClearLockedDoors() { LockedDoors.Clear(); } } public class DoorPatcher { private static readonly ManualLogSource DoorLogger = new ManualLogSource("giginss-doormod-door-patcher"); public DoorPatcher(Harmony harmony) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown Logger.Sources.Add((ILogSource)(object)DoorLogger); DoorLogger.LogInfo((object)"Patching door method"); MethodInfo method = typeof(LG_WeakDoor).GetMethod("AttemptOpenCloseInteraction"); MethodInfo methodInfo = typeof(LG_WeakDoor).GetProperty("InteractionAllowed")?.GetGetMethod(); harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(DoorPatcher), "OpenCloseInteractionPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(DoorPatcher), "InteractionAllowedPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } DoorLogger.LogInfo((object)"Patching successful!"); } private static bool OpenCloseInteractionPrefix(LG_WeakDoor __instance, bool onlyUnlock) { if (DoorLockTracker.IsDoorLocked(__instance.MapperDataID)) { return false; } return true; } private static bool InteractionAllowedPrefix(LG_WeakDoor __instance) { if (DoorLockTracker.IsDoorLocked(__instance.MapperDataID)) { return false; } return true; } } public class LockAllDoorsInZone : AbstractWorldEvent { public override string Identifier => "LockAllDoorsInZone"; public override void OnEventTrigger(ref WardenObjectiveEventData eData) { //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (TryGetZone(eData, out var zone)) { LG_WeakDoor[] allWeakDoorsInZone = GetAllWeakDoorsInZone(zone); Texture2D redXTexture = WorldEventsPatcher.GetRedXTexture(); Sprite sprite = Sprite.Create(redXTexture, new Rect(0f, 0f, (float)((Texture)redXTexture).width, (float)((Texture)redXTexture).height), new Vector2(0.5f, 0.5f), 100f); LG_WeakDoor[] array = allWeakDoorsInZone; foreach (LG_WeakDoor val in array) { DoorLockTracker.LockDoor(val.MapperDataID); foreach (LG_DoorButton item in (Il2CppArrayBase)(object)val.m_buttons) { foreach (SpriteRenderer componentsInChild in ((Component)item).gameObject.GetComponentsInChildren()) { if (((Object)componentsInChild).name.Equals("DoorFrame")) { SpriteRenderer val2 = Object.Instantiate(componentsInChild, ((Component)((Component)componentsInChild).transform.parent).gameObject.transform); ((Object)val2).name = WorldEventsPatcher.SpriteName; val2.sprite = sprite; ((Renderer)val2).enabled = true; } if (WorldEventsPatcher.DoorSpriteRenderers.Contains(((Object)componentsInChild).name)) { ((Component)componentsInChild).gameObject.SetActive(false); } } } } } else { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Identifier); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" event failed to get target zone!"); } AbstractWorldEvent.eventLogger.LogError(val3); } } } public class OpenAllWeakDoorsInZone : AbstractWorldEvent { public override string Identifier => "OpenAllWeakDoorsInZone"; public override void OnEventTrigger(ref WardenObjectiveEventData eData) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!SNet.IsMaster) { return; } if (TryGetZone(eData, out var zone)) { LG_WeakDoor[] allWeakDoorsInZone = GetAllWeakDoorsInZone(zone); LG_WeakDoor[] array = allWeakDoorsInZone; foreach (LG_WeakDoor val in array) { val.m_sync.AttemptDoorInteraction((eDoorInteractionType)0, 0f, 0f, default(Vector3), (Agent)null); } } else { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Identifier); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" event failed to get target zone!"); } AbstractWorldEvent.eventLogger.LogError(val2); } } } public class ReplaceZoneDoorAlarm : AbstractWorldEvent { public override string Identifier => "ReplaceZoneDoorAlarm"; public override void OnEventTrigger(ref WardenObjectiveEventData eData) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected I4, but got Unknown TryGetZone(eData, out var zone); LG_SecurityDoor val = ((Il2CppObjectBase)zone.m_sourceGate.SpawnedDoor).TryCast(); if ((Object)(object)val != (Object)null) { ReplicationPatch.OverrideCount++; eDoorStatus lastStatus = val.LastStatus; eDoorStatus val2 = lastStatus; switch ((int)val2) { case 8: case 9: case 10: case 16: AbstractWorldEvent.eventLogger.LogWarning((object)"Set up chained puzzle on potentially invalid door state."); val.SetupChainedPuzzleLock(eData.ChainPuzzle); break; case 1: case 3: case 4: case 5: case 6: case 7: case 15: val.SetupChainedPuzzleLock(eData.ChainPuzzle); break; case 0: case 2: case 11: case 12: case 13: case 14: AbstractWorldEvent.eventLogger.LogError((object)"Tried to setup chained puzzle on invalid door state"); break; } ReplicationPatch.OverrideCount--; } else { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Identifier); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" event failed to read a security door!"); } AbstractWorldEvent.eventLogger.LogError(val3); } } } public class TeleportPocketItems : AbstractWorldEvent { public override string Identifier => "TeleportPocketItems"; public override void OnEventTrigger(ref WardenObjectiveEventData eventData) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown int count = eventData.Count; int enemyID = (int)eventData.EnemyID; List playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel; bool flag = default(bool); if (count >= playerAgentsInLevel.Count || enemyID >= playerAgentsInLevel.Count) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(95, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Either "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" or "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(enemyID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" are out of range when trying to teleport pocket items. Number of player agents is "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerAgentsInLevel.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } AbstractWorldEvent.eventLogger.LogWarning(val); return; } PlayerAgent val2 = playerAgentsInLevel[count]; PlayerAgent val3 = playerAgentsInLevel[enemyID]; PlayerBackpack val4 = default(PlayerBackpack); bool flag2 = PlayerBackpackManager.TryGetBackpack(val2.Owner, ref val4); PlayerBackpack val5 = default(PlayerBackpack); bool flag3 = PlayerBackpackManager.TryGetBackpack(val3.Owner, ref val5); if (!flag2 || !flag3) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(67, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to get source and/or destination backpack for indices "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" and "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(enemyID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!"); } AbstractWorldEvent.eventLogger.LogWarning(val); return; } List> pocketItemsGroups = val4.PocketItemsGroups; for (int i = 0; i < pocketItemsGroups.Count; i++) { List val6 = pocketItemsGroups._items[i]; for (int j = 0; j < val6.Count; j++) { if (val6.Count > 0) { PocketItem val7 = val6._items[0]; if (!val5.ItemIDToPocketItemGroup.ContainsKey(val7.itemID)) { val5.ItemIDToPocketItemGroup.Add(val7.itemID, new List()); val5.PocketItemsGroups.Add(val5.ItemIDToPocketItemGroup[val7.itemID]); } val5.ItemIDToPocketItemGroup[val7.itemID].Add(val7); } } val6.Clear(); } pocketItemsGroups.Clear(); val4.ItemIDToPocketItemGroup.Clear(); BepInExInfoLogInterpolatedStringHandler val8 = new BepInExInfoLogInterpolatedStringHandler(35, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("Transferred pocket items from "); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" to "); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(enemyID); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("."); } AbstractWorldEvent.eventLogger.LogInfo(val8); PlayerBackpackManager.UpdatePocketItemGUI(); } } public class TeleportResourcePack : AbstractWorldEvent { public override string Identifier => "TeleportResourcePack"; public override void OnEventTrigger(ref WardenObjectiveEventData eventData) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Expected O, but got Unknown int count = eventData.Count; int enemyID = (int)eventData.EnemyID; if (!SNet.IsMaster) { return; } List playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel; bool flag = default(bool); if (count >= playerAgentsInLevel.Count || enemyID >= playerAgentsInLevel.Count) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(95, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Either "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" or "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(enemyID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" are out of range when trying to teleport pocket items. Number of player agents is "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerAgentsInLevel.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } AbstractWorldEvent.eventLogger.LogWarning(val); return; } PlayerAgent val2 = playerAgentsInLevel[count]; PlayerAgent val3 = playerAgentsInLevel[enemyID]; PlayerBackpack val4 = default(PlayerBackpack); bool flag2 = PlayerBackpackManager.TryGetBackpack(val2.Owner, ref val4); PlayerBackpack val5 = default(PlayerBackpack); bool flag3 = PlayerBackpackManager.TryGetBackpack(val3.Owner, ref val5); if (!flag2 || !flag3) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(67, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to get source and/or destination backpack for indices "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" and "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(enemyID); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!"); } AbstractWorldEvent.eventLogger.LogWarning(val); return; } BackpackItem val6 = default(BackpackItem); bool flag4 = val4.TryGetBackpackItem((InventorySlot)4, ref val6); BackpackItem val7 = default(BackpackItem); bool flag5 = val5.TryGetBackpackItem((InventorySlot)4, ref val7); if (flag4) { pItemData_Custom val8 = default(pItemData_Custom); val8.ammo = val4.AmmoStorage.ResourcePackAmmo.AmmoInPack; BepInExInfoLogInterpolatedStringHandler val9 = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("Set source custom.ammo to "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(val8.ammo); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("."); } AbstractWorldEvent.eventLogger.LogInfo(val9); val6.Instance.SetCustomData(val8, false); } if (flag5) { pItemData_Custom val10 = default(pItemData_Custom); val10.ammo = val5.AmmoStorage.ResourcePackAmmo.AmmoInPack; BepInExInfoLogInterpolatedStringHandler val9 = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("Set destination custom.ammo to "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(val10.ammo); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("."); } AbstractWorldEvent.eventLogger.LogInfo(val9); val7.Instance.SetCustomData(val10, false); } if (flag5 && flag4) { PlayerBackpackManager.MasterRemoveItem(val6.Instance, val4); PlayerBackpackManager.MasterRemoveItem(val7.Instance, val5); PlayerBackpackManager.MasterAddItem(val7.Instance, val4); PlayerBackpackManager.MasterAddItem(val6.Instance, val5); BepInExInfoLogInterpolatedStringHandler val9 = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("Swapped resource packs between indices "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" and "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(enemyID); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("."); } AbstractWorldEvent.eventLogger.LogInfo(val9); } else if (!flag5) { PlayerBackpackManager.MasterRemoveItem(val6.Instance, val4); PlayerBackpackManager.MasterAddItem(val6.Instance, val5); BepInExInfoLogInterpolatedStringHandler val9 = new BepInExInfoLogInterpolatedStringHandler(29, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("Sent resource pack from "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" to "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(enemyID); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("."); } AbstractWorldEvent.eventLogger.LogInfo(val9); } else { BepInExInfoLogInterpolatedStringHandler val9 = new BepInExInfoLogInterpolatedStringHandler(49, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("Failed to teleport resource packs from "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" to "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(enemyID); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("! ("); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(flag4); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(flag5); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(")"); } AbstractWorldEvent.eventLogger.LogInfo(val9); } } } public class UnlockAllDoorsInZone : AbstractWorldEvent { public override string Identifier => "UnlockAllDoorsInZone"; public override void OnEventTrigger(ref WardenObjectiveEventData eData) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown if (TryGetZone(eData, out var zone)) { LG_WeakDoor[] allWeakDoorsInZone = GetAllWeakDoorsInZone(zone); LG_WeakDoor[] array = allWeakDoorsInZone; foreach (LG_WeakDoor val in array) { DoorLockTracker.UnlockDoor(val.MapperDataID); foreach (LG_DoorButton item in (Il2CppArrayBase)(object)val.m_buttons) { foreach (SpriteRenderer componentsInChild in ((Component)item).gameObject.GetComponentsInChildren(true)) { if (((Object)componentsInChild).name.Equals(WorldEventsPatcher.SpriteName)) { Object.Destroy((Object)(object)((Component)componentsInChild).gameObject); } if (WorldEventsPatcher.DoorSpriteRenderers.Contains(((Object)componentsInChild).name)) { ((Component)componentsInChild).gameObject.SetActive(true); } } } } } else { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Identifier); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" event failed to get target zone!"); } AbstractWorldEvent.eventLogger.LogError(val2); } } } public class WorldEventsPatcher { [CompilerGenerated] private sealed class d__14 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AbstractWorldEvent abstractWorldEvent; public WardenObjectiveEventData eData; public float delay; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; ExecuteEvent(abstractWorldEvent, eData); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static Dictionary _customWorldEvents = new Dictionary(); private Dictionary _enumMapping = new Dictionary(); private static readonly ManualLogSource EventsLogger = new ManualLogSource("giginss-doormod-events-patcher"); private static Texture2D RedXTexture; public static readonly List DoorSpriteRenderers = new List { "DoorFrame", "Door_Blade_1", "Door_Blade_2", "Door_Blade_3", "Door_Blade_4", "Door_Blade_5", "Door_Blade_6", "Door_Blade_7", "Door_Blade_Broken", "DoorEnterArrow_1", "DoorEnterArrow_2", "DoorEnterArrow_3", "DoorExitArrow" }; private static readonly int eWardenObjectiveEventTypeOffset = 50; private int currentCount = 0; public static string SpriteName => "DoorRedX"; public WorldEventsPatcher(Harmony harmony, Texture2D redX) { //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown Logger.Sources.Add((ILogSource)(object)EventsLogger); RedXTexture = redX; Object.DontDestroyOnLoad((Object)(object)RedXTexture); ((Object)RedXTexture).hideFlags = (HideFlags)61; EventsLogger.LogDebug((object)"Creating door events"); LockAllDoorsInZone worldEvent = new LockAllDoorsInZone(); UnlockAllDoorsInZone worldEvent2 = new UnlockAllDoorsInZone(); OpenAllWeakDoorsInZone worldEvent3 = new OpenAllWeakDoorsInZone(); CloseAllWeakDoorsInZone worldEvent4 = new CloseAllWeakDoorsInZone(); ReplaceZoneDoorAlarm worldEvent5 = new ReplaceZoneDoorAlarm(); ChangeLastKnownMainDimPosition worldEvent6 = new ChangeLastKnownMainDimPosition(); TeleportResourcePack worldEvent7 = new TeleportResourcePack(); TeleportPocketItems worldEvent8 = new TeleportPocketItems(); AddMovementSpeed worldEvent9 = new AddMovementSpeed(); EventsLogger.LogDebug((object)"Registering events"); AddToCustomWorldEvents(worldEvent); AddToCustomWorldEvents(worldEvent2); AddToCustomWorldEvents(worldEvent3); AddToCustomWorldEvents(worldEvent4); AddToCustomWorldEvents(worldEvent5); AddToCustomWorldEvents(worldEvent6); AddToCustomWorldEvents(worldEvent7); AddToCustomWorldEvents(worldEvent8); AddToCustomWorldEvents(worldEvent9); EventsLogger.LogDebug((object)"Injecting events into enum..."); foreach (KeyValuePair customWorldEvent in _customWorldEvents) { _enumMapping[customWorldEvent.Value.Identifier] = customWorldEvent.Key; } EnumInjector.InjectEnumValues(_enumMapping); EventsLogger.LogDebug((object)"Injection complete, patching..."); MethodInfo method = typeof(WorldEventManager).GetMethod("ExecuteEvent"); harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(WorldEventsPatcher), "ExecuteEventPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo method2 = typeof(GS_AfterLevel).GetMethod("CleanupAfterExpedition"); harmony.Patch((MethodBase)method2, (HarmonyMethod)null, new HarmonyMethod(typeof(WorldEventsPatcher), "CleanupLevelPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); EventsLogger.LogDebug((object)"Patching successful!"); } private void AddToCustomWorldEvents(AbstractWorldEvent worldEvent) { int key = eWardenObjectiveEventTypeOffset + currentCount; currentCount++; _customWorldEvents.Add(key, worldEvent); } private static bool ExecuteEventPrefix(ref WardenObjectiveEventData eData, float currentDuration) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected I4, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (_customWorldEvents.ContainsKey((int)eData.Type)) { bool flag = default(bool); if (_customWorldEvents.TryGetValue((int)eData.Type, out var value)) { BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(11, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Triggering "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.Identifier); } EventsLogger.LogDebug(val); if (!value.CheckWorldEventCondition(eData)) { return false; } float delay = eData.Delay; if (delay > 0f) { CoroutineDispatcher.StartCoroutine(ExecuteEventCoroutine(value, eData, delay)); } else { ExecuteEvent(value, eData); } } else { BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(81, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Key "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(eData.Type); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" exists in the custom world events dictionary but failed to retrieve it!?!?!?"); } EventsLogger.LogError(val2); } return false; } return true; } [HarmonyPostfix] private static void CleanupLevelPostfix() { DoorLockTracker.ClearLockedDoors(); } public static Texture2D GetRedXTexture() { return RedXTexture; } [IteratorStateMachine(typeof(d__14))] private static IEnumerator ExecuteEventCoroutine(AbstractWorldEvent abstractWorldEvent, WardenObjectiveEventData eData, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__14(0) { abstractWorldEvent = abstractWorldEvent, eData = eData, delay = delay }; } private static void ExecuteEvent(AbstractWorldEvent abstractWorldEvent, WardenObjectiveEventData eData) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) abstractWorldEvent.OnEventTrigger(ref eData); WardenObjectiveManager.DisplayWardenIntel(eData.Layer, eData.WardenIntel); } } }