Decompiled source of MoreMountains v1.1.2

plugins/shbones-MoreMountains/MoreMountains.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MoreMountains.Interactables;
using MoreMountains.Utils.Compatibility;
using On.RoR2;
using R2API;
using R2API.Utils;
using Risky_Artifacts.Artifacts;
using RoR2;
using RoR2.Hologram;
using RoR2.Navigation;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;

[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("MoreMountains")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreMountains")]
[assembly: AssemblyTitle("MoreMountains")]
[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 MoreMountains
{
	public class BossDropManager : NetworkBehaviour
	{
		public static int NumberRedDropsForRun;

		public static int NumberYellowDropsForRun;

		public static int NumberRedDropsForStage;

		public static int NumberYellowDropsForStage;

		private List<PickupIndex> _redAvailableDrops;

		private List<PickupIndex> _yellowAvailableDrops;

		private List<PickupIndex> _voidTier2AvailableDrops;

		private List<PickupIndex> _voidTier3AvailableDrops;

		private List<PickupIndex> _lunarAvailableDrops;

		private PickupIndex redPickupIndex;

		private PickupIndex yellowPickupIndex;

		private PickupIndex voidTier2PickupIndex;

		private PickupIndex voidTier3PickupIndex;

		private PickupIndex lunarPickupIndex;

		private Vector3 _teleporterBossPosition;

		public static BossDropManager Instance { get; private set; }

		public BossDropManager()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				throw new InvalidOperationException("Singleton class BossDropManager was instantiated twice");
			}
			Instance = this;
		}

		[Server]
		public void Init()
		{
			Hooks();
		}

		public void AddMoreMountainReward(string sourceObjectName)
		{
			if (sourceObjectName.Contains("CrimsonMountain"))
			{
				RedShrineActivated();
			}
			else if (sourceObjectName.Contains("AmberMountain"))
			{
				YellowShrineActivated();
			}
		}

		[Server]
		public void RedShrineActivated()
		{
			NumberRedDropsForStage += Run.instance.participatingPlayerCount;
			if (RiskyArtifactsCompatibility.enabled)
			{
				RiskyArtifactsCompatibility.addRedStackIfArrognanceEnabled();
			}
		}

		public void YellowShrineActivated()
		{
			NumberYellowDropsForStage += Run.instance.participatingPlayerCount;
		}

		[Server]
		private void ResetRunShrinesHit(Run obj)
		{
			NumberRedDropsForRun = 0;
			NumberYellowDropsForRun = 0;
			NumberRedDropsForStage = 0;
			NumberYellowDropsForStage = 0;
		}

		[Server]
		private void ResetStageShrinesHit(Stage obj)
		{
			NumberRedDropsForStage = 0;
			NumberYellowDropsForStage = 0;
			if (RiskyArtifactsCompatibility.enabled)
			{
				RiskyArtifactsCompatibility.stageStartArroganceCompat();
			}
		}

		[Server]
		private void TrackTeleporterBoss(orig_Start orig, BossGroup self)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)self).gameObject).name.ToLower().Contains("teleporter"))
			{
				if (!self.scaleRewardsByPlayerCount)
				{
					NumberRedDropsForStage /= Run.instance.participatingPlayerCount;
				}
				if (NumberRedDropsForStage > 0)
				{
					int index = Random.Range(0, Run.instance.availableTier3DropList.Count - 1);
					redPickupIndex = Run.instance.availableTier3DropList[index];
				}
				if (NumberYellowDropsForStage > 0)
				{
					int index2 = Random.Range(0, Run.instance.availableBossDropList.Count - 1);
					yellowPickupIndex = Run.instance.availableBossDropList[index2];
				}
				_teleporterBossPosition = self.dropPosition.position;
			}
		}

		[Server]
		private void ReplaceTeleporterDropsIfNecessary(orig_CreatePickupDroplet_PickupIndex_Vector3_Vector3 orig, PickupIndex pickupIndex, Vector3 position, Vector3 velocity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (position == _teleporterBossPosition)
			{
				if (NumberRedDropsForStage > 0)
				{
					orig.Invoke(redPickupIndex, position, velocity);
					NumberRedDropsForStage--;
					return;
				}
				if (NumberYellowDropsForStage > 0)
				{
					orig.Invoke(yellowPickupIndex, position, velocity);
					NumberYellowDropsForStage--;
					return;
				}
			}
			orig.Invoke(pickupIndex, position, velocity);
		}

		private void Hooks()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			Run.onRunStartGlobal += ResetRunShrinesHit;
			Stage.onStageStartGlobal += ResetStageShrinesHit;
			BossGroup.Start += new hook_Start(TrackTeleporterBoss);
			PickupDropletController.CreatePickupDroplet_PickupIndex_Vector3_Vector3 += new hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3(ReplaceTeleporterDropsIfNecessary);
		}
	}
	public class MoreMountainsConfigManager
	{
		public static ConfigEntry<int> VanillaMountainSpawnWeightMultiplier;

		public static ConfigEntry<int> VanillaMountainMaxSpawnsMultiplier;

		public static ConfigEntry<int> RedShrineMountainReplacementPercent;

		public static ConfigEntry<int> YellowShrineMountainReplacementPercent;

		public static ConfigEntry<int> RedShrineMountainDifficultyStacks;

		public static ConfigEntry<int> YellowShrineMountainDifficultyStacks;

		public void Init(string configPath)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ConfigFile val = new ConfigFile(Path.Combine(configPath, "shbones-MoreMountains.cfg"), true);
			VanillaMountainSpawnWeightMultiplier = val.Bind<int>("1. Vanilla Mountain Config", "Spawn Weight Multiplier", 1, "Effectively scales the spawn rate of all mountain shrines. This will have effect whether the shrines added by this mod are enabled or not.");
			RedShrineMountainReplacementPercent = val.Bind<int>("2. New Shrine Replacement Chance", "Red Mountain Replacement Chance", 10, "Percent chance (e.g value of 10 = 10% chance) to replace a Mountain Shrine that would be spawned with a Crimson Mountain Shrine. Value of 0 disables Crimson Mountain Shrine. Keep the sum of values in this section less than 100.");
			YellowShrineMountainReplacementPercent = val.Bind<int>("2. New Shrine Replacement Chance", "Yellow Mountain Replacement Chance", 10, "Percent chance (e.g value of 15 = 10% chance) to replace a Mountain Shrine that would be spawned with ab Amber Mountain Shrine. Value of 0 disables Amber Mountain Shrine. Keep the sum of values in this section less than 100.");
			RedShrineMountainDifficultyStacks = val.Bind<int>("3. New Shrine Difficulty Stacks", "Red Mountain Difficulty Stacks", 5, "Additional Stacks of credits given to the Teleporter Director. A Value of 5 here means the Teleporter difficulty will be equivalent to hitting 6 normal mountain shrines. Reward is always only 1");
			YellowShrineMountainDifficultyStacks = val.Bind<int>("3. New Shrine Difficulty Stacks", "Yellow Mountain Difficulty Stacks", 4, "Additional Stacks of credits given to the Teleporter Director. A Value of 5 here means the Teleporter difficulty will be equivalent to hitting 6 normal mountain shrines. Reward is always only 1");
		}
	}
	[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("shbones.MoreMountains", "MoreMountains", "1.1.2")]
	[R2APISubmoduleDependency(new string[] { "LanguageAPI", "DirectorAPI", "PrefabAPI" })]
	public class MoreMountainsPlugin : BaseUnityPlugin
	{
		private static InteractableSpawnCard _crimsonSpawnCard;

		private static InteractableSpawnCard _amberSpawnCard;

		public const string PluginAuthor = "shbones";

		public const string PluginName = "MoreMountains";

		public const string PluginVersion = "1.1.2";

		public const string PluginGUID = "shbones.MoreMountains";

		public static PluginInfo thePluginInfo { get; private set; }

		public void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			InitPlugin();
			InitNewMountainShrines();
			DirectorCardCategorySelection.calcCardWeight += new CalcCardWeight(SpawnCardSubscription);
			DirectorCore.TrySpawnObject += new hook_TrySpawnObject(ReplaceVanillaMountains);
			Log.LogInfo("shbones.MoreMountains initialized.");
		}

		private void InitNewMountainShrines()
		{
			IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(MoreMountainShrineBase))
				select type;
			Log.LogInfo("-----------------Initializing More Mountains---------------------");
			foreach (Type item in enumerable)
			{
				MoreMountainShrineBase moreMountainShrineBase = (MoreMountainShrineBase)Activator.CreateInstance(item);
				moreMountainShrineBase.Init(((BaseUnityPlugin)this).Config);
				Log.LogDebug("Interactable: " + moreMountainShrineBase.InteractableName + " Initialized!");
			}
		}

		private void InitPlugin()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			thePluginInfo = ((BaseUnityPlugin)this).Info;
			new MoreMountainsConfigManager().Init(Paths.ConfigPath);
			BossDropManager bossDropManager = new BossDropManager();
			bossDropManager.Init();
		}

		private GameObject ReplaceVanillaMountains(orig_TrySpawnObject orig, DirectorCore self, DirectorSpawnRequest spawnRequest)
		{
			if (!(Run.instance is InfiniteTowerRun))
			{
				int value = MoreMountainsConfigManager.RedShrineMountainReplacementPercent.Value;
				int num = value + MoreMountainsConfigManager.YellowShrineMountainReplacementPercent.Value;
				SpawnCard spawnCard = spawnRequest.spawnCard;
				if (((Object)spawnCard).name.Contains("iscShrineBoss"))
				{
					int num2 = Random.Range(1, 100);
					if (num2 <= value)
					{
						Log.LogDebug("Replacing Mountain with Crimson Mountain!");
						spawnRequest.spawnCard = (SpawnCard)(object)_crimsonSpawnCard;
					}
					else if (num2 <= num)
					{
						Log.LogDebug("Replacing Mountain with Amber Mountain!");
						spawnRequest.spawnCard = (SpawnCard)(object)_amberSpawnCard;
					}
					Log.LogDebug("Spawning Normal Mountain!");
				}
			}
			return orig.Invoke(self, spawnRequest);
		}

		private void SpawnCardSubscription(DirectorCard card, ref float weight)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			if (((Object)card.spawnCard).name.Contains("iscShrineBossCrimson"))
			{
				_crimsonSpawnCard = (InteractableSpawnCard)card.spawnCard;
			}
			else if (((Object)card.spawnCard).name.Contains("iscShrineBossAmber"))
			{
				_amberSpawnCard = (InteractableSpawnCard)card.spawnCard;
			}
			else if (((Object)card.spawnCard).name.Contains("iscShrineBoss"))
			{
				weight *= MoreMountainsConfigManager.VanillaMountainSpawnWeightMultiplier.Value;
			}
		}
	}
	public static class Assets
	{
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace MoreMountains.Utils.Compatibility
{
	public static class RiskyArtifactsCompatibility
	{
		private static bool? _enabled;

		private static ArtifactIndex _arroganceIndex;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.Moffein.RiskyArtifacts");
				}
				return _enabled.Value;
			}
		}

		public static void addRedStackIfArrognanceEnabled()
		{
			if (isArroganceEnabled())
			{
				Arrogance.stageMountainCount++;
				BossDropManager.NumberRedDropsForRun += Run.instance.participatingPlayerCount;
			}
		}

		public static void addYellowStackIfArrognanceEnabled()
		{
			if (isArroganceEnabled())
			{
				Arrogance.stageMountainCount++;
				BossDropManager.NumberYellowDropsForRun += Run.instance.participatingPlayerCount;
			}
		}

		public static void stageStartArroganceCompat()
		{
			if (isArroganceEnabled())
			{
				BossDropManager.NumberRedDropsForStage = BossDropManager.NumberRedDropsForRun;
				int value = MoreMountainsConfigManager.RedShrineMountainDifficultyStacks.Value;
				if (value > 1)
				{
					int num = value * BossDropManager.NumberRedDropsForRun;
					for (int i = 0; i < num; i++)
					{
						TeleporterInteraction instance = TeleporterInteraction.instance;
						int shrineBonusStacks = instance.shrineBonusStacks + 1;
						instance.shrineBonusStacks = shrineBonusStacks;
					}
				}
				BossDropManager.NumberYellowDropsForStage = BossDropManager.NumberYellowDropsForRun;
				int value2 = MoreMountainsConfigManager.YellowShrineMountainDifficultyStacks.Value;
				if (value2 > 1)
				{
					int num2 = value2 * BossDropManager.NumberYellowDropsForRun;
					for (int j = 0; j < num2; j++)
					{
						TeleporterInteraction instance2 = TeleporterInteraction.instance;
						int shrineBonusStacks = instance2.shrineBonusStacks + 1;
						instance2.shrineBonusStacks = shrineBonusStacks;
					}
				}
			}
			else
			{
				BossDropManager.NumberRedDropsForRun = 0;
				BossDropManager.NumberYellowDropsForRun = 0;
			}
		}

		private static ArtifactIndex getArroganceArtifactIndex()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (Arrogance.enabled)
			{
				return ArtifactCatalog.FindArtifactIndex("RiskyArtifactOfArrogance");
			}
			return (ArtifactIndex)(-1);
		}

		private static bool isArroganceEnabled()
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (!Arrogance.enabled)
			{
				return false;
			}
			ArtifactIndex arroganceArtifactIndex = getArroganceArtifactIndex();
			if ((int)arroganceArtifactIndex == -1)
			{
				return false;
			}
			return RunArtifactManager.instance.IsArtifactEnabled(arroganceArtifactIndex);
		}
	}
}
namespace MoreMountains.Interactables
{
	public class AmberMountainShrine : MoreMountainShrineBase<AmberMountainShrine>
	{
		public override string InteractableName => "Amber Shrine of the Mountain";

