Decompiled source of SCP LethalOperation v0.1.0

SCP_LethalOperations/SCP_LethalOperation.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Additional.Utils;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SCP_LethalOperation")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SCP_LethalOperation")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e91f20ff-39ad-491c-a6e0-ca261991faa0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Additional.Utils
{
	public class BundleUtilities
	{
		public static byte[] GetResourceBytes(string filename, Assembly assembly)
		{
			string[] manifestResourceNames = assembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (!text.Contains(filename))
				{
					continue;
				}
				using Stream stream = assembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					return null;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				return array;
			}
			return null;
		}

		public static AssetBundle LoadBundleFromInternalAssembly(string filename, Assembly assembly)
		{
			return AssetBundle.LoadFromMemory(GetResourceBytes(filename, assembly));
		}
	}
	public static class AssetBundleExtension
	{
		public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object
		{
			Object val = bundle.LoadAsset(name);
			if (val != (Object)null)
			{
				val.hideFlags = (HideFlags)32;
				return (T)(object)val;
			}
			return default(T);
		}
	}
}
namespace SCP_LethalOperation
{
	public static class InternalInfo
	{
		public const string Plugin_Name = "SCP: Lethal Operation";

		public const string Plugin_Ver = "0.1.0";

		public const string Plugin_UI = "thecooljoe.SCPLethalOperation";
	}
	[BepInPlugin("thecooljoe.SCPLethalOperation", "SCP: Lethal Operation", "0.1.0")]
	public class SCPBase : BaseUnityPlugin
	{
		public static SCPBase Instance;

		public static ManualLogSource mls;

		private readonly Harmony harmony = new Harmony("thecooljoe.SCPLethalOperation");

		public static Texture2D Decals;

		public static AssetBundle DecalBundle;

		public static List<AudioClip> SoundFX;

		public static List<AudioClip> SoundFX2;

		public static List<AudioClip> StepsSFX;

		public static List<AudioClip> MetalStepsSFX;

		public static List<AudioClip> GrassStepsSFX;

		public static List<AudioClip> SnowStepsSFX;

		public static List<AudioClip> ShipIntros;

		public static AudioClip ShipAlarm;

		public static AudioClip RadioMusic;

		public static AudioClip ShipFired;

		public static AudioClip LastDay;

		public static AudioClip LastDayAnnounce;

		private void Awake()
		{
			mls = ((BaseUnityPlugin)this).Logger;
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
			SetupMenuAudio();
			SetupMenuImage();
			SetupShipAudio();
			SetupFootStepsAudio();
		}

