Decompiled source of NoxFerit v1.1.0

NoxFerit.dll

Decompiled 18 minutes 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 GameNetcodeStuff;
using HarmonyLib;
using NoxFerit.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoxFerit")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoxFerit")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1ba6a3c9-91e0-401b-a30f-38752c20cd00")]
[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 NoxFerit
{
	[BepInPlugin("aslimeinahoodie.NoxFerit", "Nox Ferit", "1.1.0")]
	public class NFBase : BaseUnityPlugin
	{
		private const string modGUID = "aslimeinahoodie.NoxFerit";

		private const string modName = "Nox Ferit";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("aslimeinahoodie.NoxFerit");

		private static NFBase Instance;

		internal static ManualLogSource Logger;

		internal static bool hasNightStruck;

		internal static float normalizedTimeOfDay;

		internal static float scrapAmountMultiplier;

		internal static bool isDoubledJump;

		internal static float scrapMultiplier;

		internal static float nightStrikeTime;

		internal static int extraEnemyPowerBase;

		internal static int extraEnemyPower;

		private void Awake()
		{
			hasNightStruck = false;
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"The Nox Oculus has opened...");
			harmony.PatchAll(typeof(NFBase));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(TimeOfDayPatch));
			ConfigEntry<float> val = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Scrap Multiplier", 3f, "Add this much to the multiplier of scrap spawned on moons (1 = +100%, 2.5 = +250%).");
			ConfigEntry<float> val2 = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Night Strikes Time", 7f, "Roughly how many hours have past (including 8 am) before Night Strikes (Range between 1 for 8am, and 15 for 12am).");
			ConfigEntry<int> obj = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Enemy Power", 10, "Modify the spike of enemies spawned when Night Strikes.");
			scrapMultiplier = val.Value;
			nightStrikeTime = val2.Value;
			extraEnemyPowerBase = obj.Value;
			extraEnemyPower = extraEnemyPowerBase;
			if (nightStrikeTime > 15f || nightStrikeTime < 1f)
			{
				nightStrikeTime = 11f;
			}
		}
	}
}
namespace NoxFerit.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBCheats
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate(ref float ___sprintMeter)
		{
			if (___sprintMeter < 1f)
			{
				___sprintMeter = 1f;
			}
		}

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPrefix]
		private static void patchDamagePlayer(ref int damageNumber, PlayerControllerB __instance)
		{
			damageNumber = 0;
			NFBase.Logger.LogInfo((object)"Godmode saved you from taking damage");
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static void patchKillPlayerPrefix(ref bool ___isPlayerDead)
		{
			___isPlayerDead = true;
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPostfix]
		private static void patchKillPlayerPostfix(ref bool ___isPlayerDead)
		{
			___isPlayerDead = false;
			NFBase.Logger.LogInfo((object)"Godmode saved you from dying");
		}

		[HarmonyPatch("AllowPlayerDeath")]
		[HarmonyPrefix]
		private static bool patchAllowPlayerDeath()
		{
			NFBase.Logger.LogInfo((object)"Godmode saved you from dying");
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("PlayerJump")]
		[HarmonyPrefix]
		private static void patchPlayerJump()
		{
			NFBase.Logger.LogDebug((object)(" normalizedTimeOfDay: " + NFBase.normalizedTimeOfDay + " \n hasNightStruck: " + NFBase.hasNightStruck + " \n scrapAmountMultiplier: " + NFBase.scrapAmountMultiplier + " \n scrapMultiplier: " + NFBase.scrapMultiplier + " \n nightStrikeTime: " + NFBase.nightStrikeTime + " \n extraEnemyPower: " + NFBase.extraEnemyPower));
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		private static RoundManager instance;

		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyPrefix]
		private static void patchSpawnScrapInLevel(ref float ___scrapAmountMultiplier)
		{
			NFBase.hasNightStruck = false;
			NFBase.extraEnemyPower = NFBase.extraEnemyPowerBase;
			NFBase.scrapAmountMultiplier = ___scrapAmountMultiplier;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate(ref float ___currentMaxOutsidePower, ref float ___currentOutsideEnemyPower, ref EnemyVent[] ___allEnemyVents, ref float ___currentEnemyPower, ref float ___currentMaxInsidePower)
		{
			if (!NFBase.hasNightStruck)
			{
				return;
			}
			if ((Object)(object)instance == (Object)null)
			{
				instance = Object.FindObjectOfType<RoundManager>();
				return;
			}
			if (NFBase.extraEnemyPower > 0)
			{
				___currentMaxInsidePower += NFBase.extraEnemyPower;
				NFBase.extraEnemyPower = 0;
			}
			if (!(___currentEnemyPower < ___currentMaxInsidePower))
			{
				return;
			}
			instance.PlotOutEnemiesForNextHour();
			for (int i = 0; i < ___allEnemyVents.Length; i++)
			{
				if (___allEnemyVents[i].occupied)
				{
					instance.SpawnEnemyFromVent(___allEnemyVents[i]);
					NFBase.Logger.LogDebug((object)("Found enemy vent: " + ((Object)((Component)___allEnemyVents[i]).gameObject).name + ". Spawning " + ___allEnemyVents[i].enemyType.enemyName + " from vent."));
				}
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(ref float ___scrapAmountMultiplier)
		{
			___scrapAmountMultiplier += NFBase.scrapMultiplier;
		}

		[HarmonyPatch("UnloadSceneObjectsEarly")]
		[HarmonyPostfix]
		private static void UnloadSceneObjectsEarlyPatch()
		{
			instance = null;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPatch("MoveTimeOfDay")]
		[HarmonyPostfix]
		private static void patchMoveTimeOfDay(ref float ___normalizedTimeOfDay)
		{
			if ((double)___normalizedTimeOfDay >= (double)NFBase.nightStrikeTime * 0.06666 && !NFBase.hasNightStruck)
			{
				NFBase.Logger.LogInfo((object)"Night strikes...");
				NFBase.hasNightStruck = true;
			}
			NFBase.normalizedTimeOfDay = ___normalizedTimeOfDay;
		}
	}
}