Decompiled source of KeepScrap v1.0.0

KeepScrap.dll

Decompiled 5 months ago
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 KeepScrap.Patches;
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("KeepScrap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KeepScrap")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5cead230-94f2-4c62-8a48-a1b21d4c991c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace KeepScrap
{
	[BepInPlugin("KeepScrap", "KeepScrap", "1.0.0")]
	public class KeepScrapPlugin : BaseUnityPlugin
	{
		public Harmony harmony;

		internal static KeepScrapPlugin Instance;

		internal ManualLogSource mls;

		internal bool allPlayersDeadPreviously;

		private void Awake()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("KeepScrap");
			mls.LogInfo((object)"KeepScrap has awakened");
			harmony = new Harmony("KeepScrap");
			harmony.PatchAll(typeof(KeepScrapPlugin));
			harmony.PatchAll(typeof(GameOverPatches));
			mls.LogInfo((object)"patched ");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "KeepScrap";

		public const string PLUGIN_NAME = "KeepScrap";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace KeepScrap.Patches
{
	[HarmonyPatch]
	internal class GameOverPatches
	{
		[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
		[HarmonyPrefix]
		public static void PatchGameOverPre(RoundManager __instance)
		{
			KeepScrapPlugin.Instance.mls.LogInfo((object)"DespawnPropsAtEndOfRound started");
			KeepScrapPlugin.Instance.mls.LogInfo((object)("All players dead is " + StartOfRound.Instance.allPlayersDead));
			KeepScrapPlugin.Instance.allPlayersDeadPreviously = StartOfRound.Instance.allPlayersDead;
			StartOfRound.Instance.allPlayersDead = false;
			KeepScrapPlugin.Instance.mls.LogInfo((object)"Crashed?");
		}

		[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		public static void PatchGameOverPost(RoundManager __instance)
		{
			KeepScrapPlugin.Instance.mls.LogInfo((object)"DespawnPropsAtEndOfRound ended");
			KeepScrapPlugin.Instance.mls.LogInfo((object)("All players dead is " + StartOfRound.Instance.allPlayersDead));
			KeepScrapPlugin.Instance.mls.LogInfo((object)("All players dead previously is " + KeepScrapPlugin.Instance.allPlayersDeadPreviously));
			StartOfRound.Instance.allPlayersDead = KeepScrapPlugin.Instance.allPlayersDeadPreviously;
			KeepScrapPlugin.Instance.mls.LogInfo((object)"Crashed?");
		}

		[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
		[HarmonyPrefix]
		public static void PatchHUDPre(HUDManager __instance)
		{
			KeepScrapPlugin.Instance.mls.LogInfo((object)"FillEndGameStats started");
			KeepScrapPlugin.Instance.mls.LogInfo((object)("All players dead is " + StartOfRound.Instance.allPlayersDead));
			KeepScrapPlugin.Instance.allPlayersDeadPreviously = StartOfRound.Instance.allPlayersDead;
			StartOfRound.Instance.allPlayersDead = false;
			KeepScrapPlugin.Instance.mls.LogInfo((object)"Crashed?");
		}

		[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
		[HarmonyPostfix]
		public static void PatchHUDPost(HUDManager __instance)
		{
			KeepScrapPlugin.Instance.mls.LogInfo((object)"FillEndGameStats ended");
			KeepScrapPlugin.Instance.mls.LogInfo((object)("All players dead is " + StartOfRound.Instance.allPlayersDead));
			KeepScrapPlugin.Instance.mls.LogInfo((object)("All players dead previously is " + KeepScrapPlugin.Instance.allPlayersDeadPreviously));
			StartOfRound.Instance.allPlayersDead = KeepScrapPlugin.Instance.allPlayersDeadPreviously;
			KeepScrapPlugin.Instance.mls.LogInfo((object)"Crashed?");
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		public static void PatchGameOverText(StartOfRound __instance)
		{
			KeepScrapPlugin.Instance.mls.LogInfo((object)("GameOverDialogue currently is " + __instance.gameOverDialogue[1].bodyText));
			__instance.gameOverDialogue[1].bodyText = "The autopilot will now attempt to fly to the closest safe spaceport. Luckily your items were saved by divine intervention (KeepScrap mod)!";
			KeepScrapPlugin.Instance.mls.LogInfo((object)"Changed gameOverDialogue");
		}
	}
}