Decompiled source of PathOfTheColossus v1.0.2

PathOfTheColossus.dll

Decompiled 2 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 On.RoR2.UI;
using R2API;
using RoR2;
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PathOfTheColossus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PathOfTheColossus")]
[assembly: AssemblyTitle("PathOfTheColossus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace PathOfTheColossus
{
	[BepInPlugin("com.Nuxlar.PathOfTheColossus", "PathOfTheColossus", "1.0.2")]
	public class PathOfTheColossus : BaseUnityPlugin
	{
		public class ColossusRunButton : MonoBehaviour
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static UnityAction <>9__1_0;

				internal void <Start>b__1_0()
				{
					Util.PlaySound("Play_UI_menuClick", ((Component)RoR2Application.instance).gameObject);
					Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode xColossusRun; host 0; \"", false);
				}
			}

			public HGButton hgButton;

			public void Start()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Expected O, but got Unknown
				hgButton = ((Component)this).GetComponent<HGButton>();
				((Button)hgButton).onClick = new ButtonClickedEvent();
				ButtonClickedEvent onClick = ((Button)hgButton).onClick;
				object obj = <>c.<>9__1_0;
				if (obj == null)
				{
					UnityAction val = delegate
					{
						Util.PlaySound("Play_UI_menuClick", ((Component)RoR2Application.instance).gameObject);
						Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode xColossusRun; host 0; \"", false);
					};
					<>c.<>9__1_0 = val;
					obj = (object)val;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
			}
		}

		public class ColossusRunButtonAdder : MonoBehaviour
		{
			public void Start()
			{
				if (!Object.op_Implicit((Object)(object)dlc2Def) || ((BaseUserEntitlementTracker<LocalUser>)(object)EntitlementManager.localUserEntitlementTracker).AnyUserHasEntitlement(dlc2Def.requiredEntitlement))
				{
					GameObject obj = Object.Instantiate<GameObject>(((Component)((Component)this).transform.Find("GenericMenuButton (Eclipse)")).gameObject, ((Component)this).transform);
					obj.AddComponent<ColossusRunButton>();
					obj.GetComponent<LanguageTextMeshController>().token = "Colossus";
					obj.GetComponent<HGButton>().hoverToken = "Conquer the Path of the Colossus.";
				}
			}
		}

		public class ColossusRun : Run
		{
			public bool hasStarted;
		}

		private static SceneDef verdant = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lakes/lakes.asset").WaitForCompletion();

		private static SceneDef verdantVariant = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lakesnight/lakesnight.asset").WaitForCompletion();

		private static SceneDef abodes = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/village/village.asset").WaitForCompletion();

		private static SceneDef abodesVariant = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/villagenight/villagenight.asset").WaitForCompletion();

		private static SceneDef altar = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lemuriantemple/lemuriantemple.asset").WaitForCompletion();

		private static SceneDef colony = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/habitat/habitat.asset").WaitForCompletion();

		private static SceneDef colonyVariant = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/habitatfall/habitatfall.asset").WaitForCompletion();

		private static SceneDef helminth = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/helminthroost/helminthroost.asset").WaitForCompletion();

		private static SceneDef meridian = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/meridian/meridian.asset").WaitForCompletion();

		private static SceneDef moon2 = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/Base/moon2/moon2.asset").WaitForCompletion();

		private static SceneCollection colossusStage1 = ScriptableObject.CreateInstance<SceneCollection>();

		private static GameObject classicRun = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ClassicRun/ClassicRun.prefab").WaitForCompletion(), "ColossusRunNux");

		private static GameObject colossusRun;

		private static ExpansionDef dlc2Def = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC2/Common/DLC2.asset").WaitForCompletion();

		public void Awake()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Expected O, but got Unknown
			colossusStage1._sceneEntries = (SceneEntry[])(object)new SceneEntry[2]
			{
				new SceneEntry
				{
					sceneDef = verdant,
					weightMinusOne = 0f
				},
				new SceneEntry
				{
					sceneDef = verdantVariant,
					weightMinusOne = 0f
				}
			};
			verdantVariant.isLockedBeforeLooping = false;
			abodesVariant.isLockedBeforeLooping = false;
			colonyVariant.isLockedBeforeLooping = false;
			meridian.sceneType = (SceneType)1;
			colossusRun = PrefabAPI.InstantiateClone(new GameObject("xColossusRun"), "xColossusRun");
			colossusRun.AddComponent<NetworkIdentity>();
			PrefabAPI.RegisterNetworkPrefab(colossusRun);
			Run component = classicRun.GetComponent<Run>();
			ColossusRun obj = colossusRun.AddComponent<ColossusRun>();
			((Run)obj).startingSceneGroup = colossusStage1;
			((Run)obj).nameToken = "Colossus";
			((Run)obj).gameOverPrefab = component.gameOverPrefab;
			((Run)obj).lobbyBackgroundPrefab = component.lobbyBackgroundPrefab;
			((Run)obj).uiPrefab = component.uiPrefab;
			colossusRun.AddComponent<TeamManager>();
			colossusRun.AddComponent<NetworkRuleBook>();
			colossusRun.AddComponent<TeamFilter>();
			colossusRun.AddComponent<EnemyInfoPanelInventoryProvider>();
			colossusRun.AddComponent<ExpansionRequirementComponent>();
			colossusRun.AddComponent<RunCameraManager>();
			ContentAddition.AddGameMode(colossusRun);
			Run.PickNextStageScene += new hook_PickNextStageScene(Run_PickNextStageScene);
			SceneExitController.Begin += new hook_Begin(ChangeLunarTp);
			GameModeCatalog.SetGameModes += new hook_SetGameModes(GameModeCatalog_SetGameModes);
			LanguageTextMeshController.Start += new hook_Start(LanguageTextMeshController_Start);
		}

		private void ChangeLunarTp(orig_Begin orig, SceneExitController self)
		{
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)Run.instance) && ((Object)Run.instance).name.Contains("Colossus") && (Object)(object)self.destinationScene == (Object)(object)moon2)
			{
				self.destinationScene = meridian;
			}
		}

		private void Run_PickNextStageScene(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices)
		{
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, choices);
			if (!((Object)self).name.Contains("Colossus"))
			{
				return;
			}
			WeightedSelection<SceneDef> val = new WeightedSelection<SceneDef>(8);
			ColossusRun component = ((Component)Run.instance).gameObject.GetComponent<ColossusRun>();
			int num = self.stageClearCount;
			if (self.loopClearCount >= 1 && num != 6)
			{
				num -= 6 * self.loopClearCount;
			}
			switch (num)
			{
			case 0:
				if (!component.hasStarted && self.loopClearCount == 0)
				{
					component.hasStarted = true;
					val.AddChoice(new ChoiceInfo<SceneDef>
					{
						value = verdant,
						weight = 1f
					});
					val.AddChoice(new ChoiceInfo<SceneDef>
					{
						value = verdantVariant,
						weight = 1f
					});
					self.nextStageScene = val.Evaluate(self.nextStageRng.nextNormalizedFloat);
				}
				else
				{
					val.AddChoice(new ChoiceInfo<SceneDef>
					{
						value = abodes,
						weight = 1f
					});
					val.AddChoice(new ChoiceInfo<SceneDef>
					{
						value = abodesVariant,
						weight = 1f
					});
					self.nextStageScene = val.Evaluate(self.nextStageRng.nextNormalizedFloat);
				}
				break;
			case 1:
				val.AddChoice(new ChoiceInfo<SceneDef>
				{
					value = altar,
					weight = 1f
				});
				self.nextStageScene = val.Evaluate(self.nextStageRng.nextNormalizedFloat);
				break;
			case 2:
				val.AddChoice(new ChoiceInfo<SceneDef>
				{
					value = colony,
					weight = 1f
				});
				val.AddChoice(new ChoiceInfo<SceneDef>
				{
					value = colonyVariant,
					weight = 1f
				});
				self.nextStageScene = val.Evaluate(self.nextStageRng.nextNormalizedFloat);
				break;
			case 3:
				val.AddChoice(new ChoiceInfo<SceneDef>
				{
					value = helminth,
					weight = 1f
				});
				self.nextStageScene = val.Evaluate(self.nextStageRng.nextNormalizedFloat);
				break;
			case 4:
				val.AddChoice(new ChoiceInfo<SceneDef>
				{
					value = meridian,
					weight = 1f
				});
				self.nextStageScene = val.Evaluate(self.nextStageRng.nextNormalizedFloat);
				break;
			default:
				component.hasStarted = false;
				val.AddChoice(new ChoiceInfo<SceneDef>
				{
					value = verdant,
					weight = 1f
				});
				val.AddChoice(new ChoiceInfo<SceneDef>
				{
					value = verdantVariant,
					weight = 1f
				});
				self.nextStageScene = val.Evaluate(self.nextStageRng.nextNormalizedFloat);
				break;
			}
		}

		private void GameModeCatalog_SetGameModes(orig_SetGameModes orig, Run[] newGameModePrefabComponents)
		{
			Array.Sort(newGameModePrefabComponents, (Run a, Run b) => string.CompareOrdinal(((Object)a).name, ((Object)b).name));
			orig.Invoke(newGameModePrefabComponents);
		}

		private void LanguageTextMeshController_Start(orig_Start orig, LanguageTextMeshController self)
		{
			orig.Invoke(self);
			if (self.token == "TITLE_ECLIPSE" && Object.op_Implicit((Object)(object)((Component)self).GetComponent<HGButton>()))
			{
				((Component)((Component)self).transform.parent).gameObject.AddComponent<ColossusRunButtonAdder>();
			}
		}
	}
}