Decompiled source of StartEssence v1.0.1

StartEssence.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 BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;

[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("StartEssence")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StartEssence")]
[assembly: AssemblyTitle("StartEssence")]
[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 StartEssence
{
	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);
		}
	}
	[BepInPlugin("Jeffdev.StartEssence", "StartEssence", "1.0.0")]
	public class StartEssencePlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Jeffdev.StartEssence";

		public const string PluginAuthor = "Jeffdev";

		public const string PluginName = "StartEssence";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<string> essenceRarity;

		public static ConfigEntry<int> amountToSpawn;

		public string itemEssence;

		public void Awake()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			essenceRarity = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Essence Rarity", "Red", new ConfigDescription("What rarity should the Command Essence appear as?", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[9] { "White", "Green", "Red", "Lunar", "Boss", "VoidWhite", "VoidGreen", "VoidRed", "VoidBoss" }), Array.Empty<object>()));
			amountToSpawn = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Essence Amount", 1, "How much essence to spawn at the start of a run?");
			CharacterMaster.OnBodyStart += new hook_OnBodyStart(CharacterMaster_OnBodyStart);
		}

		private void CharacterMaster_OnBodyStart(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, body);
			if ((int)self.teamIndex == 1 && body.isPlayerControlled && (!Object.op_Implicit((Object)(object)SceneInfo.instance) || !Object.op_Implicit((Object)(object)SceneInfo.instance.sceneDef) || (int)SceneInfo.instance.sceneDef.sceneType != 2) && Object.op_Implicit((Object)(object)Run.instance) && Run.instance.stageClearCount == 0)
			{
				switch (essenceRarity.Value)
				{
				case "White":
					itemEssence = "Hoof";
					break;
				case "Green":
					itemEssence = "Feather";
					break;
				case "Red":
					itemEssence = "Behemoth";
					break;
				case "Lunar":
					itemEssence = "FocusConvergence";
					break;
				case "VoidWhite":
					itemEssence = "CritGlassesVoid";
					break;
				case "VoidGreen":
					itemEssence = "EquipmentMagazineVoid";
					break;
				case "VoidRed":
					itemEssence = "CloverVoid";
					break;
				case "VoidBoss":
					itemEssence = "VoidMegaCrabItem";
					break;
				case "Boss":
					itemEssence = "BeetleGland";
					break;
				}
				PickupIndex pickupIndex = PickupCatalog.FindPickupIndex(ItemCatalog.FindItemIndex(itemEssence));
				for (int i = 0; i < amountToSpawn.Value; i++)
				{
					CreatePickupInfo val = default(CreatePickupInfo);
					((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
					CreatePickupInfo val2 = val;
					Vector3 corePosition = body.corePosition;
					Vector3 aimDirection = body.inputBank.aimDirection;
					Vector3 val3 = corePosition + ((Vector3)(ref aimDirection)).normalized * 3f + Vector3.up * 1.5f;
					ref PickupArtifactFlag artifactFlag = ref val2.artifactFlag;
					artifactFlag = (PickupArtifactFlag)((uint)artifactFlag | 1u);
					PickupDropletController.CreatePickupDroplet(val2, val3, Vector3.up * 5f);
				}
			}
		}
	}
}