Decompiled source of TierSelector v1.4.0

TierSelector.dll

Decompiled 3 weeks ago
using System;
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 On.RoR2;
using RoR2;
using UnityEngine;
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("TierSelector")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TierSelector")]
[assembly: AssemblyTitle("TierSelector")]
[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 Toasted
{
	public static class Config
	{
		public enum ItemType
		{
			White,
			Green,
			Red,
			Boss,
			Lunar,
			Void
		}

		public static ConfigEntry<ItemType> selectedTier;

		public static bool IsInitialised;

		public static void Initialise(TierSelector selector)
		{
			if (!IsInitialised)
			{
				IsInitialised = true;
				selectedTier = ((BaseUnityPlugin)selector).Config.Bind<ItemType>("ItemSelector", "Selected Tier", ItemType.White, "Which tier you want (White = 0, Green = 1, Red = 2, Boss = 3, Lunar = 4, Void = 5.");
			}
		}
	}
	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("Vorkiblo.TierSelector", "TierSelector", "1.4.0")]
	public class TierSelector : BaseUnityPlugin
	{
		public const string PluginGUID = "Vorkiblo.TierSelector";

		public const string PluginAuthor = "Vorkiblo";

		public const string PluginName = "TierSelector";

		public const string PluginVersion = "1.4.0";

		public List<PickupIndex> currentLootTable;

		public CostTypeIndex currentCostType;

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			Run.BuildDropTable += new hook_BuildDropTable(Run_BuildDropTable);
			ChestBehavior.Roll += new hook_Roll(ChestBehavior_Roll);
			ShrineChanceBehavior.AddShrineStack += new hook_AddShrineStack(ShrineChanceBehavior_AddShrineStack);
			MultiShopController.CreateTerminals += new hook_CreateTerminals(MultiShopController_CreateTerminals);
			BossGroup.DropRewards += new hook_DropRewards(BossGroup_DropRewards);
			Config.Initialise(this);
		}

		private void BossGroup_DropRewards(orig_DropRewards orig, BossGroup self)
		{
			//IL_0021: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_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)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00d1: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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)
			int participatingPlayerCount = Run.instance.participatingPlayerCount;
			if (participatingPlayerCount == 0 || !Object.op_Implicit((Object)(object)self.dropPosition))
			{
				return;
			}
			PickupIndex none = PickupIndex.none;
			if (Object.op_Implicit((Object)(object)self.dropTable))
			{
				none = self.dropTable.GenerateDrop(self.rng);
			}
			else
			{
				List<PickupIndex> list = Run.instance.availableTier2DropList;
				if (self.forceTier3Reward)
				{
					list = Run.instance.availableTier3DropList;
				}
				none = self.rng.NextElementUniform<PickupIndex>(list);
			}
			int num = 1 + self.bonusRewardCount;
			if (self.scaleRewardsByPlayerCount)
			{
				num *= participatingPlayerCount;
			}
			float num2 = 360f / (float)num;
			Vector3 val = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f);
			Quaternion val2 = Quaternion.AngleAxis(num2, Vector3.up);
			int num3 = 0;
			while (num3 < num)
			{
				PickupIndex val3 = none;
				if ((self.bossDrops.Count > 0 || self.bossDropTables.Count > 0) && self.rng.nextNormalizedFloat <= self.bossDropChance)
				{
					val3 = ((self.bossDropTables.Count <= 0) ? self.rng.NextElementUniform<PickupIndex>(self.bossDrops) : self.rng.NextElementUniform<PickupDropTable>(self.bossDropTables).GenerateDrop(self.rng));
				}
				if (val3 != PickupIndex.none || !currentLootTable.Contains(val3))
				{
					val3 = currentLootTable[Random.Range(0, currentLootTable.Count)];
				}
				PickupDropletController.CreatePickupDroplet(val3, self.dropPosition.position, val);
				num3++;
				val = val2 * val;
			}
		}

		private void ShrineChanceBehavior_AddShrineStack(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00a6: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'System.Void RoR2.ShrineChanceBehavior::AddShrineStack(RoR2.Interactor)' called on client");
				return;
			}
			PickupIndex val = PickupIndex.none;
			if (Object.op_Implicit((Object)(object)self.dropTable))
			{
				if (self.rng.nextNormalizedFloat > self.failureChance)
				{
					val = self.dropTable.GenerateDrop(self.rng);
					if (val != PickupIndex.none || !currentLootTable.Contains(val))
					{
						val = currentLootTable[Random.Range(0, currentLootTable.Count)];
					}
				}
			}
			else
			{
				PickupIndex none = PickupIndex.none;
				PickupIndex val2 = self.rng.NextElementUniform<PickupIndex>(currentLootTable);
				WeightedSelection<PickupIndex> obj = new WeightedSelection<PickupIndex>(8);
				obj.AddChoice(none, self.failureWeight);
				obj.AddChoice(val2, self.tier3Weight);
				val = obj.Evaluate(self.rng.nextNormalizedFloat);
			}
			string baseToken;
			if (val == PickupIndex.none)
			{
				baseToken = "SHRINE_CHANCE_FAIL_MESSAGE";
			}
			else
			{
				baseToken = "SHRINE_CHANCE_SUCCESS_MESSAGE";
				self.successfulPurchaseCount++;
				PickupDropletController.CreatePickupDroplet(val, self.dropletOrigin.position, self.dropletOrigin.forward * 20f);
			}
			Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
			{
				subjectAsCharacterBody = ((Component)activator).GetComponent<CharacterBody>(),
				baseToken = baseToken
			});
			self.waitingForRefresh = true;
			self.refreshTimer = 2f;
			EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
			{
				origin = ((Component)this).transform.position,
				rotation = Quaternion.identity,
				scale = 1f,
				color = Color32.op_Implicit(self.colorShrineRewardNormal)
			}, true);
			if (self.successfulPurchaseCount >= self.maxPurchaseCount)
			{
				((Component)self.symbolTransform).gameObject.SetActive(false);
			}
		}

		private void MultiShopController_CreateTerminals(orig_CreateTerminals orig, MultiShopController self)
		{
			//IL_0078: 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)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			ShopTerminalBehavior[] array = Object.FindObjectsOfType<ShopTerminalBehavior>();
			foreach (ShopTerminalBehavior val in array)
			{
				if (((Object)((Component)val).gameObject).name.Contains("Duplicator"))
				{
					PurchaseInteraction[] components = ((Component)val).gameObject.GetComponents<PurchaseInteraction>();
					for (int j = 0; j < components.Length; j++)
					{
						components[j].costType = currentCostType;
					}
				}
				val.selfGeneratePickup = false;
				val.SetPickupIndex(currentLootTable[Random.Range(0, currentLootTable.Count)], false);
			}
		}

		private void ChestBehavior_Roll(orig_Roll orig, ChestBehavior self)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			self.dropPickup = currentLootTable[Random.Range(0, currentLootTable.Count)];
		}

		private void Run_BuildDropTable(orig_BuildDropTable orig, Run self)
		{
			orig.Invoke(self);
			SetupCurrentLootTables();
			self.smallChestDropTierSelector.Clear();
			self.smallChestDropTierSelector.AddChoice(currentLootTable, 1f);
			self.mediumChestDropTierSelector.Clear();
			self.mediumChestDropTierSelector.AddChoice(currentLootTable, 1f);
			self.largeChestDropTierSelector.Clear();
			self.largeChestDropTierSelector.AddChoice(currentLootTable, 1f);
		}

		private void SetupCurrentLootTables()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_00b5: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			currentLootTable = new List<PickupIndex>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Current selected tier is: " + Config.selectedTier.Value));
			if (Config.selectedTier.Value == Config.ItemType.White)
			{
				currentLootTable = Run.instance.availableTier1DropList;
				currentCostType = (CostTypeIndex)4;
			}
			if (Config.selectedTier.Value == Config.ItemType.Green)
			{
				currentLootTable = Run.instance.availableTier2DropList;
				currentCostType = (CostTypeIndex)5;
			}
			if (Config.selectedTier.Value == Config.ItemType.Red)
			{
				currentLootTable = Run.instance.availableTier3DropList;
				currentCostType = (CostTypeIndex)6;
			}
			if (Config.selectedTier.Value == Config.ItemType.Boss)
			{
				ItemIndex val = ItemCatalog.FindItemIndex("Pearl");
				ItemIndex val2 = ItemCatalog.FindItemIndex("ShinyPearl");
				ItemIndex val3 = ItemCatalog.FindItemIndex("TitanGoldDuringTP");
				currentLootTable = new List<PickupIndex>(Run.instance.availableBossDropList);
				currentLootTable.Add(new PickupIndex(val));
				currentLootTable.Add(new PickupIndex(val2));
				currentLootTable.Add(new PickupIndex(val3));
				currentCostType = (CostTypeIndex)10;
			}
			if (Config.selectedTier.Value == Config.ItemType.Lunar)
			{
				currentLootTable = Run.instance.availableLunarCombinedDropList;
				currentLootTable.AddRange(Run.instance.availableLunarEquipmentDropList);
				currentCostType = (CostTypeIndex)9;
			}
			if (Config.selectedTier.Value == Config.ItemType.Void)
			{
				currentLootTable = Run.instance.availableVoidTier1DropList;
				currentLootTable.AddRange(Run.instance.availableVoidTier2DropList);
				currentLootTable.AddRange(Run.instance.availableVoidTier3DropList);
				currentCostType = (CostTypeIndex)13;
			}
		}
	}
}