using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using FairerFireExits.Networking;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
using OreoM.FairerFireExits.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AccessibilityModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AndroidJNIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AnimationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClothModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterInputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterRendererModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ContentLoadModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CoreModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CrashReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DirectorModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DSPGraphModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GameCenterModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GridModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.HotReloadModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ImageConversionModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.IMGUIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputLegacyModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.JSONSerializeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.LocalizationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ParticleSystemModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PerformanceReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.Physics2DModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ProfilerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PropertiesModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ScreenCaptureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SharedInternalsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteMaskModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteShapeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.StreamingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubstanceModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubsystemsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainPhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreFontEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreTextEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextRenderingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TilemapModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TLSModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UmbraModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsCommonModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityConnectModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityCurlModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityTestProtocolModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestTextureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestWWWModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VehiclesModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VFXModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VideoModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VirtualTexturingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VRModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.WindModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XRModule")]
[assembly: AssemblyCompany("OreoM.FairerFireExits")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("FairerFireExits")]
[assembly: AssemblyTitle("OreoM.FairerFireExits")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[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 FairerFireExits
{
[BepInPlugin("OreoM.FairerFireExits", "FairerFireExits", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class FairerFireExits : BaseUnityPlugin
{
public const string LethalConfigGUID = "ainavt.lc.lethalconfig";
public static FairerFireExits Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static FairerFireExitsConfig FireConfig { get; set; }
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Patch();
NetcodePatch();
Logger.LogInfo((object)"OreoM.FairerFireExits v1.2.0 has loaded!");
}
private static void NetcodePatch()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
internal static void Patch()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("OreoM.FairerFireExits");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public class FairerFireExitsConfig
{
internal Dictionary<DungeonFlow, ConfigEntry<bool>> ApplyFireExitChangePerInterior;
private bool? lethalConfigLoaded;
public FairerFireExitsConfig(ConfigFile cfg, DungeonFlow[] AllInteriors)
{
if (!lethalConfigLoaded.HasValue)
{
lethalConfigLoaded = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
}
ApplyFireExitChangePerInterior = new Dictionary<DungeonFlow, ConfigEntry<bool>>();
cfg.SaveOnConfigSet = false;
foreach (DungeonFlow val in AllInteriors)
{
ConfigEntry<bool> val2 = cfg.Bind<bool>("General", Regex.Replace(((Object)val).name, "Flow$", "", RegexOptions.None), true, "Apply Fairer Fire Exits patch to this interior");
if (ApplyFireExitChangePerInterior.TryGetValue(val, out ConfigEntry<bool> _))
{
FairerFireExits.Logger.LogError((object)(((Object)val).name + " has duplicate entries, this shouldn't happen... skipping this entry"));
continue;
}
if (lethalConfigLoaded.Value)
{
AddLethalConfigItem(val2);
}
ApplyFireExitChangePerInterior[val] = val2;
}
ClearOrphanedEntries(cfg);
cfg.Save();
cfg.SaveOnConfigSet = true;
if (lethalConfigLoaded.Value)
{
ConfigLethalConfigModEntry();
}
}
private void ClearOrphanedEntries(ConfigFile cfg)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
dictionary.Clear();
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private void AddLethalConfigItem(ConfigEntry<bool> entry)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(entry, false);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private void ConfigLethalConfigModEntry()
{
LethalConfigManager.SetModDescription("Choose what modded interiors are affected by this mod!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "OreoM.FairerFireExits";
public const string PLUGIN_NAME = "FairerFireExits";
public const string PLUGIN_VERSION = "1.2.0";
}
}
namespace FairerFireExits.Patches
{
[HarmonyPatch(typeof(DungeonGenerator))]
internal class DungeonGeneratorPatches
{
[HarmonyPatch("Generate")]
[HarmonyPrefix]
private static void PreGenerate(DungeonGenerator __instance)
{
if (((NetworkBehaviour)FFENetworkManager.Instance).IsServer || ((NetworkBehaviour)FFENetworkManager.Instance).IsHost)
{
if (FairerFireExits.FireConfig.ApplyFireExitChangePerInterior.TryGetValue(__instance.DungeonFlow, out ConfigEntry<bool> value) && !value.Value)
{
FairerFireExits.Logger.LogInfo((object)("Found current DungeonFlow (" + ((Object)__instance.DungeonFlow).name + ") config but patch is set to false"));
FFENetworkManager.Instance.shouldUseFireExitPatch.Value = false;
}
else
{
FFENetworkManager.Instance.shouldUseFireExitPatch.Value = true;
}
}
}
[HarmonyPatch("ProcessGlobalProps")]
[HarmonyPrefix]
private static void PreProcessGlobalProps(DungeonGenerator __instance)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
if (!FFENetworkManager.Instance.shouldUseFireExitPatch.Value)
{
return;
}
foreach (Tile allTile in __instance.CurrentDungeon.AllTiles)
{
GlobalProp[] componentsInChildren = ((Component)allTile).GetComponentsInChildren<GlobalProp>();
GlobalProp[] array = componentsInChildren;
foreach (GlobalProp val in array)
{
if (val.PropGroupID == 1231)
{
val.DepthWeightScale = new AnimationCurve(DungeonGeneratorHelper.fireExitKeyframes);
}
}
SpawnSyncedObject componentInChildren = ((Component)allTile).GetComponentInChildren<SpawnSyncedObject>();
if (!((Object)(object)componentInChildren == (Object)null) && ((Object)componentInChildren.spawnPrefab).name == "EntranceTeleportA")
{
DungeonGeneratorHelper.mainDoorDepth = allTile.Placement.NormalizedPathDepth;
FairerFireExits.Logger.LogInfo((object)$"Found Main exit at {DungeonGeneratorHelper.mainDoorDepth} of the main path");
}
}
}
[HarmonyPatch("ProcessGlobalProps")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> TranspileProcessGlobalProps(IEnumerable<CodeInstruction> codes)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(codes, (ILGenerator)null);
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(TilePlacementData), "NormalizedDepth"), (string)null)
});
if (val.IsInvalid)
{
FairerFireExits.Logger.LogError((object)"Could not the ending pattern. Aborting TranspileProcessGlobalProps transpiler.");
return codes;
}
int pos = val.Pos;
val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null)
});
if (val.IsInvalid)
{
FairerFireExits.Logger.LogError((object)"Could not the starting pattern. Aborting TranspileProcessGlobalProps transpiler.");
return codes;
}
val.Advance(1);
int pos2 = val.Pos;
val.RemoveInstructionsInRange(pos2, pos);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldloc_S, (object)6),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(DungeonGeneratorHelper), "GetNormalizedPathDepthForFireExit", (Type[])null, (Type[])null))
});
return val.InstructionEnumeration();
}
}
internal static class DungeonGeneratorHelper
{
public const int fireExitGroupID = 1231;
public static float mainDoorDepth = 0f;
public static readonly Keyframe[] fireExitKeyframes = (Keyframe[])(object)new Keyframe[5]
{
new Keyframe(0f, 0f, 0f, 0f),
new Keyframe(0.2f, 0f, 7.952512E-06f, 0.04168295f),
new Keyframe(0.5f, 0.3f, 7.952512E-06f, 0.04168295f),
new Keyframe(0.8f, 1f, 0.02613646f, 0.02613646f),
new Keyframe(1f, 1f, 0.02613646f, 0.02613646f)
};
public static float GetAdjustedDistanceFromMain(float NormalizedPathDepth)
{
mainDoorDepth = 0f;
float num = Mathf.Max(mainDoorDepth, 1f - mainDoorDepth);
return Mathf.Abs(NormalizedPathDepth - mainDoorDepth) / num;
}
public static float GetNormalizedPathDepthForFireExit(Tile currTile, GlobalProp currProp, DungeonGenerator instance)
{
if (!FFENetworkManager.Instance.shouldUseFireExitPatch.Value)
{
return currTile.Placement.NormalizedDepth;
}
if (currProp.PropGroupID != 1231)
{
return currTile.Placement.NormalizedDepth;
}
return GetAdjustedDistanceFromMain(currTile.Placement.NormalizedPathDepth);
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManagerPatches
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void PostStart(GameNetworkManager __instance)
{
FFENetworkManager.CreateAndRegisterPrefab();
DungeonFlow[] allInteriors = Resources.FindObjectsOfTypeAll<DungeonFlow>();
FairerFireExits.FireConfig = new FairerFireExitsConfig(((BaseUnityPlugin)FairerFireExits.Instance).Config, allInteriors);
}
[HarmonyPatch("Disconnect")]
[HarmonyPrefix]
private static void PreDisconnect(GameNetworkManager __instance)
{
FFENetworkManager.DespawnNetworkHandler();
}
}
[HarmonyPatch(typeof(NetworkManager))]
internal static class NetworkManagerPatches
{
private static readonly string MOD_GUID = "OreoM.FairerFireExits";
[HarmonyPostfix]
[HarmonyPatch("SetSingleton")]
private static void RegisterPrefab()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(MOD_GUID + " Prefab");
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
Object.DontDestroyOnLoad((Object)(object)val);
NetworkObject obj = val.AddComponent<NetworkObject>();
FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic);
field.SetValue(obj, GetHash(MOD_GUID));
NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val);
static uint GetHash(string value)
{
return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0;
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatches
{
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void PreAwake(StartOfRound __instance)
{
FFENetworkManager.SpawnNetworkHandler();
}
}
}
namespace FairerFireExits.Networking
{
internal class FFENetworkManager : NetworkBehaviour
{
private static GameObject prefab;
private const bool default_shouldUseFireExitPatch = true;
public NetworkVariable<bool> shouldUseFireExitPatch = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
public static FFENetworkManager Instance { get; private set; }
public static void CreateAndRegisterPrefab()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)prefab != (Object)null))
{
prefab = new GameObject("OreoM.FairerFireExits Prefab");
GameObject obj = prefab;
((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x3D);
NetworkObject val = prefab.AddComponent<NetworkObject>();
val.GlobalObjectIdHash = XXHash.Hash32(((Object)prefab).name);
prefab.AddComponent<FFENetworkManager>();
NetworkManager.Singleton.AddNetworkPrefab(prefab);
FairerFireExits.Logger.LogInfo((object)"Network prefab created and registered");
}
}
public static void SpawnNetworkHandler()
{
if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)
{
Object.Instantiate<GameObject>(prefab).GetComponent<NetworkObject>().Spawn(false);
FairerFireExits.Logger.LogInfo((object)"Network handler spawned");
}
}
public static void DespawnNetworkHandler()
{
if ((Object)(object)Instance != (Object)null && ((Component)Instance).gameObject.GetComponent<NetworkObject>().IsSpawned && (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost))
{
((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
FairerFireExits.Logger.LogInfo((object)"Network handler despawned");
}
}
private void Awake()
{
Instance = this;
}
protected override void __initializeVariables()
{
if (shouldUseFireExitPatch == null)
{
throw new Exception("FFENetworkManager.shouldUseFireExitPatch cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)shouldUseFireExitPatch).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)shouldUseFireExitPatch, "shouldUseFireExitPatch");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)shouldUseFireExitPatch);
((NetworkBehaviour)this).__initializeVariables();
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "FFENetworkManager";
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace OreoM.FairerFireExits.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}