Decompiled source of InterlopingArtifact v0.3.0

InterlopingArtifact.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HDeMods.INTER;
using HDeMods.InterOptionalMods;
using HarmonyLib;
using On.RoR2;
using ProperSave;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Components.Options;
using RiskOfOptions.Components.Panel;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Achievements.Artifacts;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: IgnoresAccessChecksTo("RiskOfOptions")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("InterlopingArtifact")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyProduct("InterlopingArtifact")]
[assembly: AssemblyTitle("InterlopingArtifact")]
[assembly: AssemblyInformationalVersion("1.0.0+045854128c8c7792d227e058d40681b16e2d5613")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HDeMods
{
	public class CullingTracker : MonoBehaviour
	{
		private CharacterBody m_body;

		public bool canBeCulled;

		public bool isMinion;

		private bool m_isBigMan;

		private bool m_isVeryBigMan;

		private InterloperCullingZone m_rangeDisplayController;

		public bool Player { get; private set; }

		private void Awake()
		{
			//IL_003a: 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)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Log.Warning("Culling Tracker created on Client.");
				return;
			}
			if (!InterlopingArtifact.artifactEnabled && !InterlopingArtifact.HurricaneRun)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			m_body = ((Component)this).GetComponent<CharacterBody>();
			m_isBigMan = InterRefs.IsBigMan(m_body.bodyIndex);
			m_isVeryBigMan = InterRefs.IsVeryBigMan(m_body.bodyIndex);
			if (!Object.op_Implicit((Object)(object)m_body.master))
			{
				Log.Warning(((Object)m_body).name + " master not found. Assuming this is not a player or a minion.");
				return;
			}
			if ((Object)(object)m_body.master.minionOwnership.ownerMaster != (Object)null)
			{
				CharacterBody body = m_body.master.minionOwnership.ownerMaster.GetBody();
				if (!Object.op_Implicit((Object)(object)body))
				{
					Log.Warning(((Object)m_body).name + " ownerMaster has no body! Assuming this is not a Geep or Gip!");
					isMinion = true;
					return;
				}
				if (body.bodyIndex != InterRefs.Gup && body.bodyIndex != InterRefs.Geep)
				{
					isMinion = true;
					return;
				}
			}
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (!((Object)(object)m_body.master != (Object)(object)instance.master))
				{
					Player = true;
					Log.Message(((Object)m_body).name + " is a player.");
					GameObject val = Object.Instantiate<GameObject>(InterloperCullingZone.rangeDisplayPrefab);
					NetworkServer.Spawn(val);
					m_rangeDisplayController = val.GetComponent<InterloperCullingZone>();
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || m_isVeryBigMan)
			{
				return;
			}
			float num = InterlopingArtifact.aggressiveCullingRadius.Value;
			if (Player)
			{
				if (!InterRunInfo.instance.loiterPenaltyActive || !InterlopingArtifact.aggressiveCulling.Value)
				{
					m_rangeDisplayController.CallRpcSetVisibility(visibility: false);
					return;
				}
				m_rangeDisplayController.CallRpcSetPosition(((Component)this).transform.localPosition);
				m_rangeDisplayController.CallRpcSetSize(Vector3.one * (num * 2f));
				m_rangeDisplayController.CallRpcSetVisibility(visibility: true);
			}
			else if (InterRunInfo.instance.loiterPenaltyActive)
			{
				if (m_isBigMan)
				{
					num *= 2f;
				}
				canBeCulled = !m_body.NearAnyPlayers(num);
			}
		}

		private void OnDestroy()
		{
			if (NetworkServer.active && Player)
			{
				NetworkServer.Destroy(((Component)m_rangeDisplayController).gameObject);
			}
		}
	}
	internal class InterloperCullingZone : NetworkBehaviour
	{
		public static GameObject rangeDisplayPrefab;

		private static Material material;

		private ObjectScaleCurve m_rangeDisplayRenderer;

		private bool m_visible;

		private bool m_visiblePreviousFrame;

		private bool m_enabledPreviousFrame;

		private static int kRpcRpcSetPosition;

		private static int kRpcRpcSetSize;

		private static int kRpcRpcSetVisibility;

		public static void InitZone()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = InterlopingArtifact.InterBundle.LoadAsset<GameObject>("InterloperCullingZoneVisual");
			rangeDisplayPrefab = PrefabAPI.InstantiateClone(val, "Interloper_CullZone");
			Object.Destroy((Object)(object)val);
			material = Object.Instantiate<Material>(Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Teleporters/matTeleporterRangeIndicator.mat").WaitForCompletion());
			((Object)material).name = "matInterloperCullingZone";
			material.SetTexture(InterRefs.remapTex, (Texture)(object)InterlopingArtifact.InterBundle.LoadAsset<Texture2D>("texRampCulling2"));
			material.SetFloat(InterRefs.softFactor, 0.25f);
			material.SetFloat(InterRefs.softPower, 1f);
			material.SetFloat(InterRefs.brightnessBoost, 0.1f);
			material.SetFloat(InterRefs.alphaBoost, 0.5f);
			material.SetFloat(InterRefs.intersectionStrength, 20f);
			((Renderer)rangeDisplayPrefab.GetComponentInChildren<MeshRenderer>()).material = material;
			rangeDisplayPrefab.AddComponent<InterloperCullingZone>();
		}

		private void Awake()
		{
			m_rangeDisplayRenderer = ((Component)this).GetComponent<ObjectScaleCurve>();
			((Behaviour)m_rangeDisplayRenderer).enabled = false;
		}

		private void Update()
		{
			if (m_visible != m_visiblePreviousFrame || InterlopingArtifact.showCullingRadius.Value != m_enabledPreviousFrame)
			{
				SetVisible(m_visible);
			}
			m_enabledPreviousFrame = InterlopingArtifact.showCullingRadius.Value;
			m_visiblePreviousFrame = m_visible;
		}

		private void SetVisible(bool visibility)
		{
			if (visibility && InterlopingArtifact.showCullingRadius.Value)
			{
				((Behaviour)m_rangeDisplayRenderer).enabled = true;
				return;
			}
			m_rangeDisplayRenderer.Reset();
			((Behaviour)m_rangeDisplayRenderer).enabled = false;
		}

		[ClientRpc]
		public void RpcSetPosition(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SetPosition(position);
		}

		[ClientRpc]
		public void RpcSetSize(Vector3 size)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SetSize(size);
		}

		[ClientRpc]
		public void RpcSetVisibility(bool visibility)
		{
			SetVisibility(visibility);
		}

		private void SetPosition(Vector3 position)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.localPosition = position;
		}

		private void SetSize(Vector3 size)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			m_rangeDisplayRenderer.baseScale = size;
		}

		private void SetVisibility(bool visibility)
		{
			m_visible = visibility;
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeRpcRpcSetPosition(NetworkBehaviour obj, NetworkReader reader)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcSetPosition called on server.");
			}
			else
			{
				((InterloperCullingZone)(object)obj).RpcSetPosition(reader.ReadVector3());
			}
		}

		protected static void InvokeRpcRpcSetSize(NetworkBehaviour obj, NetworkReader reader)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcSetSize called on server.");
			}
			else
			{
				((InterloperCullingZone)(object)obj).RpcSetSize(reader.ReadVector3());
			}
		}

		protected static void InvokeRpcRpcSetVisibility(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcSetVisibility called on server.");
			}
			else
			{
				((InterloperCullingZone)(object)obj).RpcSetVisibility(reader.ReadBoolean());
			}
		}

		public void CallRpcSetPosition(Vector3 position)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcSetPosition called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcSetPosition);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write(position);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcSetPosition");
		}

		public void CallRpcSetSize(Vector3 size)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcSetSize called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcSetSize);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write(size);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcSetSize");
		}

		public void CallRpcSetVisibility(bool visibility)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcSetVisibility called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcSetVisibility);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write(visibility);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcSetVisibility");
		}

		static InterloperCullingZone()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			kRpcRpcSetPosition = -200678569;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterloperCullingZone), kRpcRpcSetPosition, new CmdDelegate(InvokeRpcRpcSetPosition));
			kRpcRpcSetSize = 1901424943;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterloperCullingZone), kRpcRpcSetSize, new CmdDelegate(InvokeRpcRpcSetSize));
			kRpcRpcSetVisibility = 981719488;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterloperCullingZone), kRpcRpcSetVisibility, new CmdDelegate(InvokeRpcRpcSetVisibility));
			NetworkCRC.RegisterBehaviour("InterloperCullingZone", 0);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			bool result = default(bool);
			return result;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
		}
	}
	[RegisterAchievement("INTERLOPER_ARTIFACT", "Artifacts.Interloper", "", 3u, null)]
	public class InterAchievement : BaseObtainArtifactAchievement
	{
		public override ArtifactDef artifactDef => InterlopingArtifact.Artifact;
	}
	internal static class InterArtifactTrial
	{
		internal static void CheckArtifactTrial(orig_SetCurrentArtifact setCurrentArtifact, ArtifactTrialMissionController self, int artifact)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between I4 and Unknown
			if (artifact == (int)InterlopingArtifact.Artifact.artifactIndex && NetworkServer.active)
			{
				InterlopingArtifact.artifactTrial = true;
			}
			setCurrentArtifact.Invoke(self, artifact);
		}

		internal static void BeginTrial(orig_OnEnter onEnter, EntityState self)
		{
			if (InterlopingArtifact.artifactTrial && NetworkServer.active)
			{
				InterRunInfo.instance.NetworkloiterPenaltyActive = true;
			}
			onEnter.Invoke(self);
		}

		internal static void OnShellTakeDamage(ArtifactTrialMissionController mc, DamageReport dr)
		{
			if (InterlopingArtifact.artifactTrial && NetworkServer.active)
			{
				InterlopingArtifact.artifactChallengeMult += 0.25f;
			}
		}

		internal static void OnShellDeath(ArtifactTrialMissionController mc, DamageReport dr)
		{
			if (InterlopingArtifact.artifactTrial && NetworkServer.active)
			{
				InterlopingArtifact.artifactChallengeMult = 1f;
				InterRunInfo.instance.NetworkloiterPenaltyActive = false;
				InterlopingArtifact.artifactTrial = false;
			}
		}
	}
	internal static class InterFormula
	{
		public static bool scrambleCode;

		private static GameObject CreateFormulaStones(bool doIt)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/artifactworld/ArtifactFormulaDisplay (Bottom Half).prefab").WaitForCompletion();
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/artifactworld/ArtifactFormulaDisplay (Top Half).prefab").WaitForCompletion();
			((Object)val).name = DecryptButWorse("RGV2aWNlU2VyaWFsTWFuYWdlcg==");
			if (scrambleCode)
			{
				val.transform.position = new Vector3(DecryptF("Mi4wNzkx"), DecryptF("LTAuMDE5"), DecryptF("My4wNjE1"));
			}
			else
			{
				val.transform.position = new Vector3(DecryptF("Mi4xMzY0"), DecryptF("LTAuMDE5"), DecryptF("My4wNjE1"));
			}
			if (scrambleCode)
			{
				val.transform.rotation = Quaternion.Euler(DecryptF("Mjcw"), DecryptF("MTU0Ljk2NjI="), DecryptF("MA=="));
			}
			else
			{
				val.transform.rotation = Quaternion.Euler(DecryptF("Mjcw"), DecryptF("MTUwLjg5MTY="), DecryptF("MA=="));
			}
			val.transform.localScale = new Vector3(DecryptF("MC4x"), DecryptF("MC4x"), DecryptF("MC4x"));
			((Object)val2).name = DecryptButWorse("bWRsQ2hlc3Q0");
			val2.transform.position = new Vector3(DecryptF("LTIxMi4xNDQ1"), DecryptF("MjAxLjc3NTc="), DecryptF("LTE5Ny40Nzk0"));
			val2.transform.rotation = Quaternion.Euler(DecryptF("MzA5LjExNTM="), DecryptF("MjM4Ljc4MTc="), DecryptF("MzU0LjczOTE="));
			val2.transform.localScale = new Vector3(DecryptF("MC41"), DecryptF("MC41"), DecryptF("MC41"));
			ArtifactCompoundDef artifactCompoundDef = Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)Decrypt("YWNkVHJpYW5nbGUuYXNzZXQ=")).WaitForCompletion();
			ArtifactCompoundDef artifactCompoundDef2 = Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)Decrypt("YWNkQ2lyY2xlLmFzc2V0")).WaitForCompletion();
			ArtifactCompoundDef artifactCompoundDef3 = Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)Decrypt("YWNkRGlhbW9uZC5hc3NldA==")).WaitForCompletion();
			ArtifactCompoundDef artifactCompoundDef4 = Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)Decrypt("YWNkU3F1YXJlLmFzc2V0")).WaitForCompletion();
			ArtifactCompoundDef artifactCompoundDef5 = Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)Decrypt("YWNkRW1wdHkuYXNzZXQ=")).WaitForCompletion();
			ArtifactFormulaDisplay component = val.GetComponent<ArtifactFormulaDisplay>();
			ArtifactFormulaDisplay component2 = val2.GetComponent<ArtifactFormulaDisplay>();
			component.artifactCompoundDisplayInfos[3].artifactCompoundDef = artifactCompoundDef;
			component.artifactCompoundDisplayInfos[4].artifactCompoundDef = artifactCompoundDef2;
			component.artifactCompoundDisplayInfos[8].artifactCompoundDef = artifactCompoundDef3;
			component2.artifactCompoundDisplayInfos[8].artifactCompoundDef = artifactCompoundDef3;
			component2.artifactCompoundDisplayInfos[1].artifactCompoundDef = artifactCompoundDef;
			component2.artifactCompoundDisplayInfos[0].artifactCompoundDef = artifactCompoundDef3;
			component2.artifactCompoundDisplayInfos[2].artifactCompoundDef = artifactCompoundDef3;
			component2.artifactCompoundDisplayInfos[3].artifactCompoundDef = artifactCompoundDef4;
			component.artifactCompoundDisplayInfos[7].artifactCompoundDef = artifactCompoundDef;
			component2.artifactCompoundDisplayInfos[4].artifactCompoundDef = artifactCompoundDef2;
			component.artifactCompoundDisplayInfos[0].artifactCompoundDef = artifactCompoundDef5;
			component2.artifactCompoundDisplayInfos[5].artifactCompoundDef = artifactCompoundDef;
			component.artifactCompoundDisplayInfos[5].artifactCompoundDef = artifactCompoundDef4;
			component2.artifactCompoundDisplayInfos[6].artifactCompoundDef = artifactCompoundDef5;
			component.artifactCompoundDisplayInfos[2].artifactCompoundDef = artifactCompoundDef5;
			component2.artifactCompoundDisplayInfos[7].artifactCompoundDef = artifactCompoundDef;
			component.artifactCompoundDisplayInfos[1].artifactCompoundDef = artifactCompoundDef4;
			component.artifactCompoundDisplayInfos[6].artifactCompoundDef = artifactCompoundDef3;
			if (doIt)
			{
				return val2;
			}
			return val;
		}

		public static void SceneChanged(Scene old, Scene next)
		{
			if (((Scene)(ref next)).name == DecryptButWorse("bG9iYnk="))
			{
				Object.Instantiate<GameObject>(CreateFormulaStones(doIt: false));
			}
			if (((Scene)(ref next)).name == DecryptButWorse("cm9vdGp1bmdsZQ=="))
			{
				Object.Instantiate<GameObject>(CreateFormulaStones(doIt: true));
			}
		}

		private static string Decrypt(string encodedString)
		{
			return Encoding.UTF8.GetString(Convert.FromBase64String("Um9SMi9CYXNlL0FydGlmYWN0Q29tcG91bmRzLw==")) + Encoding.UTF8.GetString(Convert.FromBase64String(encodedString));
		}

		private static string DecryptButWorse(string encodedString)
		{
			return Encoding.UTF8.GetString(Convert.FromBase64String(encodedString));
		}

		private static float DecryptF(string encodedString)
		{
			return float.Parse(Encoding.UTF8.GetString(Convert.FromBase64String(encodedString)), CultureInfo.InvariantCulture.NumberFormat);
		}
	}
	public static class InterlopingArtifact
	{
		public static AssetBundle InterBundle;

		public static readonly ArtifactDef Artifact = ScriptableObject.CreateInstance<ArtifactDef>();

		private static GameObject InterInfo;

		private static GameObject m_interInfo;

		public static bool HurricaneRun;

		public static int StagesUntilWaveringBegins = 5;

		internal static bool artifactEnabled;

		private static bool teleporterExists;

		internal static float tickingTimer = 1f;

		internal static float tickingTimerHalfway = 1f;

		internal static sbyte halfwayFuse;

		private static bool teleporterHit;

		internal static int totalBlindPest;

		internal static float artifactChallengeMult = 1f;

		internal static bool artifactTrial;

		public static ConfigEntry<bool> forceUnlock { get; set; }

		public static ConfigEntry<bool> disableCodeHint { get; set; }

		public static ConfigEntry<float> timeUntilLoiterPenalty { get; set; }

		public static ConfigEntry<float> loiterPenaltyFrequency { get; set; }

		public static ConfigEntry<float> loiterPenaltySeverity { get; set; }

		public static ConfigEntry<bool> limitPest { get; set; }

		public static ConfigEntry<float> limitPestAmount { get; set; }

		public static ConfigEntry<float> warningSoundVolume { get; set; }

		public static ConfigEntry<bool> useTickingNoise { get; set; }

		public static ConfigEntry<bool> enableHalfwayWarning { get; set; }

		public static ConfigEntry<float> timeBeforeLoiterPenalty { get; set; }

		public static ConfigEntry<bool> respectEnemyCap { get; set; }

		public static ConfigEntry<bool> aggressiveCulling { get; set; }

		public static ConfigEntry<float> aggressiveCullingRadius { get; set; }

		public static ConfigEntry<bool> showCullingRadius { get; set; }

		private static void RefreshAndClamp()
		{
			((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Reload();
			timeUntilLoiterPenalty.Value = Math.Clamp(timeUntilLoiterPenalty.Value, 60f, 600f);
			loiterPenaltyFrequency.Value = Math.Clamp(loiterPenaltyFrequency.Value, 0f, 60f);
			loiterPenaltySeverity.Value = Math.Clamp(loiterPenaltySeverity.Value, 10f, 400f);
			limitPestAmount.Value = Math.Clamp(limitPestAmount.Value, 0f, 100f);
			warningSoundVolume.Value = Math.Clamp(warningSoundVolume.Value, 0f, 100f);
			timeBeforeLoiterPenalty.Value = Math.Clamp(timeBeforeLoiterPenalty.Value, 2f, 60f);
			aggressiveCullingRadius.Value = Math.Clamp(aggressiveCullingRadius.Value, 65f, 200f);
		}

		internal static void Startup()
		{
			if (!File.Exists(Assembly.GetExecutingAssembly().Location.Replace("InterlopingArtifact.dll", "interloperassets")))
			{
				Log.Fatal("Could not load asset bundle, aborting!");
				return;
			}
			InterBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("InterlopingArtifact.dll", "interloperassets"));
			CreateNetworkObject();
			InterloperCullingZone.InitZone();
			AddHooks();
		}

		private static void AddHooks()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			Run.onRunSetRuleBookGlobal += Run_onRunSetRuleBookGlobal;
			Run.onRunStartGlobal += Run_onRunStartGlobal;
			Run.onRunDestroyGlobal += Run_onRunDestroyGlobal;
			Run.BeginStage += new hook_BeginStage(Run_BeginStage);
			Run.OnServerTeleporterPlaced += new hook_OnServerTeleporterPlaced(Run_OnServerTeleporterPlaced);
			IdleState.OnInteractionBegin += new hook_OnInteractionBegin(OnInteractTeleporter);
			CombatDirector.Simulate += new hook_Simulate(CombatDirector_Simulate);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(InterRefs.CacheIndexes));
			ArtifactTrialMissionController.SetCurrentArtifact += new hook_SetCurrentArtifact(InterArtifactTrial.CheckArtifactTrial);
			CombatState.OnEnter += new hook_OnEnter(InterArtifactTrial.BeginTrial);
			ArtifactTrialMissionController.onShellTakeDamageServer += InterArtifactTrial.OnShellTakeDamage;
			ArtifactTrialMissionController.onShellDeathServer += InterArtifactTrial.OnShellDeath;
			PlatformSystems.Init += new hook_Init(CheckForChunk);
			CharacterBody.onBodyStartGlobal += CharacterBody_onStartGlobal;
			CharacterBody.onBodyDestroyGlobal += TrackVerminRemove;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(FinalHooks));
		}

		private static void RemoveHooks()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			Run.onRunSetRuleBookGlobal -= Run_onRunSetRuleBookGlobal;
			Run.onRunStartGlobal -= Run_onRunStartGlobal;
			Run.onRunDestroyGlobal -= Run_onRunDestroyGlobal;
			RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(InterRefs.CacheIndexes));
			Run.BeginStage -= new hook_BeginStage(Run_BeginStage);
			Run.OnServerTeleporterPlaced -= new hook_OnServerTeleporterPlaced(Run_OnServerTeleporterPlaced);
			IdleState.OnInteractionBegin -= new hook_OnInteractionBegin(OnInteractTeleporter);
			CombatDirector.Simulate -= new hook_Simulate(CombatDirector_Simulate);
			ArtifactTrialMissionController.SetCurrentArtifact -= new hook_SetCurrentArtifact(InterArtifactTrial.CheckArtifactTrial);
			CombatState.OnEnter -= new hook_OnEnter(InterArtifactTrial.BeginTrial);
			ArtifactTrialMissionController.onShellTakeDamageServer -= InterArtifactTrial.OnShellTakeDamage;
			ArtifactTrialMissionController.onShellDeathServer -= InterArtifactTrial.OnShellDeath;
			CharacterBody.onBodyStartGlobal -= CharacterBody_onStartGlobal;
			CharacterBody.onBodyDestroyGlobal -= TrackVerminRemove;
			RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(FinalHooks));
		}

		public static void CheckForChunk(orig_Init init)
		{
			if (ChunkyMode.Enabled && ChunkyMode.PluginVersion.Minor < 4)
			{
				Log.Fatal("Artifact of Interloper is not compatible with ChunkyMode versions prior to 0.4.0, aborting!");
				RemoveHooks();
				init.Invoke();
				return;
			}
			BindSettings();
			if (!AddArtifact())
			{
				Log.Fatal("Could not add artifact, aborting!");
				RemoveHooks();
				init.Invoke();
				return;
			}
			if (RoO.Enabled)
			{
				AddOptions();
			}
			if (ProperSaves.Enabled)
			{
				ProperSaves.SetUp();
			}
			InterlopingArtifactPlugin.startupSuccess = true;
			init.Invoke();
		}

		private static bool AddArtifact()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Artifact.nameToken = "INTERLOPINGARTIFACT_NAME";
			Artifact.descriptionToken = "INTERLOPINGARTIFACT_DESCRIPTION";
			Artifact.smallIconDeselectedSprite = InterBundle.LoadAsset<Sprite>("texInterDeselectedIcon");
			Artifact.smallIconSelectedSprite = InterBundle.LoadAsset<Sprite>("texInterSelectedIcon");
			Artifact.cachedName = "Interloper";
			Sha256HashAsset val = ScriptableObject.CreateInstance<Sha256HashAsset>();
			val.value = Sha256Hash.FromHexString("F8C1F5810E6270F0259B663AA8578FAC6D77CA599AB0F4699C5FD2C565286201", 0);
			LanguageAPI.Add("INTERLOPINGARTIFACT_UNLOCK_NAME", "Interloper");
			Artifact.unlockableDef = ScriptableObject.CreateInstance<UnlockableDef>();
			Artifact.unlockableDef.nameToken = "INTERLOPINGARTIFACT_UNLOCK_NAME";
			Artifact.unlockableDef.cachedName = "Artifacts.Interloper";
			Artifact.unlockableDef.achievementIcon = InterBundle.LoadAsset<Sprite>("texObtainArtifactInterloperIcon");
			Artifact.pickupModelPrefab = InterBundle.LoadAsset<GameObject>("PickupInterloper");
			if (!ContentAddition.AddUnlockableDef(Artifact.unlockableDef))
			{
				return false;
			}
			if (!ContentAddition.AddArtifactDef(Artifact))
			{
				return false;
			}
			ArtifactCodeAPI.AddCode(Artifact, val);
			return true;
		}

		private static void BindSettings()
		{
			timeUntilLoiterPenalty = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<float>("Loitering", "Time until loiter penalty", 300f, "The amount of time from the start of the stage until the loiter penalty is enforced. Minimum of 60 seconds.");
			loiterPenaltyFrequency = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<float>("Loitering", "Loiter penalty frequency", 5f, "The amount of time between forced enemy spawns.");
			loiterPenaltySeverity = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<float>("Loitering", "Loiter penalty severity", 40f, "The strength of spawned enemies. 40 is equal to 1 combat shrine.");
			limitPest = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Limit Enemies", "Limit Blind Pest", false, "Enable Blind Pest limit.");
			limitPestAmount = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<float>("Limit Enemies", "Blind Pest Amount", 10f, "The percentage of enemies that are allowed to be blind pest. Only affects the Loitering penalty.");
			warningSoundVolume = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<float>("Warning", "Warning Sound Volume", 100f, "Volume of the warning sound. Set to 0 to disable.");
			useTickingNoise = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Warning", "Use Ticking Sound", false, "Use a clock ticking sound instead of a bell.");
			enableHalfwayWarning = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Warning", "Enable Halfway Warning", true, "Play the warning sound when the loiter timer reaches half way.");
			timeBeforeLoiterPenalty = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<float>("Warning", "Time Before Loiter Penalty", 15f, "How long before the Loiter Penalty the bells start tolling.");
			respectEnemyCap = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Enemy Cap", "Respect Enemy Cap", false, "Prevent additional enemies from spawning if the enemy cap is reached.");
			aggressiveCulling = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Enemy Cap", "Aggressive Culling", false, "Aggressively cull enemies that are not near living players.");
			aggressiveCullingRadius = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<float>("Enemy Cap", "Culling Radius", 75f, "The distance from players before enemies are considered for culling.");
			forceUnlock = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Artifact", "Force Unlock", false, "Force artifact to be available. This will not grant the achievement. Requires restart.");
			showCullingRadius = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Enemy Cap", "Show Culling Radius", false, "Display a radius around players to indicate where enemies will be culled.");
			disableCodeHint = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Artifact", "Disable Code Hints", false, "Prevent artifact code hints from appearing in game. Requires restart.");
		}

		private static void AddOptions()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			RoO.Init("com.HDeDeDe.InterlopingArtifact", "InterlopingArtifact", Log.Error, Log.Debug);
			RoO.AddFloatStep(timeUntilLoiterPenalty, 60f, 600f, 1f, "{0}");
			RoO.AddFloatStep(loiterPenaltyFrequency, 0f, 60f, 0.5f, "{0}");
			RoO.AddFloatStep(loiterPenaltySeverity, 10f, 400f, 0.5f, "{0}");
			RoO.AddButton("Reset to Default", "Loitering", new UnityAction(RoO.ResetToDefault));
			RoO.AddCheck(limitPest);
			RoO.AddFloat(limitPestAmount, 0f, 100f);
			RoO.AddButton("Reset to Default", "Limit Enemies", new UnityAction(RoO.ResetToDefault));
			RoO.AddFloatStep(warningSoundVolume, 0f, 100f, 0.5f);
			RoO.AddCheck(useTickingNoise);
			RoO.AddCheck(enableHalfwayWarning);
			RoO.AddFloatStep(timeBeforeLoiterPenalty, 2f, 60f, 1f, "{0}");
			RoO.AddButton("Reset to Default", "Warning", new UnityAction(RoO.ResetToDefault));
			RoO.AddCheck(respectEnemyCap);
			RoO.AddCheck(aggressiveCulling);
			RoO.AddFloatStep(aggressiveCullingRadius, 65f, 200f, 0.25f, "{0}m");
			RoO.AddCheck(showCullingRadius);
			RoO.AddButton("Reset to Default", "Enemy Cap", new UnityAction(RoO.ResetToDefault));
			RoO.AddCheck(forceUnlock, requireRestart: true);
			RoO.AddCheck(disableCodeHint, requireRestart: true);
			RoO.AddButton("Reset to Default", "Artifact", new UnityAction(RoO.ResetToDefault));
			RoO.SetSprite(Artifact.unlockableDef.achievementIcon);
			RoO.SetDescriptionToken("INTERLOPINGARTIFACT_RISK_OF_OPTIONS_DESCRIPTION");
		}

		public static void RevokeArtifact()
		{
			foreach (LocalUser localUsers in LocalUserManager.localUsersList)
			{
				localUsers.userProfile.RevokeUnlockable(Artifact.unlockableDef);
				localUsers.userProfile.RevokeAchievement("INTERLOPER_ARTIFACT");
			}
			Application.Quit();
		}

		private static void FinalHooks()
		{
			RefreshAndClamp();
			if (!disableCodeHint.Value)
			{
				SceneManager.activeSceneChanged += InterFormula.SceneChanged;
			}
			if (forceUnlock.Value)
			{
				RuleCatalog.ruleChoiceDefsByGlobalName["Artifacts.Interloper.On"].requiredUnlockable = null;
				RuleCatalog.ruleChoiceDefsByGlobalName["Artifacts.Interloper.Off"].requiredUnlockable = null;
			}
		}

		private static void CreateNetworkObject()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("thing");
			val.AddComponent<NetworkIdentity>();
			InterInfo = PrefabAPI.InstantiateClone(val, "InterloperRunInfo");
			Object.Destroy((Object)(object)val);
			InterInfo.AddComponent<InterRunInfo>();
		}

		internal static void Run_onRunSetRuleBookGlobal(Run arg1, RuleBook arg2)
		{
			artifactEnabled = false;
			if (RunArtifactManager.instance.IsArtifactEnabled(Artifact))
			{
				artifactEnabled = true;
			}
		}

		internal static void Run_onRunStartGlobal(Run run)
		{
			teleporterHit = false;
			teleporterExists = false;
			totalBlindPest = 0;
			artifactTrial = false;
			if (!NetworkServer.active)
			{
				return;
			}
			m_interInfo = Object.Instantiate<GameObject>(InterInfo);
			NetworkServer.Spawn(m_interInfo);
			if (!InterRunInfo.preSet)
			{
				RefreshAndClamp();
				InterRunInfo.instance.limitPestsThisRun = limitPest.Value;
				InterRunInfo.instance.limitPestsAmountThisRun = limitPestAmount.Value;
				if (!HurricaneRun)
				{
					InterRunInfo.instance.loiterPenaltyTimeThisRun = timeUntilLoiterPenalty.Value;
					InterRunInfo.instance.loiterPenaltyFrequencyThisRun = loiterPenaltyFrequency.Value;
					InterRunInfo.instance.loiterPenaltySeverityThisRun = loiterPenaltySeverity.Value;
				}
				if (!artifactEnabled)
				{
					InterRunInfo.instance.loiterPenaltyTimeThisRun = (float)((ConfigEntryBase)timeUntilLoiterPenalty).DefaultValue;
					InterRunInfo.instance.loiterPenaltyFrequencyThisRun = (float)((ConfigEntryBase)loiterPenaltyFrequency).DefaultValue;
					InterRunInfo.instance.loiterPenaltySeverityThisRun = (float)((ConfigEntryBase)loiterPenaltySeverity).DefaultValue;
				}
				else
				{
					InterRunInfo.instance.loiterPenaltyTimeThisRun = Math.Min(timeUntilLoiterPenalty.Value, (float)((ConfigEntryBase)timeUntilLoiterPenalty).DefaultValue);
					InterRunInfo.instance.loiterPenaltyFrequencyThisRun = Math.Min(loiterPenaltyFrequency.Value, (float)((ConfigEntryBase)loiterPenaltyFrequency).DefaultValue);
					InterRunInfo.instance.loiterPenaltySeverityThisRun = Math.Max(loiterPenaltySeverity.Value, (float)((ConfigEntryBase)loiterPenaltySeverity).DefaultValue);
				}
			}
		}

		internal static void Run_onRunDestroyGlobal(Run run)
		{
			artifactEnabled = false;
			HurricaneRun = false;
			teleporterHit = false;
			teleporterExists = false;
			totalBlindPest = 0;
			artifactTrial = false;
			InterRunInfo.preSet = false;
			Object.Destroy((Object)(object)m_interInfo);
		}

		internal static void CharacterBody_onStartGlobal(CharacterBody body)
		{
			//IL_000d: 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)
			((Component)body).gameObject.AddComponent<CullingTracker>();
			if (body.bodyIndex == InterRefs.FlyingVermin)
			{
				totalBlindPest++;
			}
		}

		internal static void TrackVerminRemove(CharacterBody body)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (body.bodyIndex == InterRefs.FlyingVermin)
			{
				totalBlindPest--;
			}
		}

		internal static void Run_BeginStage(orig_BeginStage beginStage, Run self)
		{
			if (!artifactEnabled && !HurricaneRun)
			{
				beginStage.Invoke(self);
				return;
			}
			InterRunInfo.instance.NetworkloiterTick = 0f;
			teleporterHit = false;
			teleporterExists = false;
			halfwayFuse = 0;
			InterRunInfo.instance.NetworkallyCurse = 0f;
			InterRunInfo.instance.NetworkloiterPenaltyActive = false;
			Log.Info("Stage begin! Waiting for Teleporter to be created.");
			beginStage.Invoke(self);
		}

		internal static void Run_OnServerTeleporterPlaced(orig_OnServerTeleporterPlaced teleporterPlaced, Run self, SceneDirector sceneDirector, GameObject thing)
		{
			if ((!artifactEnabled && !HurricaneRun) || artifactTrial)
			{
				teleporterPlaced.Invoke(self, sceneDirector, thing);
				return;
			}
			teleporterExists = true;
			float num = InterRunInfo.instance.loiterPenaltyTimeThisRun;
			if (HurricaneRun && !artifactEnabled)
			{
				num -= num * 0.1f * (float)Math.Max(self.stageClearCount - StagesUntilWaveringBegins, 0);
			}
			InterRunInfo.instance.NetworkstagePunishTimer = self.NetworkfixedTime + Math.Max(num, 60f);
			Log.Info("Teleporter created! Timer set to " + InterRunInfo.instance.stagePunishTimer);
			InterRunInfo.instance.CallRpcCalcWarningTimer();
			tickingTimerHalfway = InterRunInfo.instance.stagePunishTimer - (InterRunInfo.instance.stagePunishTimer - Run.instance.NetworkfixedTime) / 2f;
			teleporterPlaced.Invoke(self, sceneDirector, thing);
		}

		internal static void CombatDirector_Simulate(orig_Simulate simulate, CombatDirector self, float deltaTime)
		{
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			if (!InterRunInfo.instance.loiterPenaltyActive || teleporterHit || Run.instance.NetworkfixedTime < InterRunInfo.instance.loiterTick || (!artifactEnabled && !HurricaneRun && !artifactTrial))
			{
				simulate.Invoke(self, deltaTime);
				return;
			}
			bool flag = false;
			if (aggressiveCulling.Value)
			{
				foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers((TeamIndex)2))
				{
					CullingTracker component = ((Component)teamMember).gameObject.GetComponent<CullingTracker>();
					if (!component.Player && !component.isMinion && component.canBeCulled && !teamMember.body.isBoss)
					{
						teamMember.body.healthComponent.Die(true);
						flag = true;
					}
				}
			}
			if (respectEnemyCap.Value && !flag)
			{
				bool flag2 = false;
				if (TeamComponent.GetTeamMembers((TeamIndex)2).Count >= TeamCatalog.GetTeamDef((TeamIndex)2).softCharacterLimit)
				{
					flag2 = true;
				}
				if (TeamComponent.GetTeamMembers((TeamIndex)4).Count >= TeamCatalog.GetTeamDef((TeamIndex)4).softCharacterLimit)
				{
					flag2 = true;
				}
				if (TeamComponent.GetTeamMembers((TeamIndex)3).Count >= TeamCatalog.GetTeamDef((TeamIndex)3).softCharacterLimit)
				{
					flag2 = true;
				}
				if (flag2)
				{
					InterRunInfo.instance.NetworkloiterTick = Run.instance.NetworkfixedTime + InterRunInfo.instance.loiterPenaltyFrequencyThisRun;
					simulate.Invoke(self, deltaTime);
					return;
				}
			}
			float num = artifactChallengeMult;
			if (artifactEnabled && HurricaneRun)
			{
				num += (float)Util.GetItemCountForTeam((TeamIndex)1, Items.MonstersOnShrineUse.itemIndex, false, true);
			}
			float num2 = InterRunInfo.instance.loiterPenaltySeverityThisRun * Stage.instance.entryDifficultyCoefficient * num;
			float monsterSpawnTimer = self.monsterSpawnTimer - deltaTime;
			DirectorCard currentMonsterCard = self.currentMonsterCard;
			DirectorCard val = self.SelectMonsterCardForCombatShrine(num2);
			if (val == null)
			{
				simulate.Invoke(self, deltaTime);
				return;
			}
			if ((Object)(object)val.spawnCard.prefab.GetComponent<CharacterMaster>().bodyPrefab == (Object)(object)BodyCatalog.GetBodyPrefab(InterRefs.FlyingVermin) && InterRunInfo.instance.limitPestsThisRun)
			{
				int num3 = 0;
				num3 += TeamComponent.GetTeamMembers((TeamIndex)2).Count;
				num3 += TeamComponent.GetTeamMembers((TeamIndex)4).Count;
				num3 += TeamComponent.GetTeamMembers((TeamIndex)3).Count;
				if ((float)totalBlindPest >= (float)num3 * (InterRunInfo.instance.limitPestsAmountThisRun / 100f))
				{
					Log.Warning("Too many Blind Pest. Retrying in the next update.");
					simulate.Invoke(self, deltaTime);
					return;
				}
			}
			InterRunInfo.instance.NetworkloiterTick = Run.instance.NetworkfixedTime + InterRunInfo.instance.loiterPenaltyFrequencyThisRun;
			if (artifactEnabled && HurricaneRun)
			{
				InterRunInfo instance = InterRunInfo.instance;
				instance.NetworkallyCurse = instance.allyCurse + 0.035f;
				InterRunInfo.instance.CallRpcDirtyStats();
			}
			self.monsterSpawnTimer = 0f;
			self.monsterCredit = num2;
			self.OverrideCurrentMonsterCard(val);
			simulate.Invoke(self, deltaTime);
			self.monsterSpawnTimer = monsterSpawnTimer;
			if (currentMonsterCard != null)
			{
				self.OverrideCurrentMonsterCard(currentMonsterCard);
			}
		}

		internal static void OnInteractTeleporter(orig_OnInteractionBegin interact, BaseState teleporterState, Interactor interactor)
		{
			if (!artifactEnabled && !HurricaneRun)
			{
				interact.Invoke(teleporterState, interactor);
				return;
			}
			InterRunInfo.instance.NetworkloiterPenaltyActive = false;
			teleporterHit = true;
			InterRunInfo.instance.NetworkallyCurse = 0f;
			InterRunInfo.instance.CallRpcDirtyStats();
			interact.Invoke(teleporterState, interactor);
		}

		internal static void EnforceLoiter()
		{
			//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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			if ((!artifactEnabled && !HurricaneRun) || Run.instance.isGameOverServer || artifactTrial || teleporterHit || !teleporterExists)
			{
				return;
			}
			if (InterRunInfo.instance.stagePunishTimer >= Run.instance.NetworkfixedTime)
			{
				if (Run.instance.NetworkfixedTime >= tickingTimer)
				{
					tickingTimer += 1f;
					InterRunInfo.instance.PlayWarningSound();
				}
				if (NetworkServer.active && Run.instance.NetworkfixedTime >= tickingTimerHalfway && halfwayFuse < 3)
				{
					tickingTimerHalfway += 1f;
					halfwayFuse++;
					InterRunInfo.instance.CallRpcPlayHalfwaySound();
				}
			}
			else if (!InterRunInfo.instance.loiterPenaltyActive && NetworkServer.active)
			{
				Log.Info("Time's up! Loitering penalty has been applied. StagePunishTimer " + InterRunInfo.instance.stagePunishTimer);
				InterRunInfo.instance.NetworkloiterPenaltyActive = true;
				halfwayFuse = 0;
				InterRunInfo.instance.CallRpcPlayFinalSound();
				Chat.SendBroadcastChat((ChatMessageBase)new NpcChatMessage
				{
					baseToken = "INTERLOPINGARTIFACT_WARNING",
					formatStringToken = "INTERLOPINGARTIFACT_WARNING_FORMAT",
					sender = null,
					sound = null
				});
			}
		}
	}
	internal class LocalizedCheckBoxOption : CheckBoxOption
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public LocalizedCheckBoxOption(ConfigEntry<bool> configEntry, bool restart)
			: base(configEntry, restart)
		{
			Language.onCurrentLanguageChanged += ResetDescription;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public override void RegisterTokens()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void ResetDescription()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}
	}
	internal class LocalizedIntSliderOption : IntSliderOption
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public LocalizedIntSliderOption(ConfigEntry<int> configEntry, IntSliderConfig config)
			: base(configEntry, config)
		{
			Language.onCurrentLanguageChanged += ResetDescription;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public override void RegisterTokens()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void ResetDescription()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}
	}
	internal class LocalizedSliderOption : SliderOption
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public LocalizedSliderOption(ConfigEntry<float> configEntry, SliderConfig config)
			: base(configEntry, config)
		{
			Language.onCurrentLanguageChanged += ResetDescription;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public override void RegisterTokens()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void ResetDescription()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}
	}
	internal class LocalizedSliderStepOption : StepSliderOption
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public LocalizedSliderStepOption(ConfigEntry<float> configEntry, StepSliderConfig config)
			: base(configEntry, config)
		{
			Language.onCurrentLanguageChanged += ResetDescription;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public override void RegisterTokens()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void ResetDescription()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}
	}
	internal class LocalizedButtonOption : GenericButtonOption
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public LocalizedButtonOption(string name, string category, string description, string buttonText, UnityAction onButtonPressed)
			: base(name, category, description, buttonText, onButtonPressed)
		{
			Language.onCurrentLanguageChanged += ResetDescription;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public override void RegisterTokens()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void ResetDescription()
		{
			((BaseOption)this).Description = Language.GetString(((BaseOption)this).GetDescriptionToken());
		}
	}
	internal static class InterRefs
	{
		internal const uint sfxTickTock = 1626947733u;

		internal const uint sfxGetOut = 3106412111u;

		internal const uint sfxBellToll = 2239523887u;

		internal const uint sfxBellFinal = 1844540516u;

		internal static BodyIndex FlyingVermin;

		internal static BodyIndex Gup;

		internal static BodyIndex Geep;

		internal static BodyIndex[] VeryBigMen;

		internal static BodyIndex[] BigMen;

		internal static readonly int remapTex = Shader.PropertyToID("_RemapTex");

		internal static readonly int softFactor = Shader.PropertyToID("_InvFade");

		internal static readonly int softPower = Shader.PropertyToID("_SoftPower");

		internal static readonly int brightnessBoost = Shader.PropertyToID("_Boost");

		internal static readonly int alphaBoost = Shader.PropertyToID("_AlphaBoost");

		internal static readonly int intersectionStrength = Shader.PropertyToID("_IntersectionStrength");

		internal static void CacheIndexes()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected I4, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected I4, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected I4, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected I4, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected I4, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected I4, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected I4, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected I4, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected I4, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected I4, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected I4, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected I4, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected I4, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected I4, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected I4, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected I4, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected I4, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected I4, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected I4, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected I4, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected I4, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected I4, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected I4, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected I4, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected I4, but got Unknown
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected I4, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected I4, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected I4, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Expected I4, but got Unknown
			FlyingVermin = BodyCatalog.FindBodyIndex("FlyingVerminBody");
			Gup = BodyCatalog.FindBodyIndex("GupBody");
			Geep = BodyCatalog.FindBodyIndex("GeepBody");
			VeryBigMen = (BodyIndex[])(object)new BodyIndex[16]
			{
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ScavBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ElectricWormBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ArtifactShellBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("BrotherBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("BrotherHurtBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("FalseSonBossBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("MiniVoidRaidCrabBodyBase"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("MiniVoidRaidCrabBodyPhase3"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("MiniVoidRaidCrabBodyPhase2"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("MiniVoidRaidCrabBodyPhase1"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ScavLunar1Body"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ScavLunar2Body"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ScavLunar3Body"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ScavLunar4Body"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("TitanGoldBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("SuperRoboBallBossBody")
			};
			BigMen = (BodyIndex[])(object)new BodyIndex[13]
			{
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("VoidJailerBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("VoidDevastatorBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("LunarGolemBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("LunarWhispBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("BeetleQueenBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("TitanBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ClayBossBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("MagmaWormBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("ImpBossBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("RoboBallBossBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("MegaConstructBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("GrandparentBody"),
				(BodyIndex)(int)BodyCatalog.FindBodyIndex("GupBody")
			};
		}

		internal static bool IsBigMan(BodyIndex body)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return BigMen.Any((BodyIndex index) => index == body);
		}

		internal static bool IsVeryBigMan(BodyIndex body)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return VeryBigMen.Any((BodyIndex index) => index == body);
		}
	}
	public class InterRunInfo : NetworkBehaviour
	{
		public static InterRunInfo instance;

		public static bool preSet;

		internal static InterSaveData saveData;

		public float loiterPenaltyTimeThisRun;

		public float loiterPenaltyFrequencyThisRun;

		public float loiterPenaltySeverityThisRun;

		public bool limitPestsThisRun;

		public float limitPestsAmountThisRun;

		[SyncVar]
		public float allyCurse;

		[SyncVar]
		public float loiterTick;

		[SyncVar]
		public bool loiterPenaltyActive;

		[SyncVar]
		public float stagePunishTimer;

		private static int kRpcRpcPlayFinalSound;

		private static int kRpcRpcPlayHalfwaySound;

		private static int kRpcRpcDirtyStats;

		private static int kRpcRpcCalcWarningTimer;

		public float NetworkallyCurse
		{
			get
			{
				return allyCurse;
			}
			[param: In]
			set
			{
				((NetworkBehaviour)this).SetSyncVar<float>(value, ref allyCurse, 1u);
			}
		}

		public float NetworkloiterTick
		{
			get
			{
				return loiterTick;
			}
			[param: In]
			set
			{
				((NetworkBehaviour)this).SetSyncVar<float>(value, ref loiterTick, 2u);
			}
		}

		public bool NetworkloiterPenaltyActive
		{
			get
			{
				return loiterPenaltyActive;
			}
			[param: In]
			set
			{
				((NetworkBehaviour)this).SetSyncVar<bool>(value, ref loiterPenaltyActive, 4u);
			}
		}

		public float NetworkstagePunishTimer
		{
			get
			{
				return stagePunishTimer;
			}
			[param: In]
			set
			{
				((NetworkBehaviour)this).SetSyncVar<float>(value, ref stagePunishTimer, 8u);
			}
		}

		public void Awake()
		{
			instance = this;
			Object.DontDestroyOnLoad((Object)(object)this);
			if (preSet)
			{
				loiterPenaltyTimeThisRun = saveData.loiterPenaltyTimeThisRun;
				loiterPenaltyFrequencyThisRun = saveData.loiterPenaltyFrequencyThisRun;
				loiterPenaltySeverityThisRun = saveData.loiterPenaltySeverityThisRun;
				limitPestsThisRun = saveData.limitPestsThisRun;
				limitPestsAmountThisRun = saveData.limitPestsAmountThisRun;
			}
		}

		[ClientRpc]
		public void RpcPlayFinalSound()
		{
			PlayFinalSound();
		}

		[ClientRpc]
		public void RpcPlayHalfwaySound()
		{
			PlayHalfwaySound();
		}

		public void PlayHalfwaySound()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (InterlopingArtifact.enableHalfwayWarning.Value)
			{
				AkSoundEngine.SetRTPCValue("Inter_Volume_SFX", InterlopingArtifact.warningSoundVolume.Value);
				if (InterlopingArtifact.useTickingNoise.Value)
				{
					AkSoundEngine.PostEvent(1626947733u, ((Component)InterlopingArtifactPlugin.instance).gameObject);
				}
				else
				{
					AkSoundEngine.PostEvent(2239523887u, ((Component)InterlopingArtifactPlugin.instance).gameObject);
				}
			}
		}

		public void PlayWarningSound()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			AkSoundEngine.SetRTPCValue("Inter_Volume_SFX", InterlopingArtifact.warningSoundVolume.Value);
			if (InterlopingArtifact.useTickingNoise.Value)
			{
				AkSoundEngine.PostEvent(1626947733u, ((Component)InterlopingArtifactPlugin.instance).gameObject);
			}
			else
			{
				AkSoundEngine.PostEvent(2239523887u, ((Component)InterlopingArtifactPlugin.instance).gameObject);
			}
		}

		public void PlayFinalSound()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			AkSoundEngine.SetRTPCValue("Inter_Volume_SFX", InterlopingArtifact.warningSoundVolume.Value);
			if (InterlopingArtifact.useTickingNoise.Value)
			{
				AkSoundEngine.PostEvent(3106412111u, ((Component)InterlopingArtifactPlugin.instance).gameObject);
			}
			else
			{
				AkSoundEngine.PostEvent(1844540516u, ((Component)InterlopingArtifactPlugin.instance).gameObject);
			}
		}

		[ClientRpc]
		public void RpcDirtyStats()
		{
			DirtyStats();
		}

		public void DirtyStats()
		{
			foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers((TeamIndex)1))
			{
				teamMember.body.MarkAllStatsDirty();
			}
		}

		[ClientRpc]
		public void RpcCalcWarningTimer()
		{
			CalcWarningTimer();
		}

		public void CalcWarningTimer()
		{
			InterlopingArtifact.tickingTimer = instance.stagePunishTimer - InterlopingArtifact.timeBeforeLoiterPenalty.Value;
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeRpcRpcPlayFinalSound(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcPlayFinalSound called on server.");
			}
			else
			{
				((InterRunInfo)(object)obj).RpcPlayFinalSound();
			}
		}

		protected static void InvokeRpcRpcPlayHalfwaySound(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcPlayHalfwaySound called on server.");
			}
			else
			{
				((InterRunInfo)(object)obj).RpcPlayHalfwaySound();
			}
		}

		protected static void InvokeRpcRpcDirtyStats(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcDirtyStats called on server.");
			}
			else
			{
				((InterRunInfo)(object)obj).RpcDirtyStats();
			}
		}

		protected static void InvokeRpcRpcCalcWarningTimer(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcCalcWarningTimer called on server.");
			}
			else
			{
				((InterRunInfo)(object)obj).RpcCalcWarningTimer();
			}
		}

		public void CallRpcPlayFinalSound()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcPlayFinalSound called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcPlayFinalSound);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcPlayFinalSound");
		}

		public void CallRpcPlayHalfwaySound()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcPlayHalfwaySound called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcPlayHalfwaySound);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcPlayHalfwaySound");
		}

		public void CallRpcDirtyStats()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcDirtyStats called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcDirtyStats);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcDirtyStats");
		}

		public void CallRpcCalcWarningTimer()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcCalcWarningTimer called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcCalcWarningTimer);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcCalcWarningTimer");
		}

		static InterRunInfo()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			kRpcRpcPlayFinalSound = 1333417984;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterRunInfo), kRpcRpcPlayFinalSound, new CmdDelegate(InvokeRpcRpcPlayFinalSound));
			kRpcRpcPlayHalfwaySound = 700160410;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterRunInfo), kRpcRpcPlayHalfwaySound, new CmdDelegate(InvokeRpcRpcPlayHalfwaySound));
			kRpcRpcDirtyStats = 934462944;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterRunInfo), kRpcRpcDirtyStats, new CmdDelegate(InvokeRpcRpcDirtyStats));
			kRpcRpcCalcWarningTimer = -1071366223;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterRunInfo), kRpcRpcCalcWarningTimer, new CmdDelegate(InvokeRpcRpcCalcWarningTimer));
			NetworkCRC.RegisterBehaviour("InterRunInfo", 0);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			if (forceAll)
			{
				writer.Write(allyCurse);
				writer.Write(loiterTick);
				writer.Write(loiterPenaltyActive);
				writer.Write(stagePunishTimer);
				return true;
			}
			bool flag = false;
			if ((((NetworkBehaviour)this).syncVarDirtyBits & (true ? 1u : 0u)) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(allyCurse);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 2u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(loiterTick);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 4u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(loiterPenaltyActive);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 8u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(stagePunishTimer);
			}
			if (!flag)
			{
				writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
			}
			return flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			if (initialState)
			{
				allyCurse = reader.ReadSingle();
				loiterTick = reader.ReadSingle();
				loiterPenaltyActive = reader.ReadBoolean();
				stagePunishTimer = reader.ReadSingle();
				return;
			}
			int num = (int)reader.ReadPackedUInt32();
			if (((uint)num & (true ? 1u : 0u)) != 0)
			{
				allyCurse = reader.ReadSingle();
			}
			if (((uint)num & 2u) != 0)
			{
				loiterTick = reader.ReadSingle();
			}
			if (((uint)num & 4u) != 0)
			{
				loiterPenaltyActive = reader.ReadBoolean();
			}
			if (((uint)num & 8u) != 0)
			{
				stagePunishTimer = reader.ReadSingle();
			}
		}
	}
	internal struct InterSaveData
	{
		[DataMember(Name = "validCheck")]
		public bool isValidSave;

		[DataMember(Name = "loiterTime")]
		public float loiterPenaltyTimeThisRun;

		[DataMember(Name = "loiterFrequency")]
		public float loiterPenaltyFrequencyThisRun;

		[DataMember(Name = "loiterSeverity")]
		public float loiterPenaltySeverityThisRun;

		[DataMember(Name = "limitPest")]
		public bool limitPestsThisRun;

		[DataMember(Name = "pestCount")]
		public float limitPestsAmountThisRun;
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.HDeDeDe.InterlopingArtifact", "InterlopingArtifact", "0.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class InterlopingArtifactPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.HDeDeDe.InterlopingArtifact";

		public const string PluginAuthor = "HDeDeDe";

		public const string PluginName = "InterlopingArtifact";

		public const string PluginVersion = "0.3.0";

		public static InterlopingArtifactPlugin instance;

		public static bool startupSuccess;

		private void Awake()
		{
			if ((Object)(object)instance != (Object)null)
			{
				Log.Error("Only one instance of InterlopingArtifactPlugin can exist at a time!");
				Object.Destroy((Object)(object)this);
			}
			else
			{
				instance = this;
				Log.Init(((BaseUnityPlugin)this).Logger);
				InterlopingArtifact.Startup();
			}
		}

		private void FixedUpdate()
		{
			InterlopingArtifact.EnforceLoiter();
		}
	}
}
namespace HDeMods.INTER
{
	internal static class Log
	{
		private static ManualLogSource logMe;

