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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
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 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+ca4967312ec7a27788fc725ceb38bf7ab39403cd")]
[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;
}
}
}
[BepInPlugin("com.giginss.rundownmod", "Giginss's Rundown Mod", "0.0.4")]
public class DoorPlugin : BasePlugin
{
public override void Load()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
((BasePlugin)this).Log.LogInfo((object)"Plugin Giginss's Rundown Mod is loading!");
((BasePlugin)this).Log.LogInfo((object)"Hello Complex!");
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<byte>.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);
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);
}
}
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<uint, LG_WeakDoor> dictionary = new Dictionary<uint, LG_WeakDoor>();
Enumerator<AIG_CourseNode> enumerator = zone.m_courseNodes.GetEnumerator();
while (enumerator.MoveNext())
{
AIG_CourseNode current = enumerator.Current;
Enumerator<AIG_CoursePortal> 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<LG_WeakDoor>();
if ((Object)(object)val != (Object)null)
{
dictionary.TryAdd(val.MapperDataID, val);
}
}
}
}
return dictionary.Values.ToArray();
}
}
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<string>(Identifier);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" event failed to get target zone!");
}
AbstractWorldEvent.eventLogger.LogError(val2);
}
}
}
public class DoorLockTracker
{
private static readonly HashSet<uint> LockedDoors = new HashSet<uint>();
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<LG_DoorButton>)(object)val.m_buttons)
{
foreach (SpriteRenderer componentsInChild in ((Component)item).gameObject.GetComponentsInChildren<SpriteRenderer>())
{
if (((Object)componentsInChild).name.Equals("DoorFrame"))
{
SpriteRenderer val2 = Object.Instantiate<SpriteRenderer>(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<string>(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<string>(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<LG_SecurityDoor>();
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<string>(Identifier);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" event failed to read a security door!");
}
AbstractWorldEvent.eventLogger.LogError(val3);
}
}
}
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<LG_DoorButton>)(object)val.m_buttons)
{
foreach (SpriteRenderer componentsInChild in ((Component)item).gameObject.GetComponentsInChildren<SpriteRenderer>(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<string>(Identifier);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" event failed to get target zone!");
}
AbstractWorldEvent.eventLogger.LogError(val2);
}
}
}
public class WorldEventsPatcher
{
private static Dictionary<int, AbstractWorldEvent> _customWorldEvents = new Dictionary<int, AbstractWorldEvent>();
private Dictionary<string, object> _enumMapping = new Dictionary<string, object>();
private static readonly ManualLogSource EventsLogger = new ManualLogSource("giginss-doormod-events-patcher");
private static Texture2D RedXTexture;
public static readonly List<string> DoorSpriteRenderers = new List<string>
{
"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_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Expected O, but got Unknown
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: 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();
EventsLogger.LogDebug((object)"Registering events");
AddToCustomWorldEvents(worldEvent);
AddToCustomWorldEvents(worldEvent2);
AddToCustomWorldEvents(worldEvent3);
AddToCustomWorldEvents(worldEvent4);
AddToCustomWorldEvents(worldEvent5);
EventsLogger.LogDebug((object)"Injecting events into enum...");
foreach (KeyValuePair<int, AbstractWorldEvent> customWorldEvent in _customWorldEvents)
{
_enumMapping[customWorldEvent.Value.Identifier] = customWorldEvent.Key;
}
EnumInjector.InjectEnumValues<eWardenObjectiveEventType>(_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<string>(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<eWardenObjectiveEventType>(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;
}
private static IEnumerator ExecuteEventCoroutine(AbstractWorldEvent abstractWorldEvent, WardenObjectiveEventData eData, float delay)
{
yield return (object)new WaitForSeconds(delay);
ExecuteEvent(abstractWorldEvent, eData);
}
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);
}
}
}