Decompiled source of PandorasGiftBox v1.0.2

PandorasGiftBox.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using PandorasGiftBox;
using PandorasJackInTheBox.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("PandorasGiftBox")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PandorasGiftBox")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e19f0186-1cfe-47f9-a4c0-adbeb3a03b51")]
[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 PandorasJackInTheBox.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("UseItemOnClient")]
		private static void useItemPatch(GrabbableObject __instance)
		{
			Item itemProperties = __instance.itemProperties;
			if (((Object)itemProperties).name == "GiftBox")
			{
				PandorasBoxBase.mls.LogInfo((object)"Gift Box was opened");
				RoundManagerPatch.giftOpenedFlag = true;
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		public static bool giftOpenedFlag;

		private static float timeGiftOpened;

		private static int hoursToAdd;

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static void wasPandoraOpened(ref TimeOfDay ___timeScript, ref SelectableLevel ___currentLevel, ref int ___minOutsideEnemiesToSpawn, ref int ___minEnemiesToSpawn)
		{
			if (giftOpenedFlag)
			{
				timeGiftOpened = ___timeScript.globalTime;
				___minOutsideEnemiesToSpawn = 5;
				___minEnemiesToSpawn = 5;
				SelectableLevel obj = ___currentLevel;
				obj.maxEnemyPowerCount += 4;
				SelectableLevel obj2 = ___currentLevel;
				obj2.maxOutsideEnemyPowerCount += 4;
				SelectableLevel obj3 = ___currentLevel;
				obj3.maxDaytimeEnemyPowerCount += 8;
				giftOpenedFlag = false;
			}
			if (timeGiftOpened > 100f && timeGiftOpened < 300f)
			{
				hoursToAdd = 4;
			}
			else if (timeGiftOpened > 300f && timeGiftOpened < 600f)
			{
				hoursToAdd = 3;
			}
			else if (timeGiftOpened > 600f)
			{
				hoursToAdd = 1;
			}
			if (hoursToAdd > 0)
			{
				timeGiftOpened = 0f;
				TimeOfDay obj4 = ___timeScript;
				obj4.globalTime += 60f;
				hoursToAdd--;
			}
		}
	}
}
namespace PandorasGiftBox
{
	[BepInPlugin("Tundra.PandorasGiftBoxMod", "Pandora's Gift Box Mod", "1.0.0.0")]
	public class PandorasBoxBase : BaseUnityPlugin
	{
		private const string modGUID = "Tundra.PandorasGiftBoxMod";

		private const string modName = "Pandora's Gift Box Mod";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Tundra.PandorasGiftBoxMod");

		private static PandorasBoxBase Instance;

		public static ManualLogSource mls = Logger.CreateLogSource("Tundra.PandorasGiftBoxMod");

		public static ConfigEntry<bool> CanHoardingBugEscape;

		public static ConfigEntry<float> HoardingBugChanceToEscapeEveryMinute;

		public static ConfigEntry<float> HoardingBugChanceToNestNearShip;

		public static ConfigEntry<float> HoardingBugChanceToSpawnOutside;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls.LogInfo((object)"Tundra's mod Pandora's Gift Box has opened!");
			harmony.PatchAll(typeof(PandorasBoxBase));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(GrabbableObjectPatch));
		}
	}
}