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 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+acef18cbf865767ce1910ae674000d29b9d21a1b")]
[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_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: 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);
FixWardenObjectiveManager fixWardenObjectiveManager = new FixWardenObjectiveManager(val2, ((BasePlugin)this).Log);
OnlyBreakLocksPatch onlyBreakLocksPatch = new OnlyBreakLocksPatch(val2, ((BasePlugin)this).Log);
FixProgressionPuzzleNotUsingDimensionIndexPatch fixProgressionPuzzleNotUsingDimensionIndexPatch = new FixProgressionPuzzleNotUsingDimensionIndexPatch(val2, ((BasePlugin)this).Log);
FixDimensionInfectionPlane fixDimensionInfectionPlane = new FixDimensionInfectionPlane(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 FixDimensionInfectionPlane
{
private static ManualLogSource logger;
private static float lastLogtime;
public FixDimensionInfectionPlane(Harmony harmony, ManualLogSource loggerParent)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
logger = loggerParent;
MethodInfo method = typeof(EffectVolumeManager).GetMethod("RegisterVolume");
MethodInfo method2 = typeof(EffectVolumeManager).GetMethod("UnregisterVolume");
MethodInfo method3 = typeof(EffectVolumeManager).GetMethod("Update");
MethodInfo method4 = typeof(LocalPlayerAgentSettings).GetMethod("UpdateBlendTowardsTargetFogSetting");
harmony.Patch((MethodBase)method4, (HarmonyMethod)null, new HarmonyMethod(typeof(FixDimensionInfectionPlane), "FixInfectionPlanesInDimensions", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
logger.LogInfo((object)"Patched blend method for dimensions!");
}
private static void UpdatePostfix()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Expected O, but got Unknown
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
if (!(lastLogtime + 2f < Clock.Time))
{
return;
}
lastLogtime = Clock.Time;
ManualLogSource val = logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Effect Volume Count: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(EffectVolumeManager.volumes.Count);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val.LogInfo(val2);
EV_Plane infectionPlane = LocalPlayerAgentSettings.Current.infectionPlane;
ManualLogSource val3 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(69, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Local Infection Plane details; Highest Altitude: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(infectionPlane.highestAltitude);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Lowest Altitude: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(infectionPlane.lowestAltitude);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val3.LogInfo(val2);
for (int i = 0; i < EffectVolumeManager.targets.Count; i++)
{
IEffectVolumeTarget val4 = EffectVolumeManager.targets[i];
ManualLogSource val5 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Effect Volume Target Data Ref Pos: ");
BepInExInfoLogInterpolatedStringHandler obj = val2;
EV_TargetData effectVolumeTargetData = val4.EffectVolumeTargetData;
((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>(((object)(Vector3)(ref effectVolumeTargetData.referencePosition)).ToString());
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val5.LogInfo(val2);
}
Dimension val6 = default(Dimension);
for (int j = 0; j < Dimension.DimensionCount; j++)
{
bool dimensionFromCreationIndex = Dimension.GetDimensionFromCreationIndex(j, ref val6);
ManualLogSource val7 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(34, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Dimension ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(val6.CreationOrderIndex);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", GroundY: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val6.GroundY);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Position: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector3>(val6.Position);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val7.LogInfo(val2);
}
}
private static void RegisterVolumePostfix(EffectVolume volume)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Expected O, but got Unknown
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Expected O, but got Unknown
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
ManualLogSource val = logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Registered Effect Volume ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((object)volume).GetType().FullName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val.LogInfo(val2);
ManualLogSource val3 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(96, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Effect Volume Details; Contents: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<eEffectVolumeContents>(volume.contents);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", EffectOrder: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(volume.effectOrder);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Invert: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(volume.invert);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Modification: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<eEffectVolumeModification>(volume.modification);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ModificationScale: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(volume.modificationScale);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val3.LogInfo(val2);
if (volume is EV_Plane)
{
EV_Plane val4 = (EV_Plane)volume;
ManualLogSource val5 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(56, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EV_Plane details; Highest Altitude: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val4.highestAltitude);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Lowest Altitude: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val4.lowestAltitude);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val5.LogInfo(val2);
}
else if (volume is EV_Sphere)
{
EV_Sphere val6 = (EV_Sphere)volume;
ManualLogSource val7 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(58, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EV_Sphere details; Max Radius: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val6.maxRadius);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Min Radius: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val6.minRadius);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Position: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector3>(val6.position);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val7.LogInfo(val2);
}
}
private static void UnregisterVolumePostfix(EffectVolume volume)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Expected O, but got Unknown
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Expected O, but got Unknown
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
ManualLogSource val = logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Unregistered Effect Volume ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((object)volume).GetType().FullName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val.LogInfo(val2);
ManualLogSource val3 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(96, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Effect Volume Details; Contents: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<eEffectVolumeContents>(volume.contents);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", EffectOrder: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(volume.effectOrder);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Invert: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(volume.invert);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Modification: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<eEffectVolumeModification>(volume.modification);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ModificationScale: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(volume.modificationScale);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val3.LogInfo(val2);
if (volume is EV_Plane)
{
EV_Plane val4 = (EV_Plane)volume;
ManualLogSource val5 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(56, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EV_Plane details; Highest Altitude: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val4.highestAltitude);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Lowest Altitude: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val4.lowestAltitude);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val5.LogInfo(val2);
}
else if (volume is EV_Sphere)
{
EV_Sphere val6 = (EV_Sphere)volume;
ManualLogSource val7 = logger;
val2 = new BepInExInfoLogInterpolatedStringHandler(58, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EV_Sphere details; Max Radius: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val6.maxRadius);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Min Radius: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(val6.minRadius);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Position: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector3>(val6.position);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
val7.LogInfo(val2);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(LocalPlayerAgentSettings), "UpdateBlendTowardsTargetFogSetting")]
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;
}
}
}
}
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<string>(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<eDimensionIndex>(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<eDimensionIndex>(val3.DimensionIndex);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("! Not enough zones, dimension has ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(val3.MainLayer.m_zones._size);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" zones and Placement Index is ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<eLocalZoneIndex>(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<eDimensionIndex>(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<eDimensionIndex>(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 infection plane functions!");
}
private static void OnLevelCleanupPostfix(WardenObjectiveManager __instance)
{
logger.LogInfo((object)"Resetting value of exitEventsTriggered.");
WardenObjectiveManager.m_exitEventsTriggered = false;
}
}
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<ExpeditionBalanceDataBlock>)(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<ExpeditionBalanceDataBlock>)(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<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 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<PlayerAgent> 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<string>(val.PlayerName);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" has had their last known dimension position changed to a random position inside courseNode 0 for ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((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<string>(((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<string>(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<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 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<PlayerAgent> 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<int>(count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" or ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(enemyID);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" are out of range when trying to teleport pocket items. Number of player agents is ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(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<int>(count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" and ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(enemyID);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!");
}
AbstractWorldEvent.eventLogger.LogWarning(val);
return;
}
List<List<PocketItem>> pocketItemsGroups = val4.PocketItemsGroups;
for (int i = 0; i < pocketItemsGroups.Count; i++)
{
List<PocketItem> 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<PocketItem>());
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<int>(count);
((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" to ");
((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<int>(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<PlayerAgent> 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<int>(count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" or ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(enemyID);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" are out of range when trying to teleport pocket items. Number of player agents is ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(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<int>(count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" and ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(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<float>(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<float>(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<int>(count);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" and ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<int>(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<int>(count);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" to ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<int>(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<int>(count);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" to ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<int>(enemyID);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("! (");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<bool>(flag4);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<bool>(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<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_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Expected O, but got Unknown
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: 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();
EventsLogger.LogDebug((object)"Registering events");
AddToCustomWorldEvents(worldEvent);
AddToCustomWorldEvents(worldEvent2);
AddToCustomWorldEvents(worldEvent3);
AddToCustomWorldEvents(worldEvent4);
AddToCustomWorldEvents(worldEvent5);
AddToCustomWorldEvents(worldEvent6);
AddToCustomWorldEvents(worldEvent7);
AddToCustomWorldEvents(worldEvent8);
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);
}
}
}