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 Unity.Netcode;
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.2.0")]
public class NFBase : BaseUnityPlugin
{
private const string modGUID = "aslimeinahoodie.NoxFerit";
private const string modName = "Nox Ferit";
private const string modVersion = "1.2.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 currentDayTime;
internal static float totalTime;
internal static float scrapAmountMultiplier;
internal static bool isDoubledJump;
internal static bool isServer;
internal static bool hasMonstersSpawned;
internal static float Multiplier;
internal static float nightStrikeTime;
internal static int ventCount;
private void Awake()
{
hasNightStruck = false;
hasMonstersSpawned = 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", "Multiplier", 1.5f, "A multiplier to change how much scrap spawns, as well as how many enemies spawn. (1 = +100%, 2.5 = +250%).");
ConfigEntry<float> obj = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Night Strikes Time", 6f, "Roughly how many hours have past (including 8 am) before Night Strikes (Range between 1 for 8am, 6 for 1pm, and 15 for 12am).");
Multiplier = val.Value;
nightStrikeTime = obj.Value;
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)(" timeLeft: " + ((double)NFBase.nightStrikeTime * 0.06666 - (double)NFBase.normalizedTimeOfDay) * 900.0 + " \n normalizedTimeOfDay: " + NFBase.normalizedTimeOfDay + " \n currentDatTime / totalTime: " + NFBase.currentDayTime + "/" + NFBase.totalTime + " \n hasNightStruck: " + NFBase.hasNightStruck + " \n scrapAmountMultiplier: " + NFBase.scrapAmountMultiplier + " \n configMultiplier: " + NFBase.Multiplier + " \n configNightStrikeTime: " + NFBase.nightStrikeTime + " \n ventCount: " + NFBase.ventCount + " \n isServer: " + NFBase.isServer));
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
private static RoundManager instance;
[HarmonyPatch("SpawnScrapInLevel")]
[HarmonyPrefix]
private static void patchSpawnScrapInLevel(ref float ___scrapAmountMultiplier)
{
if (NFBase.isServer)
{
NFBase.hasNightStruck = false;
NFBase.hasMonstersSpawned = false;
NFBase.scrapAmountMultiplier = ___scrapAmountMultiplier;
}
}
[HarmonyPatch(typeof(RoundManager), "Update")]
[HarmonyPostfix]
private static void updatePostPatch(RoundManager __instance)
{
if (!NFBase.isServer)
{
return;
}
if (NFBase.ventCount != __instance.allEnemyVents.Length)
{
NFBase.ventCount = __instance.allEnemyVents.Length;
NFBase.Logger.LogDebug((object)("allEnemyVents populated with count: " + NFBase.ventCount));
}
if (!NFBase.hasNightStruck)
{
return;
}
if (!NFBase.hasMonstersSpawned)
{
NFBase.hasMonstersSpawned = true;
__instance.currentMaxInsidePower += (float)NFBase.ventCount * NFBase.Multiplier;
}
if (!(__instance.currentEnemyPower < __instance.currentMaxInsidePower))
{
return;
}
__instance.PlotOutEnemiesForNextHour();
for (int i = 0; i < __instance.allEnemyVents.Length; i++)
{
if (__instance.allEnemyVents[i].occupied)
{
__instance.SpawnEnemyFromVent(__instance.allEnemyVents[i]);
NFBase.Logger.LogDebug((object)("Found enemy vent: " + ((Object)((Component)__instance.allEnemyVents[i]).gameObject).name + ". Spawning " + __instance.allEnemyVents[i].enemyType.enemyName + " from vent."));
}
}
}
[HarmonyPatch(typeof(RoundManager), "Start")]
[HarmonyPostfix]
private static void StartPostPatch(RoundManager __instance)
{
NFBase.isServer = ((NetworkBehaviour)__instance).IsServer;
if (NFBase.isServer)
{
__instance.scrapAmountMultiplier += NFBase.Multiplier;
}
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal class TimeOfDayPatch
{
[HarmonyPatch("MoveTimeOfDay")]
[HarmonyPostfix]
private static void patchMoveTimeOfDay(ref float ___normalizedTimeOfDay, ref float ___currentDayTime, ref float ___totalTime)
{
NFBase.currentDayTime = ___currentDayTime;
NFBase.totalTime = ___totalTime;
if (___normalizedTimeOfDay * 900f >= NFBase.nightStrikeTime * 60f && !NFBase.hasNightStruck)
{
NFBase.Logger.LogInfo((object)"Night strikes...");
NFBase.hasNightStruck = true;
}
NFBase.normalizedTimeOfDay = ___normalizedTimeOfDay;
}
}
}