Decompiled source of GettingOverItWithProvidence v1.0.1

GettingOverItWithProvidence.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using On.RoR2;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[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("GettingOverItWithProvidence")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4e8fa4c474ac486aea2bc09d1666eb16fe1960e8")]
[assembly: AssemblyProduct("GettingOverItWithProvidence")]
[assembly: AssemblyTitle("GettingOverItWithProvidence")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GettingOverItWithProvidence;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Synodii.GettingOverItWithProvidence", "GettingOverItWithProvidence", "1.0.0")]
public class Main : BaseUnityPlugin
{
	public class AdvanceStageMessage : INetMessage, ISerializableObject
	{
		private string stage;

		public AdvanceStageMessage()
		{
		}

		public AdvanceStageMessage(string stage)
		{
			this.stage = stage;
		}

		public void Deserialize(NetworkReader reader)
		{
			stage = reader.ReadString();
		}

		public void Serialize(NetworkWriter writer)
		{
			writer.Write(stage);
		}

		public void OnReceived()
		{
			Run.instance.AdvanceStage(SceneCatalog.FindSceneDef(stage));
		}
	}

	public static ManualLogSource ModLogger;

	private static Dictionary<Collider, int> thatRoofThatIHate = new Dictionary<Collider, int>();

	public void Awake()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		ModLogger = ((BaseUnityPlugin)this).Logger;
		IdkWhatIAmDoing();
		MapZone.TryZoneStart += new hook_TryZoneStart(UpDown);
		MapZone.TeleportBody += new hook_TeleportBody(ConditionalTeleport);
	}

	public void UpDown(orig_TryZoneStart orig, MapZone self, Collider other)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		if (((Component)other).transform.position.y > ((Component)self).transform.position.y)
		{
			thatRoofThatIHate[other] = 1;
		}
		else
		{
			thatRoofThatIHate[other] = 0;
		}
		orig.Invoke(self, other);
	}

	private void ConditionalTeleport(orig_TeleportBody orig, MapZone self, CharacterBody characterBody)
	{
		Collider component = ((Component)characterBody).gameObject.GetComponent<Collider>();
		if (Object.op_Implicit((Object)(object)component) && thatRoofThatIHate.TryGetValue(component, out var value))
		{
			thatRoofThatIHate.Remove(component);
			if (value == 1)
			{
				PathLevelUp(orig, self, characterBody);
			}
			else
			{
				PathLevelDown(orig, self, characterBody);
			}
		}
		else
		{
			orig.Invoke(self, characterBody);
		}
	}

	private void PathLevelDown(orig_TeleportBody orig, MapZone self, CharacterBody characterBody)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		Scene activeScene;
		int num;
		if (Object.op_Implicit((Object)(object)characterBody) && characterBody.isPlayerControlled)
		{
			activeScene = SceneManager.GetActiveScene();
			num = ((((Scene)(ref activeScene)).name == "habitat") ? 1 : 0);
		}
		else
		{
			num = 0;
		}
		bool flag = (byte)num != 0;
		int num2;
		if (Object.op_Implicit((Object)(object)characterBody) && characterBody.isPlayerControlled)
		{
			activeScene = SceneManager.GetActiveScene();
			num2 = ((((Scene)(ref activeScene)).name == "lemuriantemple") ? 1 : 0);
		}
		else
		{
			num2 = 0;
		}
		bool flag2 = (byte)num2 != 0;
		int num3;
		if (Object.op_Implicit((Object)(object)characterBody) && characterBody.isPlayerControlled)
		{
			activeScene = SceneManager.GetActiveScene();
			num3 = ((((Scene)(ref activeScene)).name == "meridian") ? 1 : 0);
		}
		else
		{
			num3 = 0;
		}
		bool flag3 = (byte)num3 != 0;
		int num4;
		if (Object.op_Implicit((Object)(object)characterBody) && characterBody.isPlayerControlled)
		{
			activeScene = SceneManager.GetActiveScene();
			num4 = ((((Scene)(ref activeScene)).name == "habitatfall") ? 1 : 0);
		}
		else
		{
			num4 = 0;
		}
		bool flag4 = (byte)num4 != 0;
		if (NetworkServer.active)
		{
			if (flag || flag4)
			{
				Run.instance.AdvanceStage(SceneCatalog.FindSceneDef("lemuriantemple"));
			}
			else if (flag3)
			{
				if (Run.instance.loopClearCount > 0)
				{
					Run.instance.AdvanceStage(SceneCatalog.FindSceneDef("habitatfall"));
				}
				else
				{
					Run.instance.AdvanceStage(SceneCatalog.FindSceneDef("habitat"));
				}
			}
			else
			{
				orig.Invoke(self, characterBody);
			}
			return;
		}
		if (flag || flag4)
		{
			NetMessageExtensions.Send((INetMessage)(object)new AdvanceStageMessage("lemuriantemple"), (NetworkDestination)2);
		}
		if (flag3)
		{
			if (Run.instance.loopClearCount > 0)
			{
				NetMessageExtensions.Send((INetMessage)(object)new AdvanceStageMessage("habitatfall"), (NetworkDestination)2);
			}
			else
			{
				NetMessageExtensions.Send((INetMessage)(object)new AdvanceStageMessage("habitat"), (NetworkDestination)2);
			}
		}
	}

	private void PathLevelUp(orig_TeleportBody orig, MapZone self, CharacterBody characterBody)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		Scene activeScene;
		int num;
		if (Object.op_Implicit((Object)(object)characterBody) && characterBody.isPlayerControlled)
		{
			activeScene = SceneManager.GetActiveScene();
			num = ((((Scene)(ref activeScene)).name == "habitat") ? 1 : 0);
		}
		else
		{
			num = 0;
		}
		bool flag = (byte)num != 0;
		int num2;
		if (Object.op_Implicit((Object)(object)characterBody) && characterBody.isPlayerControlled)
		{
			activeScene = SceneManager.GetActiveScene();
			num2 = ((((Scene)(ref activeScene)).name == "lemuriantemple") ? 1 : 0);
		}
		else
		{
			num2 = 0;
		}
		bool flag2 = (byte)num2 != 0;
		int num3;
		if (Object.op_Implicit((Object)(object)characterBody) && characterBody.isPlayerControlled)
		{
			activeScene = SceneManager.GetActiveScene();
			num3 = ((((Scene)(ref activeScene)).name == "habitatfall") ? 1 : 0);
		}
		else
		{
			num3 = 0;
		}
		bool flag3 = (byte)num3 != 0;
		int num4;
		if (Object.op_Implicit((Object)(object)characterBody) && characterBody.isPlayerControlled)
		{
			activeScene = SceneManager.GetActiveScene();
			num4 = ((((Scene)(ref activeScene)).name == "meridian") ? 1 : 0);
		}
		else
		{
			num4 = 0;
		}
		bool flag4 = (byte)num4 != 0;
		if (NetworkServer.active)
		{
			if (flag || flag3)
			{
				Run.instance.AdvanceStage(SceneCatalog.FindSceneDef("meridian"));
			}
			else if (flag2)
			{
				if (Run.instance.loopClearCount > 0)
				{
					Run.instance.AdvanceStage(SceneCatalog.FindSceneDef("habitatfall"));
				}
				else
				{
					Run.instance.AdvanceStage(SceneCatalog.FindSceneDef("habitat"));
				}
			}
			else
			{
				orig.Invoke(self, characterBody);
			}
			return;
		}
		if (flag || flag3)
		{
			NetMessageExtensions.Send((INetMessage)(object)new AdvanceStageMessage("meridian"), (NetworkDestination)2);
		}
		if (flag2)
		{
			if (Run.instance.loopClearCount > 0)
			{
				NetMessageExtensions.Send((INetMessage)(object)new AdvanceStageMessage("habitatfall"), (NetworkDestination)2);
			}
			else
			{
				NetMessageExtensions.Send((INetMessage)(object)new AdvanceStageMessage("habitat"), (NetworkDestination)2);
			}
		}
	}

	private void IdkWhatIAmDoing()
	{
		NetworkingAPI.RegisterMessageType<AdvanceStageMessage>();
	}
}