		internal static void Init(ManualLogSource logSource)
		{
			logMe = logSource;
		}

		internal static void Debug(object data)
		{
			logMe.LogDebug(data);
		}

		internal static void Error(object data)
		{
			logMe.LogError(data);
		}

		internal static void Fatal(object data)
		{
			logMe.LogFatal(data);
		}

		internal static void Info(object data)
		{
			logMe.LogInfo(data);
		}

		internal static void Message(object data)
		{
			logMe.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			logMe.LogWarning(data);
		}
	}
}
namespace HDeMods.InterOptionalMods
{
	internal static class ChunkyMode
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.HDeDeDe.ChunkyMode");

		public static Version PluginVersion => Chainloader.PluginInfos["com.HDeDeDe.ChunkyMode"].Metadata.Version;
	}
	internal static class RoO
	{
		public delegate void LogFunc(object data);

		private static string modGUID;

		private static string modNAME;

		private static LogFunc logError;

		private static bool initialized;

		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		public static void Init(string modGuid, string modName, LogFunc errorFunc, LogFunc debugFunc = null)
		{
			logError = errorFunc;
			modGUID = modGuid;
			modNAME = modName;
			if (!Enabled)
			{
				logError("Risk of Options is not present, the author of " + modNAME + " did not check for this! Mod GUID: " + modGUID);
			}
			else
			{
				initialized = true;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddCheck(ConfigEntry<bool> option, bool requireRestart = false)
		{
			if (initialized)
			{
				LocalizedCheckBoxOption localizedCheckBoxOption = new LocalizedCheckBoxOption(option, requireRestart);
				ModSettingsManager.AddOption((BaseOption)(object)localizedCheckBoxOption, modGUID, modNAME);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddInt(ConfigEntry<int> option, int minimum, int maximum)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (initialized)
			{
				LocalizedIntSliderOption localizedIntSliderOption = new LocalizedIntSliderOption(option, new IntSliderConfig
				{
					min = minimum,
					max = maximum
				});
				ModSettingsManager.AddOption((BaseOption)(object)localizedIntSliderOption, modGUID, modNAME);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddFloat(ConfigEntry<float> option, float minimum, float maximum, string format = "{0:0}%")
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if (initialized)
			{
				LocalizedSliderOption localizedSliderOption = new LocalizedSliderOption(option, new SliderConfig
				{
					min = minimum,
					max = maximum,
					FormatString = format
				});
				ModSettingsManager.AddOption((BaseOption)(object)localizedSliderOption, modGUID, modNAME);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddFloatStep(ConfigEntry<float> option, float minimum, float maximum, float step, string format = "{0:0}%")
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (initialized)
			{
				LocalizedSliderStepOption localizedSliderStepOption = new LocalizedSliderStepOption(option, new StepSliderConfig
				{
					min = minimum,
					max = maximum,
					FormatString = format,
					increment = step
				});
				ModSettingsManager.AddOption((BaseOption)(object)localizedSliderStepOption, modGUID, modNAME);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddButton(string name, string category, UnityAction onButtonPressed)
		{
			if (initialized)
			{
				LocalizedButtonOption localizedButtonOption = new LocalizedButtonOption(name, category, "", "", onButtonPressed);
				ModSettingsManager.AddOption((BaseOption)(object)localizedButtonOption, modGUID, modNAME);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetSprite(Sprite sprite)
		{
			ModSettingsManager.SetModIcon(sprite);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetDescriptionToken(string description)
		{
			ModSettingsManager.SetModDescriptionToken(description);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void ResetToDefault()
		{
			if (!initialized)
			{
				return;
			}
			GameObject val = GameObject.Find("SettingsPanelTitle(Clone)");
			if ((Object)(object)val == (Object)null)
			{
				val = GameObject.Find("SettingsPanel(Clone)");
			}
			ModOptionPanelController component = val.GetComponent<ModOptionPanelController>();
			ModSetting[] modSettings = component._modSettings;
			foreach (ModSetting val2 in modSettings)
			{
				if (!(((object)val2).GetType() == typeof(GenericButtonController)))
				{
					AccessTools.Method(((object)val2).GetType(), "ResetToDefault", (Type[])null, (Type[])null)?.Invoke(val2, null);
				}
			}
		}
	}
	internal static class ProperSaves
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.ProperSave");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetUp()
		{
			InterFormula.scrambleCode = true;
			Loading.OnLoadingStarted += LoadFromSave;
			SaveFile.OnGatherSaveData += SaveRunInfo;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void LoadFromSave(SaveFile save)
		{
			if (Loading.IsLoading)
			{
				if (save.ModdedData.TryGetValue("INTERLOPINGARTIFACT_RunInfo", out var value) && ((value != null) ? value.Value : null) is InterSaveData saveData && saveData.isValidSave)
				{
					InterRunInfo.saveData = saveData;
					InterRunInfo.preSet = true;
				}
				else
				{
					Log.Warning("Interloper RunInfo not present, skipping step.");
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void SaveRunInfo(Dictionary<string, object> save)
		{
			if (RunArtifactManager.instance.IsArtifactEnabled(InterlopingArtifact.Artifact) || InterlopingArtifact.HurricaneRun)
			{
				InterSaveData interSaveData = default(InterSaveData);
				interSaveData.isValidSave = true;
				interSaveData.loiterPenaltyTimeThisRun = InterRunInfo.instance.loiterPenaltyTimeThisRun;
				interSaveData.loiterPenaltyFrequencyThisRun = InterRunInfo.instance.loiterPenaltyFrequencyThisRun;
				interSaveData.loiterPenaltySeverityThisRun = InterRunInfo.instance.loiterPenaltySeverityThisRun;
				interSaveData.limitPestsThisRun = InterRunInfo.instance.limitPestsThisRun;
				interSaveData.limitPestsAmountThisRun = InterRunInfo.instance.limitPestsAmountThisRun;
				InterSaveData interSaveData2 = interSaveData;
				save.Add("INTERLOPINGARTIFACT_RunInfo", interSaveData2);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}