Decompiled source of InterlopingArtifact v0.1.3

InterlopingArtifact.dll

Decompiled 32 minutes ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
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: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyCompany("InterlopingArtifact")]
[assembly: AssemblyProduct("InterlopingArtifact")]
[assembly: AssemblyTitle("InterlopingArtifact")]
[assembly: AssemblyInformationalVersion("1.0.0+7544e97e75c8e726c04c840e2a27bd11bee1813c")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HDeMods
{
	[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;

		private 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; }

		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();
			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.CacheBlindPest));
			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 += TrackVerminAdd;
			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.CacheBlindPest));
			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 -= TrackVerminAdd;
			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.");
			forceUnlock = ((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Bind<bool>("Artifact", "Force Unlock", false, "Force artifact to be available. This will not grant the achievement. Requires restart.");
			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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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(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()
		{
			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)
			{
				((BaseUnityPlugin)InterlopingArtifactPlugin.instance).Config.Reload();
				InterRunInfo.instance.NetworklimitPestsThisRun = limitPest.Value;
				InterRunInfo.instance.NetworklimitPestsAmountThisRun = limitPestAmount.Value;
				if (!HurricaneRun)
				{
					InterRunInfo.instance.NetworkloiterPenaltyTimeThisRun = timeUntilLoiterPenalty.Value;
					InterRunInfo.instance.NetworkloiterPenaltyFrequencyThisRun = loiterPenaltyFrequency.Value;
					InterRunInfo.instance.NetworkloiterPenaltySeverityThisRun = loiterPenaltySeverity.Value;
				}
				if (!artifactEnabled)
				{
					InterRunInfo.instance.NetworkloiterPenaltyTimeThisRun = (float)((ConfigEntryBase)timeUntilLoiterPenalty).DefaultValue;
					InterRunInfo.instance.NetworkloiterPenaltyFrequencyThisRun = (float)((ConfigEntryBase)loiterPenaltyFrequency).DefaultValue;
					InterRunInfo.instance.NetworkloiterPenaltySeverityThisRun = (float)((ConfigEntryBase)loiterPenaltySeverity).DefaultValue;
				}
				else
				{
					InterRunInfo.instance.NetworkloiterPenaltyTimeThisRun = Math.Min(timeUntilLoiterPenalty.Value, (float)((ConfigEntryBase)timeUntilLoiterPenalty).DefaultValue);
					InterRunInfo.instance.NetworkloiterPenaltyFrequencyThisRun = Math.Min(loiterPenaltyFrequency.Value, (float)((ConfigEntryBase)loiterPenaltyFrequency).DefaultValue);
					InterRunInfo.instance.NetworkloiterPenaltySeverityThisRun = 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 TrackVerminAdd(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 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;
			InterRunInfo.instance.NetworkstagePunishTimer = self.NetworkfixedTime + InterRunInfo.instance.loiterPenaltyTimeThisRun;
			Log.Info("Teleporter created! Timer set to " + InterRunInfo.instance.stagePunishTimer);
			tickingTimer = InterRunInfo.instance.stagePunishTimer - 15f;
			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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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;
			}
			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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0132: Expected O, but got Unknown
			if ((!artifactEnabled && !HurricaneRun) || Run.instance.isGameOverServer || !NetworkServer.active || artifactTrial || teleporterHit || !teleporterExists || InterRunInfo.instance.loiterPenaltyActive)
			{
				return;
			}
			if (InterRunInfo.instance.stagePunishTimer >= Run.instance.NetworkfixedTime)
			{
				if (Run.instance.NetworkfixedTime >= tickingTimer)
				{
					tickingTimer += 1f;
					InterRunInfo.instance.CallRpcPlayWarningSound();
				}
				if (Run.instance.NetworkfixedTime >= tickingTimerHalfway && halfwayFuse < 3)
				{
					tickingTimerHalfway += 1f;
					halfwayFuse++;
					InterRunInfo.instance.CallRpcPlayHalfwaySound();
				}
			}
			else
			{
				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 void CacheBlindPest()
		{
			//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)
			FlyingVermin = BodyCatalog.FindBodyIndex("FlyingVerminBody");
		}
	}
	public class InterRunInfo : NetworkBehaviour
	{
		public static InterRunInfo instance;

		public static bool preSet;

		internal static InterSaveData saveData;

		[SyncVar]
		public float loiterPenaltyTimeThisRun;

		[SyncVar]
		public float loiterPenaltyFrequencyThisRun;

		[SyncVar]
		public float loiterPenaltySeverityThisRun;

		[SyncVar]
		public bool limitPestsThisRun;

		[SyncVar]
		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 kRpcRpcPlayWarningSound;

		private static int kRpcRpcPlayHalfwaySound;

		private static int kRpcRpcDirtyStats;

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

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

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

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

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

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

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

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

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

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

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

		[ClientRpc]
		public void RpcPlayWarningSound()
		{
			PlayWarningSound();
		}

		[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();
			}
		}

		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 InvokeRpcRpcPlayWarningSound(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcPlayWarningSound called on server.");
			}
			else
			{
				((InterRunInfo)(object)obj).RpcPlayWarningSound();
			}
		}

		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();
			}
		}

		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 CallRpcPlayWarningSound()
		{
			//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 RpcPlayWarningSound called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcPlayWarningSound);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcPlayWarningSound");
		}

		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");
		}

		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));
			kRpcRpcPlayWarningSound = -609633318;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterRunInfo), kRpcRpcPlayWarningSound, new CmdDelegate(InvokeRpcRpcPlayWarningSound));
			kRpcRpcPlayHalfwaySound = 700160410;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterRunInfo), kRpcRpcPlayHalfwaySound, new CmdDelegate(InvokeRpcRpcPlayHalfwaySound));
			kRpcRpcDirtyStats = 934462944;
			NetworkBehaviour.RegisterRpcDelegate(typeof(InterRunInfo), kRpcRpcDirtyStats, new CmdDelegate(InvokeRpcRpcDirtyStats));
			NetworkCRC.RegisterBehaviour("InterRunInfo", 0);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			if (forceAll)
			{
				writer.Write(loiterPenaltyTimeThisRun);
				writer.Write(loiterPenaltyFrequencyThisRun);
				writer.Write(loiterPenaltySeverityThisRun);
				writer.Write(limitPestsThisRun);
				writer.Write(limitPestsAmountThisRun);
				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(loiterPenaltyTimeThisRun);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 2u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(loiterPenaltyFrequencyThisRun);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 4u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(loiterPenaltySeverityThisRun);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 8u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(limitPestsThisRun);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 0x10u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(limitPestsAmountThisRun);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 0x20u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(allyCurse);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 0x40u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(loiterTick);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 0x80u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				writer.Write(loiterPenaltyActive);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 0x100u) != 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)
			{
				loiterPenaltyTimeThisRun = reader.ReadSingle();
				loiterPenaltyFrequencyThisRun = reader.ReadSingle();
				loiterPenaltySeverityThisRun = reader.ReadSingle();
				limitPestsThisRun = reader.ReadBoolean();
				limitPestsAmountThisRun = reader.ReadSingle();
				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)
			{
				loiterPenaltyTimeThisRun = reader.ReadSingle();
			}
			if (((uint)num & 2u) != 0)
			{
				loiterPenaltyFrequencyThisRun = reader.ReadSingle();
			}
			if (((uint)num & 4u) != 0)
			{
				loiterPenaltySeverityThisRun = reader.ReadSingle();
			}
			if (((uint)num & 8u) != 0)
			{
				limitPestsThisRun = reader.ReadBoolean();
			}
			if (((uint)num & 0x10u) != 0)
			{
				limitPestsAmountThisRun = reader.ReadSingle();
			}
			if (((uint)num & 0x20u) != 0)
			{
				allyCurse = reader.ReadSingle();
			}
			if (((uint)num & 0x40u) != 0)
			{
				loiterTick = reader.ReadSingle();
			}
			if (((uint)num & 0x80u) != 0)
			{
				loiterPenaltyActive = reader.ReadBoolean();
			}
			if (((uint)num & 0x100u) != 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.*/)]
	[BepInPlugin("com.HDeDeDe.InterlopingArtifact", "InterlopingArtifact", "0.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[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.1.3";

		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)
		{
		}
	}
}