		public void SetupMenuAudio()
		{
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("SCP_LethalOperation.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "scp_lo_menumusic");
			if ((Object)(object)val != (Object)null)
			{
				SoundFX = val.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogWarning((object)"Main Menu Theme failed to load...");
			}
		}

		public void SetupShipAudio()
		{
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("SCP_LethalOperation.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "scp_lo_shipbg");
			AssetBundle val2 = AssetBundle.LoadFromFile(location + "scp_lo_shipintros");
			AssetBundle val3 = AssetBundle.LoadFromFile(location + "scp_lo_fired");
			AssetBundle val4 = AssetBundle.LoadFromFile(location + "scp_lo_alarms");
			AssetBundle val5 = AssetBundle.LoadFromFile(location + "scp_lo_radiomusic");
			AssetBundle val6 = AssetBundle.LoadFromFile(location + "scp_lo_lastdaydread");
			AssetBundle val7 = AssetBundle.LoadFromFile(location + "scp_lo_finalday");
			if ((Object)(object)val != (Object)null)
			{
				SoundFX2 = val.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogWarning((object)"Ship audio failed to load...");
			}
			if ((Object)(object)val2 != (Object)null)
			{
				ShipIntros = val2.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogWarning((object)"Ship Intros failed to load...");
			}
			if ((Object)(object)val3 != (Object)null)
			{
				ShipFired = val3.LoadAsset<AudioClip>("scpradio6.ogg");
			}
			else
			{
				mls.LogWarning((object)"Ship Intros failed to load...");
			}
			if ((Object)(object)val4 != (Object)null)
			{
				ShipAlarm = val4.LoadAsset<AudioClip>("RadioAlarm.ogg");
			}
			else
			{
				mls.LogWarning((object)"Ship alarm failed to load...");
			}
			if ((Object)(object)val5 != (Object)null)
			{
				RadioMusic = val5.LoadAsset<AudioClip>("scpradio0.ogg");
			}
			else
			{
				mls.LogWarning((object)"Radio BG failed to load...");
			}
			if ((Object)(object)val6 != (Object)null)
			{
				LastDay = val6.LoadAsset<AudioClip>("GlacierDimension.ogg");
			}
			else
			{
				mls.LogWarning((object)"Last Day Music failed to load...");
			}
			if ((Object)(object)val7 != (Object)null)
			{
				LastDayAnnounce = val7.LoadAsset<AudioClip>("FinalDay.ogg");
			}
			else
			{
				mls.LogWarning((object)"Last Day Music failed to load...");
			}
		}

		public void SetupFootStepsAudio()
		{
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("SCP_LethalOperation.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "scp_lo_normalsteps");
			AssetBundle val2 = AssetBundle.LoadFromFile(location + "scp_lo_metalsteps");
			AssetBundle val3 = AssetBundle.LoadFromFile(location + "scp_lo_grasssteps");
			AssetBundle val4 = AssetBundle.LoadFromFile(location + "scp_lo_snowsteps");
			if ((Object)(object)val != (Object)null)
			{
				StepsSFX = val.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogWarning((object)"Normal footstep audio failed to load...");
			}
			if ((Object)(object)val2 != (Object)null)
			{
				MetalStepsSFX = val2.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogWarning((object)"Metal footstep audio failed to load...");
			}
			if ((Object)(object)val3 != (Object)null)
			{
				GrassStepsSFX = val3.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogWarning((object)"Grass footstep audio failed to load...");
			}
			if ((Object)(object)val4 != (Object)null)
			{
				SnowStepsSFX = val4.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogWarning((object)"Snow footstep audio failed to load...");
			}
		}

		public void SetupMenuImage()
		{
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("SCP_LethalOperation.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "scp_lo_images");
			if ((Object)(object)val != (Object)null)
			{
				Decals = val.LoadPersistentAsset<Texture2D>("SCPLogoMain2.png");
			}
			else
			{
				mls.LogWarning((object)"Main Menu Logo failed to load...");
			}
		}
	}
}
namespace SCP_LethalOperation.Patches
{
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class DepositPatch
	{
		[HarmonyPatch("SellItemsOnServer")]
		[HarmonyPrefix]
		public static bool CorpseTaxPatch(DepositItemsDesk __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < __instance.itemsOnCounter.Count; i++)
			{
				if ((__instance.itemsOnCounter[i].itemProperties.itemName.ToUpper().Contains("DEAD") || __instance.itemsOnCounter[i].itemProperties.itemName.ToUpper().Contains("CORPSE")) && __instance.itemsOnCounter[i].itemProperties.isScrap)
				{
					num++;
					num2 = (int)((double)num2 + (double)__instance.itemsOnCounter[i].scrapValue * 0.35);
				}
			}
			if (num > 0)
			{
				int num3 = 30 * num + num2;
				((TMP_Text)HUDManager.Instance.globalNotificationText).text = "SCP: FOUNDATION ALERT\nFINED " + num3 + " CREDITS FOR CORPSES!";
				HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
				HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.radiationWarningAudio, 1f);
				Object.FindObjectOfType<Terminal>().groupCredits = Object.FindObjectOfType<Terminal>().groupCredits - num3;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(MenuManager), "Awake")]
	internal class MainMenuPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void NewMusic(MenuManager __instance)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.isInitScene)
			{
				return;
			}
			if ((Object)(object)SCPBase.Decals != (Object)null)
			{
				Sprite sprite = Sprite.Create(SCPBase.Decals, new Rect(0f, 0f, (float)((Texture)SCPBase.Decals).width, (float)((Texture)SCPBase.Decals).height), new Vector2(0.5f, 0.5f));
				GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject;
				Transform val = gameObject.transform.Find("MenuContainer/MainButtons/HeaderImage");
				if ((Object)(object)val != (Object)null)
				{
					Image component = ((Component)val).gameObject.GetComponent<Image>();
					if ((Object)(object)component != (Object)null)
					{
						component.sprite = sprite;
						RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
						component2.anchorMin = new Vector2(0f, 0f);
						component2.anchorMax = new Vector2(1f, 1f);
						component2.offsetMin = Vector2.zero;
						component2.offsetMax = Vector2.zero;
						((Transform)component2).localScale = Vector2.op_Implicit(new Vector2(1.1f, 1.1f));
					}
				}
				Transform val2 = gameObject.transform.Find("MenuContainer/LoadingScreen");
				if ((Object)(object)val2 != (Object)null)
				{
					Transform val3 = val2.Find("Image");
					if ((Object)(object)val3 != (Object)null)
					{
						Image component3 = ((Component)val3).GetComponent<Image>();
						if ((Object)(object)component3 != (Object)null)
						{
							component3.sprite = sprite;
							RectTransform component4 = ((Component)val3).GetComponent<RectTransform>();
							component4.anchorMin = new Vector2(0f, 0f);
							component4.anchorMax = new Vector2(1f, 1f);
							component4.offsetMin = Vector2.zero;
							component4.offsetMax = Vector2.zero;
							((Transform)component4).localScale = Vector2.op_Implicit(new Vector2(1.1f, 1.1f));
						}
					}
				}
			}
			if (SCPBase.SoundFX != null)
			{
				AudioSource menuAudio = __instance.MenuAudio;
				menuAudio.Stop();
				__instance.menuMusic = SCPBase.SoundFX[0];
				menuAudio.clip = SCPBase.SoundFX[0];
				menuAudio.Play();
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
	}
	[HarmonyPatch(typeof(StartOfRound), "Awake")]
	internal class StartOfRoundPatch
	{
		[CompilerGenerated]
		private sealed class <GiveLifeSystem>d__8 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public StartOfRound __instance;

			private Random <rng>5__1;

			private int <Moonrand>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GiveLifeSystem>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<rng>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Expected O, but got Unknown
				//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f9: Expected O, but got Unknown
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				//IL_023d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0247: Expected O, but got Unknown
				//IL_0344: Unknown result type (might be due to invalid IL or missing references)
				//IL_034e: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (!RunningLife && !DidGiveLife)
					{
						RunningLife = true;
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 1;
						return true;
					}
					if (RunningLife && !DidGiveLife)
					{
						((Component)__instance.shipAnimatorObject).GetComponent<Animator>().SetBool("AlarmRinging", true);
						__instance.shipRoomLights.SetShipLightsOnLocalClientOnly(false);
						__instance.shipDoorAudioSource.clip = __instance.alarmSFX;
						__instance.shipDoorAudioSource.loop = true;
						__instance.shipDoorAudioSource.Play();
						<>2__current = (object)new WaitForSeconds(4f);
						<>1__state = 4;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					((Component)__instance.shipAnimatorObject).GetComponent<Animator>().SetBool("AlarmRinging", true);
					__instance.shipRoomLights.SetShipLightsOnLocalClientOnly(false);
					__instance.shipDoorAudioSource.clip = __instance.alarmSFX;
					__instance.shipDoorAudioSource.loop = true;
					__instance.shipDoorAudioSource.Play();
					<>2__current = (object)new WaitForSeconds(4f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					__instance.firingPlayersCutsceneRunning = false;
					__instance.inShipPhase = true;
					__instance.AllPlayersHaveRevivedClientRpc();
					if (TimeOfDay.Instance.daysUntilDeadline <= 0)
					{
						TimeOfDay.Instance.daysUntilDeadline = 1;
					}
					Object.FindObjectOfType<Terminal>().groupCredits = 0;
					<rng>5__1 = new Random();
					<Moonrand>5__2 = <rng>5__1.Next(3);
					__instance.travellingToNewLevel = true;
					if (<Moonrand>5__2 == 0)
					{
						__instance.ChangeLevelClientRpc(6, Object.FindObjectOfType<Terminal>().groupCredits);
					}
					else if (<Moonrand>5__2 == 1)
					{
						__instance.ChangeLevelClientRpc(7, Object.FindObjectOfType<Terminal>().groupCredits);
					}
					else if (<Moonrand>5__2 == 2)
					{
						__instance.ChangeLevelClientRpc(9, Object.FindObjectOfType<Terminal>().groupCredits);
					}
					else
					{
						__instance.ChangeLevelClientRpc(12, Object.FindObjectOfType<Terminal>().groupCredits);
					}
					<>2__current = (object)new WaitForSeconds(3f + __instance.currentLevel.timeToArrive);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					((Component)__instance.shipAnimatorObject).GetComponent<Animator>().SetBool("AlarmRinging", false);
					__instance.shipRoomLights.SetShipLightsOnLocalClientOnly(true);
					__instance.shipDoorAudioSource.loop = false;
					__instance.shipDoorAudioSource.Stop();
					<rng>5__1 = null;
					break;
				case 4:
					<>1__state = -1;
					__instance.firingPlayersCutsceneRunning = false;
					__instance.inShipPhase = true;
					__instance.AllPlayersHaveRevivedClientRpc();
					if (TimeOfDay.Instance.daysUntilDeadline <= 0)
					{
						TimeOfDay.Instance.daysUntilDeadline = 1;
					}
					__instance.travellingToNewLevel = true;
					__instance.ChangeLevelClientRpc(3, Object.FindObjectOfType<Terminal>().groupCredits);
					__instance.companyBuyingRate = 1.1f;
					<>2__current = (object)new WaitForSeconds(3f + __instance.currentLevel.timeToArrive);
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					((Component)__instance.shipAnimatorObject).GetComponent<Animator>().SetBool("AlarmRinging", false);
					__instance.shipRoomLights.SetShipLightsOnLocalClientOnly(true);
					__instance.shipDoorAudioSource.loop = false;
					__instance.shipDoorAudioSource.Stop();
					WentToCompany = true;
					DidGiveLife = true;
					break;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static GameObject objToSpawn;

		public static bool DidGiveLife;

		public static bool RunningLife;

		public static bool WentToCompany;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		[ClientRpc]
		public static void MainSystem(StartOfRound __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (__instance.inShipPhase)
			{
				if ((Object)(object)objToSpawn == (Object)null)
				{
					objToSpawn = new GameObject("BGAudio");
					AudioSource val = objToSpawn.AddComponent<AudioSource>();
					val.volume = 0.2f;
					val.loop = true;
					if (((Object)(object)val.clip != (Object)(object)SCPBase.LastDay && TimeOfDay.Instance.daysUntilDeadline <= 0) || RunningLife)
					{
						val.clip = SCPBase.LastDay;
					}
					else if ((Object)(object)val.clip != (Object)(object)SCPBase.SoundFX2[0])
					{
						val.clip = SCPBase.SoundFX2[0];
					}
					val.Play();
				}
				else if (!Object.op_Implicit((Object)(object)objToSpawn.GetComponent<AudioSource>()))
				{
					AudioSource val2 = objToSpawn.AddComponent<AudioSource>();
					val2.volume = 0.2f;
					val2.loop = true;
					if (((Object)(object)val2.clip != (Object)(object)SCPBase.LastDay && TimeOfDay.Instance.daysUntilDeadline <= 0) || RunningLife)
					{
						val2.clip = SCPBase.LastDay;
					}
					else if ((Object)(object)val2.clip != (Object)(object)SCPBase.SoundFX2[0])
					{
						val2.clip = SCPBase.SoundFX2[0];
					}
					val2.Play();
				}
			}
			else if ((Object)(object)objToSpawn != (Object)null && Object.op_Implicit((Object)(object)objToSpawn.GetComponent<AudioSource>()))
			{
				AudioSource component = objToSpawn.GetComponent<AudioSource>();
				component.Stop();
				Object.Destroy((Object)(object)component);
			}
			if (SCPBase.StepsSFX != null && SCPBase.MetalStepsSFX != null && SCPBase.GrassStepsSFX != null && SCPBase.SnowStepsSFX != null)
			{
				__instance.footstepSurfaces[0].clips = SCPBase.StepsSFX.ToArray();
				__instance.footstepSurfaces[1].clips = SCPBase.StepsSFX.ToArray();
				__instance.footstepSurfaces[2].clips = SCPBase.MetalStepsSFX.ToArray();
				__instance.footstepSurfaces[3].clips = SCPBase.MetalStepsSFX.ToArray();
				__instance.footstepSurfaces[4].clips = SCPBase.GrassStepsSFX.ToArray();
				__instance.footstepSurfaces[5].clips = SCPBase.StepsSFX.ToArray();
				__instance.footstepSurfaces[7].clips = SCPBase.StepsSFX.ToArray();
				__instance.footstepSurfaces[8].clips = SCPBase.SnowStepsSFX.ToArray();
				__instance.footstepSurfaces[9].clips = SCPBase.StepsSFX.ToArray();
				__instance.footstepSurfaces[10].clips = SCPBase.StepsSFX.ToArray();
				__instance.footstepSurfaces[11].clips = SCPBase.StepsSFX.ToArray();
			}
			if ((Object)(object)SCPBase.ShipAlarm != (Object)null)
			{
				__instance.alarmSFX = SCPBase.ShipAlarm;
			}
			if ((Object)(object)SCPBase.ShipFired != (Object)null)
			{
				__instance.firedVoiceSFX = SCPBase.ShipFired;
			}
			if ((Object)(object)SCPBase.LastDayAnnounce != (Object)null)
			{
				__instance.zeroDaysLeftAlertSFX = SCPBase.LastDayAnnounce;
			}
		}

		[HarmonyPatch("firstDayAnimation")]
		[HarmonyPrefix]
		[ServerRpc(RequireOwnership = false)]
		public static void ShipIntroPatch(StartOfRound __instance)
		{
			__instance.speakerAudioSource.Stop();
			if (SCPBase.ShipIntros != null && !__instance.speakerAudioSource.isPlaying && TimeOfDay.Instance.daysUntilDeadline > 0)
			{
				Random random = new Random();
				int index = random.Next(6);
				__instance.shipIntroSpeechSFX = SCPBase.ShipIntros[index];
				__instance.speakerAudioSource.clip = SCPBase.ShipIntros[index];
			}
		}

		[HarmonyPatch("SetShipReadyToLand")]
		[HarmonyPostfix]
		[ServerRpc(RequireOwnership = false)]
		public static void ShipIntroResend(StartOfRound __instance)
		{
			if (SCPBase.ShipIntros != null && !__instance.speakerAudioSource.isPlaying && TimeOfDay.Instance.daysUntilDeadline > 0)
			{
				Random random = new Random();
				int index = random.Next(6);
				__instance.shipIntroSpeechSFX = SCPBase.ShipIntros[index];
				__instance.speakerAudioSource.clip = SCPBase.ShipIntros[index];
				__instance.speakerAudioSource.PlayOneShot(__instance.shipIntroSpeechSFX);
			}
		}

		[HarmonyPatch("FirePlayersAfterDeadlineClientRpc")]
		[HarmonyPrefix]
		[ClientRpc]
		public static bool AddExtraLifeline(StartOfRound __instance)
		{
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (!DidGiveLife)
			{
				if (networkManager.IsHost)
				{
					((MonoBehaviour)__instance).StartCoroutine(GiveLifeSystem(__instance));
				}
				return false;
			}
			return true;
		}

		[IteratorStateMachine(typeof(<GiveLifeSystem>d__8))]
		[HarmonyPatch]
		[ServerRpc(RequireOwnership = false)]
		public static IEnumerator GiveLifeSystem(StartOfRound __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GiveLifeSystem>d__8(0)
			{
				__instance = __instance
			};
		}

		[HarmonyPatch("EndOfGame")]
		[HarmonyPrefix]
		[ClientRpc]
		public static void CleanUp()
		{
			if (RunningLife && WentToCompany)
			{
				SCPBase.mls.LogWarning((object)"CLEANING UP!!!");
				RunningLife = false;
				WentToCompany = false;
				DidGiveLife = true;
				if (TimeOfDay.Instance.daysUntilDeadline <= 0)
				{
					TimeOfDay.Instance.daysUntilDeadline = 1;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("LoadNewNodeIfAffordable")]
		[HarmonyPrefix]
		[ClientRpc]
		public static bool IsRunningLife(Terminal __instance, TerminalNode node)
		{
			if (StartOfRoundPatch.RunningLife)
			{
				if (node.buyRerouteToMoon > -1)
				{
					node.displayText = "SHIP NAVIGATION ERROR\n\nSCP: FOUNDATION HAS DISABLED THIS FUNCTION!\n\n";
					node.terminalEvent = "ERROR";
					__instance.PlayTerminalAudioServerRpc(3);
					__instance.LoadNewNode(node);
					return false;
				}
				return false;
			}
			return true;
		}
	}
}