Decompiled source of CrackedEggmoji v1.0.0

CrackedEggmoji.dll

Decompiled 3 weeks 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 IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2BepInExPack.GameAssetPaths;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CrackedEggmoji")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cb27a894ebb0af5bcad39600a894c79a71af207e")]
[assembly: AssemblyProduct("CrackedEggmoji")]
[assembly: AssemblyTitle("CrackedEggmoji")]
[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 ExamplePlugin
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("icebro.CrackedEggmoji", "CrackedEggmoji", "1.0.0")]
	public class CrackedEggmoji : BaseUnityPlugin
	{
		private enum interactable
		{
			drones,
			chests,
			barrels
		}

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

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

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

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

			public static Manipulator <>9__5_0;

			internal void <Awake>b__5_0(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				ILCursor val = new ILCursor(il);
				ILLabel val2 = default(ILLabel);
				if (val.TryGotoNext(new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "RoR2.InteractableSpawnCard", "skipSpawnWhenDevotionArtifactEnabled"),
					(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val2),
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0)
				}))
				{
					val.Index -= 7;
					val.RemoveRange(12);
				}
				else
				{
					Log.Error(((MemberReference)il.Method).Name + " IL Hook failed!");
				}
			}

			internal bool <Awake>b__5_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdfld(x, "RoR2.InteractableSpawnCard", "skipSpawnWhenDevotionArtifactEnabled");
			}

			internal bool <Awake>b__5_3(Instruction x)
			{
				ILLabel val = default(ILLabel);
				return ILPatternMatchingExt.MatchBrfalse(x, ref val);
			}

			internal bool <Awake>b__5_4(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdarg(x, 0);
			}
		}

		public const string PluginGUID = "icebro.CrackedEggmoji";

		public const string PluginAuthor = "icebro";

		public const string PluginName = "CrackedEggmoji";

		public const string PluginVersion = "1.0.0";

		public void Awake()
		{
			//IL_0019: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_004b: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			InteractableSpawnCard iscard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)RoR2_CU8_LemurianEgg.iscLemurianEgg_asset).WaitForCompletion();
			DirectorCard directorCard = new DirectorCard
			{
				selectionWeight = 35,
				spawnCard = (SpawnCard)(object)iscard
			};
			DirectorCardHolder directorCardHolder = new DirectorCardHolder
			{
				Card = directorCard,
				InteractableCategory = (InteractableCategory)5
			};
			ConfigEntry<int> egglimit = ((BaseUnityPlugin)this).Config.Bind<int>("Egg behavior", "Egg limit", 5, "max amount of eggs that can spawn in a stage with devotion enabled,.,.");
			IntSliderConfig val = new IntSliderConfig();
			val.max = 20;
			val.min = 1;
			val.formatString = "{0:0}";
			IntSliderOption val2 = new IntSliderOption(egglimit, val);
			ModSettingsManager.AddOption((BaseOption)(object)val2);
			ConfigEntry<int> eggweight = ((BaseUnityPlugin)this).Config.Bind<int>("Egg behavior", "Egg weight", 35, "selection weight of lemurian eggs (they dont have one in vanilla so umm this is just a guess !!! heigher = more common ,., lower = less ,,,,");
			IntSliderConfig val3 = new IntSliderConfig();
			val3.max = 350;
			val3.min = 1;
			val3.formatString = "{0:0}";
			IntSliderOption val4 = new IntSliderOption(eggweight, val3);
			ModSettingsManager.AddOption((BaseOption)(object)val4);
			ConfigEntry<int> eggcost = ((BaseUnityPlugin)this).Config.Bind<int>("Egg behavior", "Egg cost", 15, "director credit cost for egg ,.,. how many it should gobble up !!");
			IntSliderConfig val5 = new IntSliderConfig();
			val5.max = 150;
			val5.min = 1;
			val5.formatString = "{0:0}";
			IntSliderOption val6 = new IntSliderOption(eggcost, val5);
			ModSettingsManager.AddOption((BaseOption)(object)val6);
			ConfigEntry<interactable> interctablecategory = ((BaseUnityPlugin)this).Config.Bind<interactable>("Egg behavior", "director interactable category", interactable.drones, "sets what interactable category to use !!");
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)interctablecategory));
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				Manipulator val7 = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					ILCursor val9 = new ILCursor(il);
					ILLabel val10 = default(ILLabel);
					if (val9.TryGotoNext(new Func<Instruction, bool>[3]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "RoR2.InteractableSpawnCard", "skipSpawnWhenDevotionArtifactEnabled"),
						(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val10),
						(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0)
					}))
					{
						val9.Index -= 7;
						val9.RemoveRange(12);
					}
					else
					{
						Log.Error(((MemberReference)il.Method).Name + " IL Hook failed!");
					}
				};
				<>c.<>9__5_0 = val7;
				obj = (object)val7;
			}
			SceneDirector.PopulateScene += (Manipulator)obj;
			Run.Start += (hook_Start)delegate(orig_Start orig, Run self)
			{
				//IL_00a2: 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_00aa: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				Helpers.RemoveExistingInteractable(((Object)iscard).name);
				if (RunArtifactManager.instance.IsArtifactEnabled(Artifacts.Devotion))
				{
					Log.Debug("user has devotion enabled !! adding egg to director ,.,");
					((SpawnCard)iscard).directorCreditCost = eggcost.Value;
					iscard.maxSpawnsPerStage = egglimit.Value;
					directorCard.selectionWeight = eggweight.Value;
					DirectorCardHolder val8 = directorCardHolder;
					interactable value = interctablecategory.Value;
					if (1 == 0)
					{
					}
					InteractableCategory interactableCategory = (InteractableCategory)(value switch
					{
						interactable.drones => 5, 
						interactable.chests => 2, 
						interactable.barrels => 3, 
						_ => directorCardHolder.InteractableCategory, 
					});
					if (1 == 0)
					{
					}
					val8.InteractableCategory = interactableCategory;
					Helpers.AddNewInteractable(directorCardHolder);
					Log.Debug(directorCard.selectionWeight + " weight !!");
					Log.Debug(iscard.maxSpawnsPerStage + " cap !!");
				}
				else
				{
					iscard.maxSpawnsPerStage = 0;
				}
				orig.Invoke(self);
			};
		}
	}
	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);
		}
	}
}