Decompiled source of NoVoidDeath v1.1.0

NoVoidDeath.dll

Decompiled 5 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 BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NoVoidDeath.NetcodePatcher;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoVoidDeath")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("No death caused by falling of the map")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoVoidDeath")]
[assembly: AssemblyTitle("NoVoidDeath")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 NoVoidDeath
{
	internal class OutOfBoundsTrigger_Patch
	{
		private static StartOfRound playersManager;

		[HarmonyPatch(typeof(OutOfBoundsTrigger), "Start")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		internal static void Start_Patch()
		{
			playersManager = Object.FindObjectOfType<StartOfRound>();
		}

		[HarmonyPatch(typeof(OutOfBoundsTrigger), "OnTriggerEnter")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		internal static bool OnTriggerEnter_Prefix(OutOfBoundsTrigger __instance, ref Collider other)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if ((__instance.disableWhenRoundStarts && !playersManager.inShipPhase) || ((Component)other).tag != "Player")
			{
				return true;
			}
			PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
			if ((Object)(object)component == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)component || !playersManager.shipDoorsEnabled)
			{
				return true;
			}
			if (component.isInsideFactory && !StartOfRound.Instance.isChallengeFile)
			{
				component.ResetFallGravity();
				switch (Plugin.TpLocationConfig)
				{
				case Plugin.LocationType.Ship:
					component.isInsideFactory = false;
					component.TeleportPlayer(Object.FindObjectOfType<StartOfRound>().outsideShipSpawnPosition.position, false, 0f, false, true);
					break;
				case Plugin.LocationType.Entrance:
					component.TeleportPlayer(Object.FindObjectOfType<EntranceTeleport>().entrancePoint.position, false, 0f, false, true);
					break;
				default:
					return true;
				}
				Plugin.Log("Saved from falling out of bounds!");
				return false;
			}
			return true;
		}
	}
	[BepInPlugin("NoVoidDeath", "NoVoidDeath", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public enum LocationType
		{
			None,
			Ship,
			Entrance
		}

		public enum LogType
		{
			Message,
			Warning,
			Error,
			Fatal,
			Debug
		}

		private static ManualLogSource mls;

		public static LocationType TpLocationConfig;

		private void Awake()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			mls = Logger.CreateLogSource("NoVoidDeath");
			string value = ((BaseUnityPlugin)this).Config.Bind<string>("General", "TpLocationConfig", "Ship", new ConfigDescription("Where you get TPed if you fall out of bounds. If you usually die to inverse teleporter then Ship makes more sense, if it's another TP then entrance might make more sense to you.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "None", "Ship", "Entrance" }), Array.Empty<object>())).Value;
			LocationType tpLocationConfig = ((value == "Ship") ? LocationType.Ship : ((value == "Entrance") ? LocationType.Entrance : LocationType.None));
			TpLocationConfig = tpLocationConfig;
			Log("If we fall out of bound, we TP to: " + TpLocationConfig);
			if (TpLocationConfig != 0)
			{
				new Harmony("NoVoidDeath").PatchAll(typeof(OutOfBoundsTrigger_Patch));
			}
			Log("Plugin NoVoidDeath is loaded!");
		}

		internal static void Log(string message, LogType type = LogType.Message)
		{
			switch (type)
			{
			case LogType.Debug:
				mls.LogMessage((object)message);
				break;
			case LogType.Warning:
				mls.LogWarning((object)message);
				break;
			case LogType.Error:
				mls.LogError((object)message);
				break;
			case LogType.Fatal:
				mls.LogFatal((object)message);
				break;
			default:
				mls.LogMessage((object)message);
				break;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NoVoidDeath";

		public const string PLUGIN_NAME = "NoVoidDeath";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace NoVoidDeath.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}