Decompiled source of Evolution Config v1.0.5

EvolutionConfig.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HG.Reflection;
using IL.RoR2.Artifacts;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using RoR2.Artifacts;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EvolutionConfig")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+069c0d21730ea3e0fef807820cf55016f03131cc")]
[assembly: AssemblyProduct("EvolutionConfig")]
[assembly: AssemblyTitle("EvolutionConfig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}
namespace EvolutionConfig
{
	[BepInPlugin("com.Moffein.EvolutionConfig", "Evolution Config", "1.0.5")]
	public class EvolutionConfig : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Instruction, bool> <>9__4_1;

			public static Func<int, PickupDef, int> <>9__4_2;

			public static Manipulator <>9__4_0;

			internal void <Awake>b__4_0(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				val.GotoNext(new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GiveItem")
				});
				val.Emit(OpCodes.Ldloc_2);
				val.EmitDelegate<Func<int, PickupDef, int>>((Func<int, PickupDef, int>)delegate(int itemCount, PickupDef pickup)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_0009: 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_0034: Expected I4, but got Unknown
					ItemTier itemTier = pickup.itemTier;
					ItemTier val2 = itemTier;
					switch ((int)val2)
					{
					case 0:
					case 6:
						return whiteCount;
					case 1:
					case 7:
						return greenCount;
					case 2:
					case 8:
						return redCount;
					default:
						return itemCount;
					}
				});
			}

			internal bool <Awake>b__4_1(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GiveItem");
			}

			internal int <Awake>b__4_2(int itemCount, PickupDef pickup)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: 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_0034: Expected I4, but got Unknown
				ItemTier itemTier = pickup.itemTier;
				ItemTier val = itemTier;
				switch ((int)val)
				{
				case 0:
				case 6:
					return whiteCount;
				case 1:
				case 7:
					return greenCount;
				case 2:
				case 8:
					return redCount;
				default:
					return itemCount;
				}
			}
		}

		public static int whiteCount = 1;

		public static int greenCount = 1;

		public static int redCount = 1;

		private void ReadConfig()
		{
			whiteCount = ((BaseUnityPlugin)this).Config.Bind<int>("Item Counts", "Common", 1, "How many items of this tier to grant.").Value;
			greenCount = ((BaseUnityPlugin)this).Config.Bind<int>("Item Counts", "Uncommon", 1, "How many items of this tier to grant.").Value;
			redCount = ((BaseUnityPlugin)this).Config.Bind<int>("Item Counts", "Legendary", 1, "How many items of this tier to grant.").Value;
		}

		public void Awake()
		{
			//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: Expected O, but got Unknown
			ReadConfig();
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				Manipulator val = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					//IL_0038: Unknown result type (might be due to invalid IL or missing references)
					ILCursor val2 = new ILCursor(il);
					val2.GotoNext(new Func<Instruction, bool>[1]
					{
						(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GiveItem")
					});
					val2.Emit(OpCodes.Ldloc_2);
					val2.EmitDelegate<Func<int, PickupDef, int>>((Func<int, PickupDef, int>)delegate(int itemCount, PickupDef pickup)
					{
						//IL_0002: Unknown result type (might be due to invalid IL or missing references)
						//IL_0007: Unknown result type (might be due to invalid IL or missing references)
						//IL_0008: Unknown result type (might be due to invalid IL or missing references)
						//IL_0009: 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_0034: Expected I4, but got Unknown
						ItemTier itemTier = pickup.itemTier;
						ItemTier val3 = itemTier;
						switch ((int)val3)
						{
						case 0:
						case 6:
							return whiteCount;
						case 1:
						case 7:
							return greenCount;
						case 2:
						case 8:
							return redCount;
						default:
							return itemCount;
						}
					});
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			MonsterTeamGainsItemsArtifactManager.GrantMonsterTeamItem += (Manipulator)obj;
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		public static void EvolutionConfig_GrantItems(ConCommandArgs args)
		{
			string itemName = ((ConCommandArgs)(ref args)).TryGetArgString(0);
			if (((ConCommandArgs)(ref args)).Count >= 2)
			{
				int? num = ((ConCommandArgs)(ref args)).TryGetArgInt(1);
				if (num.HasValue)
				{
					GrantMonsterTeamItem(itemName, num.Value);
					return;
				}
			}
			GrantMonsterTeamItem(itemName);
		}

		public static void GrantMonsterTeamItem(string itemName, int count = 1)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			ItemIndex val = ItemCatalog.FindItemIndex(itemName);
			if ((int)val != -1)
			{
				MonsterTeamGainsItemsArtifactManager.monsterTeamInventory.GiveItem(val, count);
			}
			else
			{
				Debug.LogError((object)"Item not found. If you have DebugToolkit installed, type list_item to view a list of all internal item names. You must enter the item name exactly as it appears in the list.");
			}
		}

		public static void GrantMonsterTeamItem(ItemIndex itemIndex, int count)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			MonsterTeamGainsItemsArtifactManager.monsterTeamInventory.GiveItem(itemIndex, count);
		}
	}
}