Decompiled source of FlyingDutchmanShip v1.0.2

plugins/FlyingDutchmanShip.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;

[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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("FlyingDutchmanShip")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("ARRGGGOOOUUUUUGHHHAAA")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FlyingDutchmanShip")]
[assembly: AssemblyTitle("FlyingDutchmanShip")]
[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 LethalCompanyTemplate
{
	[BepInPlugin("FlyingDutchmanShip", "FlyingDutchmanShip", "1.0.0")]
	public class DutchmanTeleporter : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("FlyingDutchmanShip");

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin FlyingDutchmanShip is loaded!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)Paths.PluginPath);
			harmony.PatchAll(typeof(TeleporterPatches));
		}
	}
	[HarmonyPatch]
	internal class TeleporterPatches
	{
		private static Random rnd = new Random();

		private static bool shipLanded;

		private static bool hasTeleporter;

		private static ShipTeleporter teleporterInstance;

		private static AudioClip dutchmanWelcome;

		private static void loadSounds()
		{
			int num = rnd.Next(1, 3);
			try
			{
				string text;
				if (num == 1)
				{
					text = "file://" + Paths.PluginPath + "\\DutchmanSounds\\welcomeback1.ogg";
					Debug.Log((object)"Dutchman Welcome 1");
					Debug.Log((object)("LOOKED IN PATH: " + text));
				}
				else
				{
					text = "file://" + Paths.PluginPath + "\\DutchmanSounds\\welcomeback2.ogg";
					Debug.Log((object)"Dutchman Welcome 2");
					Debug.Log((object)("LOOKED IN PATH: " + text));
				}
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)14);
				audioClip.SendWebRequest();
				while (!audioClip.isDone)
				{
				}
				dutchmanWelcome = DownloadHandlerAudioClip.GetContent(audioClip);
			}
			catch (InvalidOperationException)
			{
				string text;
				if (num == 1)
				{
					text = "file://" + Paths.PluginPath + "\\brymul-FlyingDutchmanShip\\DutchmanSounds\\welcomeback1.ogg";
					Debug.Log((object)"Dutchman Welcome 1");
					Debug.Log((object)("LOOKED IN PATH: " + text));
				}
				else
				{
					text = "file://" + Paths.PluginPath + "\\brymul-FlyingDutchmanShip\\DutchmanSounds\\welcomeback2.ogg";
					Debug.Log((object)"Dutchman Welcome 2");
					Debug.Log((object)("LOOKED IN PATH: " + text));
				}
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)14);
				audioClip.SendWebRequest();
				while (!audioClip.isDone)
				{
				}
				dutchmanWelcome = DownloadHandlerAudioClip.GetContent(audioClip);
			}
		}

		[HarmonyPatch(typeof(ShipTeleporter))]
		[HarmonyPatch("beamUpPlayer")]
		[HarmonyPostfix]
		public static void WelcomeBack(ref ShipTeleporter __instance)
		{
			loadSounds();
			((MonoBehaviour)teleporterInstance).StartCoroutine(Wait());
			static IEnumerator Wait()
			{
				yield return (object)new WaitForSeconds(3f);
				teleporterInstance.shipTeleporterAudio.PlayOneShot(dutchmanWelcome);
			}
		}

		[HarmonyPatch(typeof(ShipTeleporter), "Update")]
		[HarmonyPostfix]
		public static void setTeleporterStatus(ref ShipTeleporter __instance)
		{
			if (ShipTeleporter.hasBeenSpawnedThisSession)
			{
				hasTeleporter = true;
				if (!__instance.isInverseTeleporter)
				{
					teleporterInstance = __instance;
				}
			}
			else
			{
				hasTeleporter = false;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Update")]
		[HarmonyPostfix]
		public static void roundUpdate(ref StartOfRound __instance)
		{
			shipLanded = __instance.shipHasLanded;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		public static void teleportIfFalling(ref PlayerControllerB __instance)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.takingFallDamage && !shipLanded && hasTeleporter && (Object)(object)teleporterInstance != (Object)null)
			{
				__instance.TeleportPlayer(teleporterInstance.teleporterPosition.position, true, 160f, false, true);
				Debug.Log((object)"Dutchman is saving player.");
				teleporterInstance.shipTeleporterAudio.PlayOneShot(teleporterInstance.teleporterBeamUpSFX);
				loadSounds();
				teleporterInstance.shipTeleporterAudio.PlayOneShot(dutchmanWelcome);
				teleporterInstance.teleporterAnimator.SetTrigger("useTeleporter");
				__instance.beamUpParticle.Play();
				__instance.takingFallDamage = false;
				__instance.fallValue = 0f;
				__instance.fallValueUncapped = 0f;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlyingDutchmanShip";

		public const string PLUGIN_NAME = "FlyingDutchmanShip";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}