Decompiled source of ShipWindowsCloseOnLiftoff v1.0.0

BepInEx/plugins/ShipWindowsCloseOnLiftoff/ShipWindowsCloseOnLiftoff.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using ShipWindows.Config;
using ShipWindows.Patches.Shutters;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ShipWindowsCloseOnLiftoff")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShipWindowsCloseOnLiftoff")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("19abe148-3dfc-452b-8e51-1b17f37ec2d7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ShipWindowsCloseOnLiftoff;

[BepInPlugin("Edwin.ShipWindowsCloseOnLiftoff", "Ship Windows Close On Liftoff", "1.0.0")]
public class ShipWindowsCloseOnLiftoff : BaseUnityPlugin
{
	public const string modGUID = "Edwin.ShipWindowsCloseOnLiftoff";

	public const string modName = "Ship Windows Close On Liftoff";

	public const string modVersion = "1.0.0";

	internal static ManualLogSource Log;

	private readonly Harmony harmony = new Harmony("Edwin.ShipWindowsCloseOnLiftoff");

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		harmony.PatchAll(typeof(CloseWindowShutterOnLiftoff));
	}
}
[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
internal class CloseWindowShutterOnLiftoff
{
	private static readonly MethodInfo ShutShutters = AccessTools.Method(typeof(HideMoonTransitionPatch), "ShutAndLockShuttersForTransition", (Type[])null, (Type[])null);

	[HarmonyPostfix]
	private static void Postfix(StartOfRound __instance)
	{
		if (((NetworkBehaviour)__instance).IsServer)
		{
			if (!WindowConfig.hideMoonLanding.Value)
			{
				ShipWindowsCloseOnLiftoff.Log.LogWarning((object)"Hiding moon landings is disabled in ShipWindows' config. Shutters will not be closed.");
			}
			else if (ShutShutters == null)
			{
				ShipWindowsCloseOnLiftoff.Log.LogError((object)"Could not find `ShutAndLockShuttersForTransition`. Is `ShipWindows` installed?");
			}
			else
			{
				((MonoBehaviour)__instance).StartCoroutine(Sequence(__instance));
			}
		}
	}

	private static IEnumerator Sequence(StartOfRound round)
	{
		IEnumerator closeShutters = (IEnumerator)ShutShutters.Invoke(null, new object[1] { 0.8f });
		yield return (object)new WaitForSeconds(13f);
		((MonoBehaviour)round).StartCoroutine(closeShutters);
	}
}