Decompiled source of OutOfBoundsItemsFix v1.0.1

OutOfBoundsItemsFix.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2;
using RoR2;
using RoR2.Navigation;
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 = "")]
[assembly: AssemblyCompany("OutOfBoundsItemsFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OutOfBoundsItemsFix")]
[assembly: AssemblyTitle("OutOfBoundsItemsFix")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace OutOfBoundsItemsFix;

[BepInPlugin("com.rob.OutOfBoundsItemsFix", "OutOfBoundsItemsFix", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
	public const string MODUID = "com.rob.OutOfBoundsItemsFix";

	public static GameObject helperPrefab;

	public static SpawnCard helperSpawnCard;

	private void Awake()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: 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
		helperPrefab = Resources.Load<GameObject>("SpawnCards/HelperPrefab");
		helperSpawnCard = ScriptableObject.CreateInstance<SpawnCard>();
		helperSpawnCard.hullSize = (HullClassification)0;
		helperSpawnCard.nodeGraphType = (GraphType)0;
		helperSpawnCard.prefab = helperPrefab;
		MapZone.TryZoneStart += new hook_TryZoneStart(MapZone_TryZoneStart);
		PickupDropletController.Start += new hook_Start(PickupDropletController_Start);
	}

	private void PickupDropletController_Start(orig_Start orig, PickupDropletController self)
	{
		if (Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)((Component)self).gameObject))
		{
			((Component)self).gameObject.AddComponent<DropProtection>();
		}
		orig.Invoke(self);
	}

	private void MapZone_TryZoneStart(orig_TryZoneStart orig, MapZone self, Collider collider)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_003c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		if ((int)self.zoneType == 0 && (Object.op_Implicit((Object)(object)((Component)collider).GetComponent<PickupDropletController>()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponent<GenericPickupController>())))
		{
			GameObject val = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(helperSpawnCard, new DirectorPlacementRule
			{
				placementMode = (PlacementMode)3,
				position = ((Component)collider).transform.position
			}, RoR2Application.rng));
			if (Object.op_Implicit((Object)(object)val))
			{
				TeleportHelper.TeleportGameObject(((Component)collider).gameObject, val.transform.position);
				Object.Destroy((Object)(object)val);
			}
		}
		orig.Invoke(self, collider);
	}
}
public class DropProtection : MonoBehaviour
{
	private float startY;

	private void Awake()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		startY = ((Component)this).transform.position.y;
	}

	private void FixedUpdate()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: 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_003d: 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_0058: Expected O, but got Unknown
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		if (((Component)this).transform.position.y <= startY - 100f)
		{
			GameObject val = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(Plugin.helperSpawnCard, new DirectorPlacementRule
			{
				placementMode = (PlacementMode)3,
				position = ((Component)this).transform.position
			}, RoR2Application.rng));
			if (Object.op_Implicit((Object)(object)val))
			{
				TeleportHelper.TeleportGameObject(((Component)this).gameObject, val.transform.position);
				Object.Destroy((Object)(object)val);
			}
		}
	}
}