Decompiled source of MoreAcceptableScrappers v1.0.0

plugins/MoreAcceptableScrappers/MoreAcceptableScrappers.dll

Decompiled 2 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 EntityStates.Scrapper;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using R2API.Utils;
using RoR2;
using RoR2.UI;
using UnityEngine;

[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("MoreAcceptableScrappers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a6e1e7dd1714b12db6ee8544bcac396d46866bb7")]
[assembly: AssemblyProduct("MoreAcceptableScrappers")]
[assembly: AssemblyTitle("MoreAcceptableScrappers")]
[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;
		}
	}
}
[BepInPlugin("MoreAcceptableScrappers", "More Acceptable Scrappers", "1.0.0")]
public class MoreAcceptableScrappers : BaseUnityPlugin
{
	private static PickupPickerPanel currentPanel;

	public void Awake()
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Expected O, but got Unknown
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Expected O, but got Unknown
		ConfigEntry<float> scrapperDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Scrapper Delay", 0.2f, "Scrapper delay in seconds.");
		ConfigEntry<float> scrapperAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Amount of Scrappers", 2f, "The amount of guaranteed scrappers per map (max 100 - to prevent lag on your end).");
		ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Disable Escape Leaving Scrappers", false, "Disable escape causing the scrappers to exit.  Disable this if using BetterUI.");
		if (!val.Value)
		{
			PickupPickerPanel.Awake += new hook_Awake(PickupPickerPanel_Awake);
		}
		if (scrapperAmount.Value > 100f)
		{
			scrapperAmount.Value = 100f;
		}
		if (scrapperAmount.Value <= 0f)
		{
			scrapperAmount.Value = 1f;
		}
		SceneDirector.PlaceTeleporter += (hook_PlaceTeleporter)delegate(orig_PlaceTeleporter orig, SceneDirector self)
		{
			orig.Invoke(self);
			for (int i = 0; (float)i < scrapperAmount.Value; i++)
			{
				SpawnScrapper(self);
			}
		};
		Stage.Start += (hook_Start)delegate(orig_Start orig, Stage self)
		{
			Reflection.SetFieldValue<float>(typeof(WaitToBeginScrapping), "duration", scrapperDelay.Value / 2f);
			Reflection.SetFieldValue<float>(typeof(Scrapping), "duration", scrapperDelay.Value / 2f);
			return orig.Invoke(self);
		};
	}

	private void SpawnScrapper(SceneDirector self)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_004b: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		if (SceneInfo.instance.countsAsStage)
		{
			SpawnCard val = Resources.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscScrapper");
			DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(val, new DirectorPlacementRule
			{
				placementMode = (PlacementMode)4
			}, new Xoroshiro128Plus(Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "rng").nextUlong)));
		}
	}

	private void PickupPickerPanel_Awake(orig_Awake orig, PickupPickerPanel self)
	{
		if (((Object)self).name.ToLower().Contains("scrapper"))
		{
			currentPanel = self;
		}
		orig.Invoke(self);
	}

	private void Update()
	{
		if (Object.op_Implicit((Object)(object)currentPanel) && Object.op_Implicit((Object)(object)((Component)currentPanel).gameObject) && (Input.GetKeyDown("escape") || Input.GetKeyDown("w") || Input.GetKeyDown("a") || Input.GetKeyDown("s") || Input.GetKeyDown("d")))
		{
			if (Input.GetKeyDown("escape"))
			{
				Console.instance.SubmitCmd((NetworkUser)null, "pause", false);
			}
			Object.Destroy((Object)(object)((Component)currentPanel).gameObject);
		}
	}
}