Decompiled source of ForceEulogy v1.1.1

ForceEulogy.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.IO;
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 Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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("ForceEulogy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ForceEulogy")]
[assembly: AssemblyTitle("ForceEulogy")]
[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 PodRacing
{
	[BepInPlugin("RiskOfResources.ForceEulogy", "ForceEulogy", "1.1.1")]
	public class ForceEulogy : BaseUnityPlugin
	{
		public enum BooleanChoice
		{
			True,
			False
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnDestroy <>9__19_2;

			internal void <Awake>b__19_2(orig_OnDestroy orig, Run self)
			{
				orig.Invoke(self);
				podRacingEnabled = false;
			}
		}

		public const string PluginGUID = "RiskOfResources.ForceEulogy";

		public const string PluginAuthor = "RiskOfResources";

		public const string PluginName = "ForceEulogy";

		public const string PluginVersion = "1.1.1";

		public static ArtifactDef podRacing = ScriptableObject.CreateInstance<ArtifactDef>();

		public static bool podRacingEnabled = false;

		public static AssetBundle assets;

		public static Sprite artifactOnIcon;

		public static Sprite artifactOffIcon;

		public ItemDef beads = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/Base/LunarTrinket/LunarTrinket.asset").WaitForCompletion();

		public ItemDef eulogy = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/DLC1/RandomlyLunar/RandomlyLunar.asset").WaitForCompletion();

		public static ConfigEntry<int> amount { get; set; }

		public static ConfigEntry<BooleanChoice> removeFromPool { get; set; }

		public void Awake()
		{
			//IL_002a: 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_0075: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_009c: 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_00a7: Expected O, but got Unknown
			InitConfig();
			LoadSprites();
			DefineArtifact();
			eulogy.tier = (ItemTier)5;
			eulogy.deprecatedTier = (ItemTier)5;
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				ModSettingsManager.AddOption((BaseOption)new IntSliderOption(amount));
				ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)removeFromPool));
			}
			Run.Start += (hook_Start)delegate(orig_Start orig, Run self)
			{
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: 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)
				orig.Invoke(self);
				podRacingEnabled = RunArtifactManager.instance.IsArtifactEnabled(podRacing);
				if (podRacingEnabled)
				{
					eulogy.tier = (ItemTier)5;
					eulogy.deprecatedTier = (ItemTier)5;
					PlayerCharacterMasterController._instances[0].master.inventory.GiveItem(eulogy.itemIndex, amount.Value);
				}
				ItemDef itemDef = ItemCatalog.GetItemDef(eulogy.itemIndex);
			};
			Run.RefreshLunarCombinedDropList += (hook_RefreshLunarCombinedDropList)delegate(orig_RefreshLunarCombinedDropList orig, Run self)
			{
				//IL_003f: 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_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: 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_006e: 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_0088: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self);
				podRacingEnabled = RunArtifactManager.instance.IsArtifactEnabled(podRacing);
				if (podRacingEnabled && removeFromPool.Value == BooleanChoice.True)
				{
					PickupIndex item = PickupCatalog.FindPickupIndex(eulogy.itemIndex);
					PickupIndex item2 = PickupCatalog.FindPickupIndex(beads.itemIndex);
					self.availableLunarItemDropList.Remove(item);
					self.availableLunarItemDropList.Remove(item2);
					self.availableLunarCombinedDropList.Remove(item);
					self.availableLunarCombinedDropList.Remove(item2);
				}
			};
			object obj = <>c.<>9__19_2;
			if (obj == null)
			{
				hook_OnDestroy val = delegate(orig_OnDestroy orig, Run self)
				{
					orig.Invoke(self);
					podRacingEnabled = false;
				};
				<>c.<>9__19_2 = val;
				obj = (object)val;
			}
			Run.OnDestroy += (hook_OnDestroy)obj;
		}

		public void InitConfig()
		{
			amount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Amount", 2, "The amount of Eulogy Zero to insert into the player's inventory on run start.");
			removeFromPool = ((BaseUnityPlugin)this).Config.Bind<BooleanChoice>("General", "Remove Eulogy", BooleanChoice.True, "Set to true to remove Eulogy Zero from the list of available lunars.");
		}

		public void LoadSprites()
		{
			assets = AssetBundle.LoadFromFile(Path.Combine(Paths.PluginPath, "RiskOfResources-ForceEulogy/artifactofpower"));
			artifactOnIcon = assets.LoadAsset<Sprite>("artifactOn.png");
			artifactOffIcon = assets.LoadAsset<Sprite>("artifactOff.png");
		}

		public void DefineArtifact()
		{
			podRacing.cachedName = "Artifact of Power";
			podRacing.nameToken = "Artifact of Power";
			podRacing.descriptionToken = "Converts a percentage of items in a run to lunar items.";
			podRacing.smallIconSelectedSprite = artifactOnIcon;
			podRacing.smallIconDeselectedSprite = artifactOffIcon;
			podRacing.pickupModelPrefab = LegacyResourcesAPI.Load<ArtifactDef>("artifactdefs/MixEnemy").pickupModelPrefab;
			ContentAddition.AddArtifactDef(podRacing);
		}
	}
}