Decompiled source of Shrine of Transmutation v1.1.0

plugins/ShrineOfTransmutation/ShrineOfTransmutation.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ShrineOfTransmutation")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+119a0254361d7f81c4553108cee95bd32dc14f3c")]
[assembly: AssemblyProduct("ShrineOfTransmutation")]
[assembly: AssemblyTitle("ShrineOfTransmutation")]
[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 ShrineOfTransmutation
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Xerphy.ShrineOfTransmutation", "ShrineOfTransmutation", "1.1.0")]
	public class ShrineOfTransmutation : BaseUnityPlugin
	{
		public const string PluginGUID = "Xerphy.ShrineOfTransmutation";

		public const string PluginAuthor = "Xerphy";

		public const string PluginName = "ShrineOfTransmutation";

		public const string PluginVersion = "1.1.0";

		private AssetBundle mainAssetBundle;

		private GameObject shrineOfTransmutation;

		private Sprite logo;

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

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

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

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

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

		public void Awake()
		{
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Expected O, but got Unknown
			//IL_01f8: 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_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Expected O, but got Unknown
			//IL_02fc: Expected O, but got Unknown
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Expected O, but got Unknown
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Expected O, but got Unknown
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Expected O, but got Unknown
			mainAssetBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("ShrineOfTransmutation.dll", "shrineoftransmutationbundle"));
			shrineOfTransmutation = PrefabAPI.InstantiateClone(mainAssetBundle.LoadAsset<GameObject>("Assets/ShrineOfTransmutation/ShrineOfTransmutationAssets/ShrineOfTransmutation.prefab"), "ShrineOfTransmutationModel");
			logo = mainAssetBundle.LoadAsset<Sprite>("Assets/ShrineOfTransmutation/ShrineOfTransmutationAssets/ShrineOfTransmutationLogo.png");
			Log.Init(((BaseUnityPlugin)this).Logger);
			((Object)shrineOfTransmutation).name = "ShrineOfTransmutation";
			shrineOfTransmutation.AddComponent<NetworkIdentity>();
			PurchaseInteraction val = shrineOfTransmutation.AddComponent<PurchaseInteraction>();
			ShrineOfTransmutationManager shrineOfTransmutationManager = shrineOfTransmutation.AddComponent<ShrineOfTransmutationManager>();
			string colorHexString = ColorCatalog.GetColorHexString((ColorIndex)1);
			string colorHexString2 = ColorCatalog.GetColorHexString((ColorIndex)2);
			string colorHexString3 = ColorCatalog.GetColorHexString((ColorIndex)3);
			val.contextToken = "Use Shrine of Transmutation (<color=#" + colorHexString + ">1 It</color><color=#" + colorHexString2 + ">em</color><color=#" + colorHexString3 + ">(s)</color><style=cIsDamage>)";
			val.NetworkdisplayNameToken = "Shrine of Transmutation (<color=#" + colorHexString + ">1 It</color><color=#" + colorHexString2 + ">em</color><color=#" + colorHexString3 + ">(s)</color><style=cIsDamage>)";
			shrineOfTransmutationManager.purchaseInteraction = val;
			shrineOfTransmutation.GetComponent<Highlight>().targetRenderer = (Renderer)(object)shrineOfTransmutation.GetComponentInChildren<MeshRenderer>();
			((Component)shrineOfTransmutation.transform.GetChild(0)).gameObject.AddComponent<EntityLocator>().entity = shrineOfTransmutation;
			InteractableSpawnCard val2 = ScriptableObject.CreateInstance<InteractableSpawnCard>();
			((Object)val2).name = "iscShrineOfTransmutation";
			((SpawnCard)val2).prefab = shrineOfTransmutation;
			((SpawnCard)val2).sendOverNetwork = true;
			((SpawnCard)val2).hullSize = (HullClassification)1;
			((SpawnCard)val2).nodeGraphType = (GraphType)0;
			((SpawnCard)val2).requiredFlags = (NodeFlags)0;
			((SpawnCard)val2).forbiddenFlags = (NodeFlags)16;
			((SpawnCard)val2).directorCreditCost = 5;
			((SpawnCard)val2).occupyPosition = true;
			val2.orientToFloor = false;
			val2.skipSpawnWhenSacrificeArtifactEnabled = false;
			DirectorCard card = new DirectorCard
			{
				selectionWeight = 10,
				spawnCard = (SpawnCard)(object)val2
			};
			DirectorCardHolder val3 = new DirectorCardHolder
			{
				Card = card,
				InteractableCategory = (InteractableCategory)4
			};
			Helpers.AddNewInteractable(val3);
			importantAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IMPORTANT", true, "Everyone needs to have the same options for multiplayer. You can change these settings while playing, but don't try that in multiplayer.");
			chanceToDestroyItem = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable item destruction at tier 1", true, "Toggle for if items should have a chance to be destroyed.");
			canDestroyAtAllTiers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable item destruction at all tiers", false, "Toggle for if items should have a chance to be destroyed at all tiers. 'Enable item destruction at tier 1' must be toggled to true for this to work.");
			chanceToDowngradeItem = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable item downgrading", true, "Toggle for if items should have a chance to be downgraded.");
			chanceToUpgradeItem = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable item upgrading", true, "Toggle for if items should have a chance to be upgraded.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(importantAlert));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(chanceToDestroyItem));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(canDestroyAtAllTiers, new CheckBoxConfig
			{
				checkIfDisabled = new IsDisabledDelegate(Check)
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(chanceToDowngradeItem));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(chanceToUpgradeItem));
			ModSettingsManager.SetModDescription("Shrine that lets you reroll white, green, and red items. With a chance to upgrade them, downgrade them, or even destroy them!");
			ModSettingsManager.SetModIcon(logo);
		}

		private bool Check()
		{
			return !chanceToDestroyItem.Value;
		}
	}
	public class ShrineOfTransmutationManager : NetworkBehaviour
	{
		public PurchaseInteraction purchaseInteraction;

		private GameObject shrineUseEffect = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/ShrineUseEffect.prefab").WaitForCompletion();

		private Xoroshiro128Plus rng;

		public PickupIndex dropPickup;

		public Transform dropTransform;

		public float dropUpVelocityStrength = 20f;

		public float dropForwardVelocityStrength = 2.5f;

		private CostTypeIndex currentCostType;

		private ItemDef takenItem;

		public void Start()
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance))
			{
				purchaseInteraction.SetAvailable(true);
			}
			purchaseInteraction.ShouldShowOnScanner();
			((UnityEvent<Interactor>)(object)purchaseInteraction.onPurchase).AddListener((UnityAction<Interactor>)OnPurchase);
		}

		public void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0028: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			rng = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong);
			dropTransform = ((Component)this).transform;
			dropPickup = PickupIndex.none;
			currentCostType = (CostTypeIndex)0;
		}

		[Server]
		public void OnPurchase(Interactor interactor)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'ShrineOfTransmutationManager::OnPurchase(RoR2.Interactor)' called on client");
			}
			else if (CanBeAffordedByInteractor(interactor))
			{
				purchaseInteraction.SetAvailable(false);
				EffectManager.SpawnEffect(shrineUseEffect, new EffectData
				{
					origin = ((Component)this).gameObject.transform.position,
					rotation = Quaternion.identity,
					scale = 3f,
					color = Color32.op_Implicit(Color.cyan)
				}, true);
				CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
				CostTypeDef val = RandomizeCostType(interactor);
				ItemIndex val2 = (ItemIndex)(-1);
				PayCostResults val3 = val.PayCost(1, interactor, ((Component)this).gameObject, rng, val2);
				CreateItemTakenOrb(component.corePosition, ((Component)this).gameObject, val3.itemsTaken[0]);
				takenItem = ItemCatalog.GetItemDef(val3.itemsTaken[0]);
				((MonoBehaviour)this).StartCoroutine(Delay());
			}
		}

		[Server]
		private IEnumerator Delay()
		{
			yield return (object)new WaitForSeconds(1.5f);
			ItemDrop();
			purchaseInteraction.SetAvailable(true);
		}

		public PickupIndex RollDrop()
		{
			//IL_0013: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Expected O, but got Unknown
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Expected O, but got Unknown
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0886: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: Expected O, but got Unknown
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Expected O, but got Unknown
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0805: Expected O, but got Unknown
			//IL_084f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Expected O, but got Unknown
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_075a: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Expected O, but got Unknown
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Expected O, but got Unknown
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Expected O, but got Unknown
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Expected O, but got Unknown
			int num = rng.RangeInt(1, 1001);
			PickupIndex result = PickupIndex.none;
			int num2 = 50;
			int num3 = 150;
			int num4 = 200;
			int num5 = 100;
			int num6 = 300;
			List<PickupIndex> availableTier1DropList = Run.instance.availableTier1DropList;
			List<PickupIndex> availableTier2DropList = Run.instance.availableTier2DropList;
			List<PickupIndex> availableTier3DropList = Run.instance.availableTier3DropList;
			string colorHexString = ColorCatalog.GetColorHexString((ColorIndex)1);
			string colorHexString2 = ColorCatalog.GetColorHexString((ColorIndex)2);
			string colorHexString3 = ColorCatalog.GetColorHexString((ColorIndex)3);
			if (!ShrineOfTransmutation.chanceToDestroyItem.Value)
			{
				num2 = 0;
			}
			if (!ShrineOfTransmutation.chanceToDowngradeItem.Value)
			{
				num4 = 0;
				num6 = 0;
			}
			if (!ShrineOfTransmutation.chanceToUpgradeItem.Value)
			{
				num3 = 0;
				num5 = 0;
			}
			if (((object)(CostTypeIndex)(ref currentCostType)).Equals((object)(CostTypeIndex)4))
			{
				if (num <= num2)
				{
					SimpleChatMessage val = new SimpleChatMessage();
					val.baseToken = "<style=cEvent><color=#307FFF>Destroyed </color><color=#" + colorHexString + ">" + Language.GetString(takenItem.nameToken) + "</color></style>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val);
				}
				else if (num >= 1001 - num3)
				{
					result = availableTier2DropList[rng.RangeInt(0, availableTier2DropList.Count)];
					SimpleChatMessage val = new SimpleChatMessage();
					val.baseToken = "<style=cEvent><color=#307FFF>Upgraded </color><color=#" + colorHexString + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString2 + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val);
				}
				else
				{
					result = availableTier1DropList[rng.RangeInt(0, availableTier1DropList.Count)];
					SimpleChatMessage val = new SimpleChatMessage();
					val.baseToken = "<style=cEvent><color=#307FFF>Rerolled </color><color=#" + colorHexString + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val);
				}
			}
			else if (((object)(CostTypeIndex)(ref currentCostType)).Equals((object)(CostTypeIndex)5))
			{
				if (num <= num4)
				{
					result = availableTier1DropList[rng.RangeInt(0, availableTier1DropList.Count)];
					SimpleChatMessage val = new SimpleChatMessage();
					val.baseToken = "<style=cEvent><color=#307FFF>Downgraded </color><color=#" + colorHexString2 + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val);
				}
				else if (num >= 1001 - num5)
				{
					result = availableTier3DropList[rng.RangeInt(0, availableTier3DropList.Count)];
					SimpleChatMessage val = new SimpleChatMessage();
					val.baseToken = "<style=cEvent><color=#307FFF>Upgraded </color><color=#" + colorHexString2 + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString3 + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val);
				}
				else if (ShrineOfTransmutation.canDestroyAtAllTiers.Value)
				{
					if (num <= num4 + num2)
					{
						SimpleChatMessage val = new SimpleChatMessage();
						val.baseToken = "<style=cEvent><color=#307FFF>Destroyed </color><color=#" + colorHexString2 + ">" + Language.GetString(takenItem.nameToken) + "</color></style>";
						Chat.SendBroadcastChat((ChatMessageBase)(object)val);
					}
					else
					{
						result = availableTier2DropList[rng.RangeInt(0, availableTier2DropList.Count)];
						SimpleChatMessage val = new SimpleChatMessage();
						val.baseToken = "<style=cEvent><color=#307FFF>Rerolled </color><color=#" + colorHexString2 + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString2 + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
						Chat.SendBroadcastChat((ChatMessageBase)(object)val);
					}
				}
				else
				{
					result = availableTier2DropList[rng.RangeInt(0, availableTier2DropList.Count)];
					SimpleChatMessage val = new SimpleChatMessage();
					val.baseToken = "<style=cEvent><color=#307FFF>Rerolled </color><color=#" + colorHexString2 + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString2 + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val);
				}
			}
			else if (((object)(CostTypeIndex)(ref currentCostType)).Equals((object)(CostTypeIndex)6))
			{
				if (num <= num6)
				{
					result = availableTier2DropList[rng.RangeInt(0, availableTier2DropList.Count)];
					SimpleChatMessage val = new SimpleChatMessage();
					val.baseToken = "<style=cEvent><color=#307FFF>Downgraded </color><color=#" + colorHexString3 + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString2 + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val);
				}
				else if (ShrineOfTransmutation.canDestroyAtAllTiers.Value)
				{
					if (num <= num6 + num2)
					{
						SimpleChatMessage val = new SimpleChatMessage();
						val.baseToken = "<style=cEvent><color=#307FFF>Destroyed </color><color=#" + colorHexString3 + ">" + Language.GetString(takenItem.nameToken) + "</color></style>";
						Chat.SendBroadcastChat((ChatMessageBase)(object)val);
					}
					else
					{
						result = availableTier3DropList[rng.RangeInt(0, availableTier3DropList.Count)];
						SimpleChatMessage val = new SimpleChatMessage();
						val.baseToken = "<style=cEvent><color=#307FFF>Rerolled </color><color=#" + colorHexString3 + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString3 + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
						Chat.SendBroadcastChat((ChatMessageBase)(object)val);
					}
				}
				else
				{
					result = availableTier3DropList[rng.RangeInt(0, availableTier3DropList.Count)];
					SimpleChatMessage val = new SimpleChatMessage();
					val.baseToken = "<style=cEvent><color=#307FFF>Rerolled </color><color=#" + colorHexString3 + ">" + Language.GetString(takenItem.nameToken) + "</color><color=#307FFF> to </color><color=#" + colorHexString3 + ">" + Language.GetString(ItemCatalog.GetItemDef(((PickupIndex)(ref result)).itemIndex).nameToken) + "</color></style>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val);
				}
			}
			return result;
		}

		[Server]
		public void ItemDrop()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'System.Void RoR2.ChestBehavior::ItemDrop()' called on client");
			}
			dropPickup = RollDrop();
			if (dropPickup != PickupIndex.none)
			{
				float num = 360f;
				Vector3 val = Vector3.up * dropUpVelocityStrength + dropTransform.forward * dropForwardVelocityStrength;
				Quaternion val2 = Quaternion.AngleAxis(num, Vector3.up);
				PickupDropletController.CreatePickupDroplet(dropPickup, dropTransform.position + Vector3.up * 1.5f, val);
				val = val2 * val;
				dropPickup = PickupIndex.none;
			}
			currentCostType = (CostTypeIndex)0;
		}

		public bool CanBeAffordedByInteractor(Interactor activator)
		{
			if (CostTypeCatalog.GetCostTypeDef((CostTypeIndex)4).IsAffordable(1, activator))
			{
				return true;
			}
			if (CostTypeCatalog.GetCostTypeDef((CostTypeIndex)5).IsAffordable(1, activator))
			{
				return true;
			}
			if (CostTypeCatalog.GetCostTypeDef((CostTypeIndex)6).IsAffordable(1, activator))
			{
				return true;
			}
			return false;
		}

		public CostTypeIndex PickRandomTier(Interactor activator, CostTypeIndex costType)
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
			int totalItemCountOfTier = component.inventory.GetTotalItemCountOfTier((ItemTier)0);
			int totalItemCountOfTier2 = component.inventory.GetTotalItemCountOfTier((ItemTier)1);
			int totalItemCountOfTier3 = component.inventory.GetTotalItemCountOfTier((ItemTier)2);
			int num = totalItemCountOfTier + totalItemCountOfTier2 + totalItemCountOfTier3;
			if (Object.op_Implicit((Object)(object)component.inventory))
			{
				if (totalItemCountOfTier > 0)
				{
					flag = true;
				}
				if (totalItemCountOfTier2 > 0)
				{
					flag2 = true;
				}
				if (totalItemCountOfTier3 > 0)
				{
					flag3 = true;
				}
				int num2 = rng.RangeInt(0, num);
				if (num2 < totalItemCountOfTier && flag)
				{
					costType = (CostTypeIndex)4;
				}
				else if (num2 >= num - totalItemCountOfTier3 && flag3)
				{
					costType = (CostTypeIndex)6;
				}
				else if (flag2)
				{
					costType = (CostTypeIndex)5;
				}
			}
			return costType;
		}

		public bool CanScrapBeUsed(Interactor activator)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			bool flag4 = false;
			CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
			ItemIndex val = ItemCatalog.FindItemIndex("ScrapWhite");
			ItemIndex val2 = ItemCatalog.FindItemIndex("ScrapGreen");
			ItemIndex val3 = ItemCatalog.FindItemIndex("ScrapRed");
			ItemIndex val4 = ItemCatalog.FindItemIndex("RegeneratingScrap");
			if (Object.op_Implicit((Object)(object)component.inventory))
			{
				if (component.inventory.GetItemCount(val) > 0)
				{
					flag = true;
				}
				if (component.inventory.GetItemCount(val2) > 0)
				{
					flag2 = true;
				}
				if (component.inventory.GetItemCount(val3) > 0)
				{
					flag3 = true;
				}
				if (component.inventory.GetItemCount(val4) > 0)
				{
					flag4 = true;
				}
			}
			return flag || flag2 || flag3 || flag4;
		}

		public CostTypeIndex PickRandomScrap(Interactor activator)
		{
			//IL_0013: 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_001f: 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_0030: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
			ItemIndex val = ItemCatalog.FindItemIndex("ScrapWhite");
			ItemIndex val2 = ItemCatalog.FindItemIndex("ScrapGreen");
			ItemIndex val3 = ItemCatalog.FindItemIndex("ScrapRed");
			ItemIndex val4 = ItemCatalog.FindItemIndex("RegeneratingScrap");
			int itemCount = component.inventory.GetItemCount(val);
			int itemCount2 = component.inventory.GetItemCount(val2);
			int itemCount3 = component.inventory.GetItemCount(val3);
			int itemCount4 = component.inventory.GetItemCount(val4);
			int num = itemCount + itemCount2 + itemCount3;
			if (Object.op_Implicit((Object)(object)component.inventory))
			{
				if (itemCount > 0)
				{
					flag = true;
				}
				if (itemCount2 > 0)
				{
					flag2 = true;
				}
				if (itemCount3 > 0)
				{
					flag3 = true;
				}
				if (itemCount4 > 0)
				{
					return (CostTypeIndex)5;
				}
				int num2 = rng.RangeInt(0, num);
				if (num2 < itemCount && flag)
				{
					return (CostTypeIndex)4;
				}
				if (num2 >= num - itemCount3 && flag3)
				{
					return (CostTypeIndex)6;
				}
				if (flag2)
				{
					return (CostTypeIndex)5;
				}
				return (CostTypeIndex)0;
			}
			return (CostTypeIndex)0;
		}

		public CostTypeDef RandomizeCostType(Interactor activator)
		{
			//IL_0002: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			CostTypeIndex costType = (CostTypeIndex)0;
			return CostTypeCatalog.GetCostTypeDef(currentCostType = ((!CanScrapBeUsed(activator)) ? PickRandomTier(activator, costType) : PickRandomScrap(activator)));
		}

		[Server]
		public static void CreateItemTakenOrb(Vector3 effectOrigin, GameObject targetObject, ItemIndex itemIndex)
		{
			//IL_0026: 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_002c: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0047: Expected I4, but got Unknown
			//IL_0048: Expected O, but got Unknown
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'System.Void RoR2.PurchaseInteraction::CreateItemTakenOrb(UnityEngine.Vector3,UnityEngine.GameObject,RoR2.ItemIndex)' called on client");
				return;
			}
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/OrbEffects/ItemTakenOrbEffect");
			EffectData val2 = new EffectData
			{
				origin = effectOrigin,
				genericFloat = 1.5f,
				genericUInt = (uint)(itemIndex + 1)
			};
			val2.SetNetworkedObjectReference(targetObject);
			EffectManager.SpawnEffect(val, val2, true);
		}
	}
}