Decompiled source of Final Countdown v1.0.2

FinalCountdown/FINAL COUNTDOWN.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using FINAL_COUNTDOWN.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FINAL COUNTDOWN")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FINAL COUNTDOWN")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2d1ebdb4-fc60-4d39-a1eb-7a0d30c053ac")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FINAL_COUNTDOWN
{
	[BepInPlugin("Poseidon.FINAL_COUNTDOWN", "Final Countdown", "1.0.0.0")]
	public class FinalCountdown : BaseUnityPlugin
	{
		private const string modGUID = "Poseidon.FINAL_COUNTDOWN";

		private const string modName = "Final Countdown";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Poseidon.FINAL_COUNTDOWN");

		private static FinalCountdown Instance;

		internal ManualLogSource mls;

		internal static List<AudioClip> SoundFX;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Poseidon.FINAL_COUNTDOWN");
			mls.LogInfo((object)"The final countdown mod has awaken :)");
			harmony.PatchAll(typeof(FinalCountdown));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(TimeOfDayPatch));
			mls = ((BaseUnityPlugin)this).Logger;
			SoundFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("FINAL COUNTDOWN.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "finalcountdown");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogInfo((object)"Successfully loaded asset bundle");
				SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to load asset bundle");
			}
		}
	}
}
namespace FINAL_COUNTDOWN.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate(ref float ___sprintMeter)
		{
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		private static bool isPM;

		private static bool alreadyPlayed;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void SetVariables(TimeOfDay __instance)
		{
			isPM = false;
			alreadyPlayed = false;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void OverrideAudio(TimeOfDay __instance)
		{
			int num = (int)(__instance.normalizedTimeOfDay * (60f * (float)__instance.numberOfHours)) + 360;
			int num2 = (int)Mathf.Floor((float)(num / 60));
			if (num2 > 12)
			{
				num2 %= 12;
				isPM = true;
			}
			else
			{
				isPM = false;
				alreadyPlayed = false;
			}
			if (isPM && num2 == 10 && !alreadyPlayed)
			{
				__instance.TimeOfDayMusic.Stop();
				SoundManager.Instance.musicSource.Stop();
				__instance.TimeOfDayMusic.PlayOneShot(FinalCountdown.SoundFX[0], 0.7f);
				alreadyPlayed = true;
			}
			if (StartOfRound.Instance.allPlayersDead || !StartOfRound.Instance.shipHasLanded)
			{
				__instance.TimeOfDayMusic.Stop();
			}
		}
	}
}