		public override string SpawnCardName => "iscShrineBossAmber";

		public override string PrefabName => "AmberMountain.prefab";

		public override string InteractableLangToken => "AMBER_MOUNTAIN_SHRINE";

		public override string InteractableMessage => "<style=cShrine>{0} has invited the challenge of the Amber Mountain..</color>";

		public override string InteractableMessage2P => "<style=cShrine>You have invited the challenge of the Amber Mountain..</color>";

		public override Color IconColor => Color.yellow;

		public override int NumberOfMountainDirectorStacksAdded => MoreMountainsConfigManager.YellowShrineMountainDifficultyStacks.Value;
	}
	public class MoreMountainShrineBehavior : NetworkBehaviour
	{
		public Transform IconIndicator;

		public PurchaseInteraction PurchaseInteraction;

		public int NumberOfMountainDirectorStacksToAdd;

		public string InteractableLangToken;

		public int maxPurchaseCount = 1;

		public int purchaseCount;

		public bool waitingForRefresh;

		public float refreshTimer;

		public void Start()
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance))
			{
				((Component)IconIndicator).gameObject.SetActive(true);
				PurchaseInteraction.SetAvailableTrue();
			}
			((UnityEvent<Interactor>)(object)PurchaseInteraction.onPurchase).AddListener((UnityAction<Interactor>)ShrineBehaviorAttempt);
		}

		public void FixedUpdate()
		{
			if (waitingForRefresh)
			{
				refreshTimer -= Time.fixedDeltaTime;
				if (refreshTimer <= 0f && purchaseCount < maxPurchaseCount)
				{
					SetShrineEnabled(activeState: true);
					waitingForRefresh = false;
				}
			}
			((Component)IconIndicator).gameObject.SetActive(PurchaseInteraction.available);
		}

		[Server]
		public void AddShrineStack(Interactor interactor)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'System.Void RoR2.MoreMountainShrineBehavior::AddShrineStack(RoR2.Interactor)' called on client");
				return;
			}
			waitingForRefresh = true;
			if (Object.op_Implicit((Object)(object)TeleporterInteraction.instance))
			{
				Log.LogDebug("Adding " + NumberOfMountainDirectorStacksToAdd + " mountain stacks.");
				TeleporterInteraction.instance.AddShrineStack();
				for (int i = 0; i < NumberOfMountainDirectorStacksToAdd; i++)
				{
					TeleporterInteraction instance = TeleporterInteraction.instance;
					int shrineBonusStacks = instance.shrineBonusStacks + 1;
					instance.shrineBonusStacks = shrineBonusStacks;
				}
				Log.LogDebug("ShrineBonusStacks = " + TeleporterInteraction.instance.shrineBonusStacks);
			}
			CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
			Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
			{
				subjectAsCharacterBody = component,
				baseToken = "INTERACTABLE_" + InteractableLangToken + "_MESSAGE"
			});
			EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
			{
				origin = ((Component)this).transform.position,
				rotation = Quaternion.identity,
				scale = 1f,
				color = Color32.op_Implicit(new Color(0.7372549f, 77f / 85f, 0.94509804f))
			}, true);
			refreshTimer = 2f;
			BossDropManager.Instance.AddMoreMountainReward(((Object)((Component)this).gameObject).name);
			SetShrineEnabled(activeState: false);
		}

		public void ShrineBehaviorAttempt(Interactor interactor)
		{
			purchaseCount++;
			AddShrineStack(interactor);
		}

		public void SetShrineEnabled(bool activeState)
		{
			PurchaseInteraction.SetAvailable(activeState);
			((Component)IconIndicator).gameObject.SetActive(activeState);
		}
	}
	public class CrimsonMountainShrine : MoreMountainShrineBase<CrimsonMountainShrine>
	{
		public override string InteractableName => "Crimson Shrine of the Mountain";

		public override string SpawnCardName => "iscShrineBossCrimson";

		public override string PrefabName => "CrimsonMountain.prefab";

		public override string InteractableLangToken => "CRIMSON_MOUNTAIN_SHRINE";

		public override string InteractableMessage => "<style=cShrine>{0} has invited the challenge of the Crimson Mountain..</color>";

		public override string InteractableMessage2P => "<style=cShrine>You have invited the challenge of the Crimson Mountain..</color>";

		public override Color IconColor => Color.red;

		public override int NumberOfMountainDirectorStacksAdded => MoreMountainsConfigManager.RedShrineMountainDifficultyStacks.Value;
	}
	public abstract class MoreMountainShrineBase<T> : MoreMountainShrineBase where T : MoreMountainShrineBase<T>
	{
		public static T instance { get; private set; }

		public MoreMountainShrineBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting PurchaseInteractableBase/Interactable was instantiated twice");
			}
			instance = this as T;
		}
	}
	public abstract class MoreMountainShrineBase
	{
		public GameObject InteractableModel;

		public string InteractableContext = "This shrine looks different than usual...are you sure?";

		public GameObject InteractableBodyModelPrefab;

		public InteractableSpawnCard InteractableSpawnCard;

		public abstract string InteractableName { get; }

		public abstract string InteractableMessage { get; }

		public abstract string InteractableMessage2P { get; }

		public abstract string SpawnCardName { get; }

		public abstract string PrefabName { get; }

		public abstract string InteractableLangToken { get; }

		public abstract Color IconColor { get; }

		public abstract int NumberOfMountainDirectorStacksAdded { get; }

		public void Init(ConfigFile config)
		{
			CreateFromMountainPrefab();
			CreateInteractableSpawnCard(InteractableBodyModelPrefab, SpawnCardName, MountainShrineUtil.GetAllStageList());
			CreateLang();
		}

		private void CreateFromMountainPrefab()
		{
			//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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ShrineBoss/ShrineBoss.prefab").WaitForCompletion();
			InteractableModel = PrefabAPI.InstantiateClone(val, PrefabName);
			ShrineBossBehavior component = InteractableModel.GetComponent<ShrineBossBehavior>();
			Object.Destroy((Object)(object)component);
			InteractableBodyModelPrefab = InteractableModel;
			PurchaseInteraction component2 = InteractableBodyModelPrefab.GetComponent<PurchaseInteraction>();
			component2.displayNameToken = "INTERACTABLE_" + InteractableLangToken + "_NAME";
			component2.contextToken = "INTERACTABLE_" + InteractableLangToken + "_CONTEXT";
			PingInfoProvider val2 = InteractableModel.AddComponent<PingInfoProvider>();
			val2.pingIconOverride = LegacyResourcesAPI.Load<Sprite>("Textures/MiscIcons/texShrineIconOutlined");
			GenericDisplayNameProvider component3 = InteractableBodyModelPrefab.GetComponent<GenericDisplayNameProvider>();
			component3.displayToken = "INTERACTABLE_" + InteractableLangToken + "_NAME";
			Transform iconIndicator = setUpBillboardIcon(InteractableBodyModelPrefab, IconColor);
			changeColorOfShrine(InteractableBodyModelPrefab, IconColor);
			MoreMountainShrineBehavior moreMountainShrineBehavior = InteractableBodyModelPrefab.AddComponent<MoreMountainShrineBehavior>();
			moreMountainShrineBehavior.PurchaseInteraction = component2;
			moreMountainShrineBehavior.IconIndicator = iconIndicator;
			moreMountainShrineBehavior.NumberOfMountainDirectorStacksToAdd = NumberOfMountainDirectorStacksAdded;
			moreMountainShrineBehavior.InteractableLangToken = InteractableLangToken;
		}

		private InteractableSpawnCard CreateInteractableSpawnCard(GameObject aInteractableModel, string name, List<Stage> stageList)
		{
			//IL_001d: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			InteractableSpawnCard val = ScriptableObject.CreateInstance<InteractableSpawnCard>();
			((Object)val).name = name;
			((SpawnCard)val).prefab = aInteractableModel;
			((SpawnCard)val).sendOverNetwork = true;
			((SpawnCard)val).hullSize = (HullClassification)1;
			((SpawnCard)val).nodeGraphType = (GraphType)0;
			((SpawnCard)val).requiredFlags = (NodeFlags)0;
			((SpawnCard)val).forbiddenFlags = (NodeFlags)16;
			((SpawnCard)val).directorCreditCost = 20;
			((SpawnCard)val).occupyPosition = true;
			val.orientToFloor = false;
			val.skipSpawnWhenSacrificeArtifactEnabled = false;
			DirectorCard val2 = new DirectorCard
			{
				selectionWeight = 0,
				spawnCard = (SpawnCard)(object)val
			};
			foreach (Stage stage in stageList)
			{
				Helpers.AddNewInteractableToStage(val2, (InteractableCategory)4, stage, "");
			}
			return val;
		}

		private static void changeColorOfShrine(GameObject normalModel, Color iconColor)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer component = ((Component)normalModel.transform.Find("Base").GetChild(0)).gameObject.GetComponent<MeshRenderer>();
			((Renderer)component).material.SetColor("_Color", iconColor);
		}

		private static Transform setUpBillboardIcon(GameObject normalModel, Color iconColor)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			Transform val = normalModel.transform.Find("Symbol");
			Billboard val2 = ((Component)val).gameObject.AddComponent<Billboard>();
			((Component)val).gameObject.AddComponent<NetworkIdentity>();
			Material material = ((Renderer)((Component)LegacyResourcesAPI.Load<SpawnCard>("spawncards/interactablespawncard/iscShrineBoss").prefab.transform.Find("Symbol")).GetComponent<MeshRenderer>()).material;
			MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
			Texture mainTexture = material.mainTexture;
			((Renderer)component).material = new Material(material.shader);
			((Renderer)component).material.CopyPropertiesFromMaterial(material);
			((Renderer)component).material.mainTexture = mainTexture;
			((Renderer)component).material.SetColor("_TintColor", iconColor);
			return val;
		}

		protected void CreateLang()
		{
			LanguageAPI.Add("INTERACTABLE_" + InteractableLangToken + "_NAME", InteractableName);
			LanguageAPI.Add("INTERACTABLE_" + InteractableLangToken + "_CONTEXT", InteractableContext);
			LanguageAPI.Add("INTERACTABLE_" + InteractableLangToken + "_MESSAGE", InteractableMessage);
			LanguageAPI.Add("INTERACTABLE_" + InteractableLangToken + "_MESSAGE_2P", InteractableMessage2P);
		}

		private void CreateInteractable()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			InteractableBodyModelPrefab = InteractableModel;
			InteractableBodyModelPrefab.AddComponent<NetworkIdentity>();
			PurchaseInteraction val = InteractableBodyModelPrefab.AddComponent<PurchaseInteraction>();
			val.displayNameToken = "INTERACTABLE_" + InteractableLangToken + "_NAME";
			val.contextToken = "INTERACTABLE_" + InteractableLangToken + "_CONTEXT";
			val.costType = (CostTypeIndex)0;
			val.automaticallyScaleCostWithDifficulty = false;
			val.cost = 0;
			val.available = true;
			val.setUnavailableOnTeleporterActivated = true;
			val.isShrine = true;
			val.isGoldShrine = false;
			PingInfoProvider val2 = InteractableModel.AddComponent<PingInfoProvider>();
			val2.pingIconOverride = LegacyResourcesAPI.Load<Sprite>("Textures/MiscIcons/texShrineIconOutlined");
			GenericDisplayNameProvider val3 = InteractableBodyModelPrefab.AddComponent<GenericDisplayNameProvider>();
			val3.displayToken = "INTERACTABLE_" + InteractableLangToken + "_NAME";
			Transform iconIndicator = setUpBillboardIcon(InteractableBodyModelPrefab, IconColor);
			MoreMountainShrineBehavior moreMountainShrineBehavior = InteractableBodyModelPrefab.AddComponent<MoreMountainShrineBehavior>();
			moreMountainShrineBehavior.PurchaseInteraction = val;
			moreMountainShrineBehavior.IconIndicator = iconIndicator;
			moreMountainShrineBehavior.NumberOfMountainDirectorStacksToAdd = NumberOfMountainDirectorStacksAdded;
			moreMountainShrineBehavior.InteractableLangToken = InteractableLangToken;
			EntityLocator component = ((Component)InteractableBodyModelPrefab.GetComponentInChildren<BoxCollider>()).gameObject.GetComponent<EntityLocator>();
			component.entity = InteractableBodyModelPrefab;
			ModelLocator val4 = InteractableBodyModelPrefab.AddComponent<ModelLocator>();
			val4.modelTransform = InteractableBodyModelPrefab.transform;
			val4.modelBaseTransform = InteractableBodyModelPrefab.transform.Find("Base");
			val4.dontDetatchFromParent = true;
			val4.autoUpdateModelTransform = true;
			Highlight component2 = InteractableBodyModelPrefab.GetComponent<Highlight>();
			component2.targetRenderer = (Renderer)(object)(from x in InteractableBodyModelPrefab.GetComponentsInChildren<MeshRenderer>()
				where ((Object)((Component)x).gameObject).name.Contains("mdlShrineBoss")
				select x).First();
			component2.strength = 1f;
			component2.highlightColor = (HighlightColor)0;
			HologramProjector val5 = InteractableBodyModelPrefab.AddComponent<HologramProjector>();
			val5.hologramPivot = InteractableBodyModelPrefab.transform.Find("HologramPivot");
			val5.displayDistance = 10f;
			val5.disableHologramRotation = true;
			ChildLocator val6 = InteractableBodyModelPrefab.AddComponent<ChildLocator>();
			PrefabAPI.RegisterNetworkPrefab(InteractableBodyModelPrefab);
		}
	}
	public static class MountainShrineUtil
	{
		public static List<Stage> GetNormalStageList()
		{
			List<Stage> list = new List<Stage>();
			list.Add((Stage)4);
			list.Add((Stage)128);
			list.Add((Stage)2);
			list.Add((Stage)131072);
			list.Add((Stage)256);
			list.Add((Stage)16384);
			list.Add((Stage)134217728);
			list.Add((Stage)64);
			list.Add((Stage)262144);
			return list;
		}

		public static List<Stage> GetSnowyStageList()
		{
			List<Stage> list = new List<Stage>();
			list.Add((Stage)67108864);
			list.Add((Stage)32);
			return list;
		}

		public static List<Stage> GetSandyStageList()
		{
			List<Stage> list = new List<Stage>();
			list.Add((Stage)16);
			return list;
		}

		public static List<Stage> GetAllStageList()
		{
			List<Stage> list = new List<Stage>();
			list.Add((Stage)4);
			list.Add((Stage)128);
			list.Add((Stage)2);
			list.Add((Stage)131072);
			list.Add((Stage)256);
			list.Add((Stage)16384);
			list.Add((Stage)134217728);
			list.Add((Stage)64);
			list.Add((Stage)262144);
			list.Add((Stage)67108864);
			list.Add((Stage)32);
			list.Add((Stage)16);
			return list;
		}
	}
}