Decompiled source of GuaranteedScrapper v0.0.1

GuaranteedScrapper.dll

Decompiled 9 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 Microsoft.CodeAnalysis;
using On.RoR2;
using R2API.Utils;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("GuaranteedScrapper")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GuaranteedScrapper")]
[assembly: AssemblyTitle("GuaranteedScrapper")]
[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 GuaranteedScraper
{
	[BepInPlugin("Saeraphinx.GuaranteedScraper", "GuaranteedScraper", "0.0.1")]
	public class GuaranteedScrapper : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__4_0;

			internal void <Awake>b__4_0(orig_Awake orig, BazaarController self)
			{
				orig.Invoke(self);
			}
		}

		public bool canSpawn;

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

		public void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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
			//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_004a: Expected O, but got Unknown
			ScrapperAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "Scrapper Amount", 5, new ConfigDescription("Amount of scrappers to be spawned on each stage. (0 for vanilla spawn rate).", (AcceptableValueBase)null, Array.Empty<object>()));
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, BazaarController self)
				{
					orig.Invoke(self);
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			BazaarController.Awake += (hook_Awake)obj;
			SceneDirector.PlaceTeleporter += (hook_PlaceTeleporter)delegate(orig_PlaceTeleporter orig, SceneDirector self)
			{
				orig.Invoke(self);
				if (((ScrapperAmount.Value > 0 && ScrapperAmount.Value != 0) ? 1 : 0) > (false ? 1 : 0) && canSpawn)
				{
					for (int i = 0; i < ScrapperAmount.Value; i++)
					{
						SpawnScrapper(self);
					}
				}
			};
			SceneCatalog.onMostRecentSceneDefChanged += OnMostRecentSceneDefChanged;
		}

		public void SpawnScrapper(SceneDirector self)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0045: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			Xoroshiro128Plus val = new Xoroshiro128Plus(Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "rng").nextUlong);
			if (SceneInfo.instance.countsAsStage)
			{
				SpawnCard val2 = Resources.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscScrapper");
				DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(val2, new DirectorPlacementRule
				{
					placementMode = (PlacementMode)4
				}, val));
			}
		}

		public void OnMostRecentSceneDefChanged(SceneDef scene)
		{
			if (scene.cachedName == "moon2" || scene.cachedName == "bazaar")
			{
				canSpawn = false;
			}
			else
			{
				canSpawn = true;
			}
		}
	}
}