Decompiled source of SimulacrumRework v1.0.0

SimulacrumRework.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SimulacrumRework")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SimulacrumRework")]
[assembly: AssemblyTitle("SimulacrumRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SimulacrumRework
{
	[BepInPlugin("com.Nuxlar.SimulacrumRework", "SimulacrumRework", "1.0.0")]
	public class SimulacrumRework : BaseUnityPlugin
	{
		private GameObject simPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerRun.prefab").WaitForCompletion();

		private SceneDef voidPlains = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itgolemplains/itgolemplains.asset").WaitForCompletion();

		private SceneDef voidAqueduct = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itgoolake/itgoolake.asset").WaitForCompletion();

		private SceneDef voidAphelian = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itancientloft/itancientloft.asset").WaitForCompletion();

		private SceneDef voidRPD = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itfrozenwall/itfrozenwall.asset").WaitForCompletion();

		private SceneDef voidAbyssal = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itdampcave/itdampcave.asset").WaitForCompletion();

		private SceneDef voidMeadow = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC1/itskymeadow/itskymeadow.asset").WaitForCompletion();

		private SpawnCard[] interactableCards = (SpawnCard[])(object)new SpawnCard[4]
		{
			Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Duplicator/iscDuplicator.asset").WaitForCompletion(),
			Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/DuplicatorLarge/iscDuplicatorLarge.asset").WaitForCompletion(),
			Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/EquipmentBarrel/iscEquipmentBarrel.asset").WaitForCompletion(),
			Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/Scrapper/iscScrapper.asset").WaitForCompletion()
		};

		public void Awake()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			InfiniteTowerRun component = simPrefab.GetComponent<InfiniteTowerRun>();
			component.stageTransitionPeriod = 5;
			component.interactableCredits = 0;
			Run.PickNextStageScene += new hook_PickNextStageScene(Run_PickNextStageScene);
			InfiniteTowerSafeWardController.RandomizeLocation += new hook_RandomizeLocation(Movent);
			InfiniteTowerRun.SpawnSafeWard += new hook_SpawnSafeWard(SpawnAdditionalInteractables);
		}

		private void Run_PickNextStageScene(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)self).name.Contains("InfiniteTowerRun"))
			{
				int waveIndex = ((Component)Run.instance).gameObject.GetComponent<InfiniteTowerRun>().waveIndex;
				if (waveIndex > 0)
				{
					if (waveIndex == 5)
					{
						int[] array = Array.Empty<int>();
						WeightedSelection<SceneDef> obj = new WeightedSelection<SceneDef>(8);
						obj.AddChoice(voidAqueduct, 1f);
						obj.AddChoice(voidAphelian, 1f);
						int num = obj.EvaluateToChoiceIndex(Run.instance.runRNG.nextNormalizedFloat, array);
						ChoiceInfo<SceneDef> choice = obj.GetChoice(num);
						Run.instance.nextStageScene = choice.value;
					}
					if (waveIndex == 10)
					{
						Run.instance.nextStageScene = voidRPD;
					}
					if (waveIndex == 15)
					{
						Run.instance.nextStageScene = voidAbyssal;
					}
					if (waveIndex == 20)
					{
						Run.instance.nextStageScene = voidMeadow;
					}
					if (waveIndex > 20)
					{
						orig.Invoke(self, choices);
					}
				}
				else
				{
					Run.instance.nextStageScene = voidPlains;
				}
			}
			else
			{
				orig.Invoke(self, choices);
			}
		}

		private void Movent(orig_RandomizeLocation orig, InfiniteTowerSafeWardController self, Xoroshiro128Plus rng)
		{
			if (!Object.op_Implicit((Object)(object)Run.instance) || !((Object)Run.instance).name.Contains("InfiniteTowerRun"))
			{
				orig.Invoke(self, rng);
			}
		}

		private void SpawnAdditionalInteractables(orig_SpawnSafeWard orig, InfiniteTowerRun self, InteractableSpawnCard safeWardCard, DirectorPlacementRule placementRule)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("InfiniteTowerRun"))
			{
				GameObject val = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)safeWardCard, placementRule, self.safeWardRng));
				if (Object.op_Implicit((Object)(object)val))
				{
					NetworkServer.Spawn(val);
					self.safeWardController = val.GetComponent<InfiniteTowerSafeWardController>();
					if (Object.op_Implicit((Object)(object)self.safeWardController))
					{
						self.safeWardController.onActivated += self.OnSafeWardActivated;
					}
					HoldoutZoneController component = val.GetComponent<HoldoutZoneController>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.calcAccumulatedCharge += new CalcAccumulatedChargeDelegate(self.CalcHoldoutZoneCharge);
					}
					if (!Object.op_Implicit((Object)(object)self.fogDamageController))
					{
						return;
					}
					self.fogDamageController.AddSafeZone(self.safeWardController.safeZone);
					DirectorPlacementRule val2 = new DirectorPlacementRule();
					val2.position = ((Component)self.safeWardController).transform.position;
					val2.minDistance = 5f;
					val2.maxDistance = 20f;
					val2.placementMode = (PlacementMode)1;
					SpawnCard[] array = interactableCards;
					foreach (SpawnCard val3 in array)
					{
						GameObject val4 = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(val3, val2, self.safeWardRng));
						if (Object.op_Implicit((Object)(object)val4))
						{
							NetworkServer.Spawn(val4);
						}
					}
				}
				else
				{
					Debug.LogError((object)"Unable to spawn safe ward instance.  Are there any ground nodes?");
				}
			}
			else
			{
				orig.Invoke(self, safeWardCard, placementRule);
			}
		}
	}
}