Decompiled source of BattleRoyale v1.0.0

Snowlance.BattleRoyale.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SpawnableItems;
using TMPro;

[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: AssemblyCompany("Snowlance.BattleRoyale")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e7a20407619d137554b2f3ed018877d0790520db")]
[assembly: AssemblyProduct("BattleRoyale")]
[assembly: AssemblyTitle("Snowlance.BattleRoyale")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BattleRoyale
{
	[BepInPlugin("Snowlance.BattleRoyale", "BattleRoyale", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BattleRoyale : BaseUnityPlugin
	{
		public static BattleRoyale Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			SpawnableItemsBase.configItemSpawnSequence.Value = "BeforeScrap";
			SpawnableItemsBase.configMinItemsToSpawn.Value = 50;
			SpawnableItemsBase.configMaxItemsToSpawn.Value = 100;
			if (Harmony == null)
			{
				Harmony = new Harmony("Snowlance.BattleRoyale");
			}
			Harmony.PatchAll();
			Logger.LogInfo((object)"Snowlance.BattleRoyale v1.0.0 has loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Snowlance.BattleRoyale";

		public const string PLUGIN_NAME = "BattleRoyale";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BattleRoyale.Patches
{
	internal class DeadlinePatch
	{
		[HarmonyPatch(typeof(TimeOfDay), "UpdateProfitQuotaCurrentTime")]
		public class InfiniteDeadline
		{
			[HarmonyPostfix]
			public static void SetInfiniteDeadline()
			{
				TimeOfDay.Instance.timeUntilDeadline = (int)(TimeOfDay.Instance.totalTime * (float)TimeOfDay.Instance.quotaVariables.deadlineDaysAmount);
				((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = "DEADLINE:\n NONE";
			}
		}

		[HarmonyPatch(typeof(HUDManager), "DisplayDaysLeft")]
		public class DisplayInfiniteLeft
		{
			[HarmonyPostfix]
			public static void SetDisplayInfiniteLeft()
			{
				((TMP_Text)HUDManager.Instance.profitQuotaDaysLeftText).text = "Infinite Days Left";
				((TMP_Text)HUDManager.Instance.profitQuotaDaysLeftText2).text = "Infinite Days Left";
			}
		}
	}
	[HarmonyPatch(typeof(EntranceTeleport))]
	internal class EntranceTeleportPatch : HarmonyPatch
	{
		private static ManualLogSource Logger = BattleRoyale.Logger;

		[HarmonyPatch("TeleportPlayer")]
		[HarmonyPrefix]
		public static bool TeleportPlayerPrefix(bool ___isEntranceToBuilding, int ___entranceId, bool ___gotExitPoint)
		{
			if (!___gotExitPoint)
			{
				Logger.LogInfo((object)"IS");
			}
			else if (___entranceId != 0 && ___isEntranceToBuilding)
			{
				HUDManager.Instance.DisplayTip("???", "It appears to be locked from the inside...", false, false, "LC_Tip1");
				return false;
			}
			if (___entranceId == 0 && !___isEntranceToBuilding)
			{
				HUDManager.Instance.DisplayTip("???", "The entrance appears to be blocked...", false, false, "LC_Tip1");
				return false;
			}
			if (___entranceId == 0 && ___isEntranceToBuilding)
			{
				HUDManager.Instance.DisplayTip("???", "The entrance is welded shut!", false, false, "LC_Tip1");
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		private static ManualLogSource Logger = BattleRoyale.Logger;

		[HarmonyPatch("firstDayAnimation")]
		[HarmonyPostfix]
		private static void firstDayAnimationPatch()
		{
			if (StartOfRound.Instance.gameStats.daysSpent != 0 || StartOfRound.Instance.isChallengeFile)
			{
				Logger.LogInfo((object)"Not a new save, not loading unlockables.");
				return;
			}
			UnlockShipItem(StartOfRound.Instance.unlockablesList.unlockables.FindIndex((UnlockableItem x) => x.unlockableName == "Inverse Teleporter"));
			UnlockShipItem(StartOfRound.Instance.unlockablesList.unlockables.FindIndex((UnlockableItem x) => x.unlockableName == "Signal translator"));
			UnlockShipItem(StartOfRound.Instance.unlockablesList.unlockables.FindIndex((UnlockableItem x) => x.unlockableName == "Teleporter"));
		}

		private static void UnlockShipItem(int unlockableID)
		{
			try
			{
				MethodInfo method = ((object)StartOfRound.Instance).GetType().GetMethod("UnlockShipObject", BindingFlags.Instance | BindingFlags.NonPublic);
				method.Invoke(StartOfRound.Instance, new object[1] { unlockableID });
			}
			catch (NullReferenceException arg)
			{
				Logger.LogError((object)$"Could not invoke UnlockShipObject method: {arg}");
			}
		}
	}
}