using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using NoFox.Patches;
using Unity.Netcode;
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("NoFox")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoFox")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("52941dcc-4063-4525-8464-fb8cba9c135a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NoFox
{
[BepInPlugin("rogan.NoFox", "No Fox", "1.0.4")]
public class NoFoxBase : BaseUnityPlugin
{
private const string modGUID = "rogan.NoFox";
private const string modName = "No Fox";
private const string modVersion = "1.0.4";
private readonly Harmony harmony = new Harmony("rogan.NoFox");
private static NoFoxBase Instance;
internal static ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("rogan.NoFox");
mls.LogInfo((object)"NoFox Started!");
harmony.PatchAll(typeof(NoFoxBase));
harmony.PatchAll(typeof(StartRoundPatch));
harmony.PatchAll(typeof(FoxSpawnPatch));
}
}
}
namespace NoFox.Patches
{
[HarmonyPatch(typeof(RoundManager))]
internal class FoxSpawnPatch
{
[HarmonyPatch("LoadNewLevelWait")]
[HarmonyPostfix]
private static void foxSpawnPatch(ref SelectableLevel ___currentLevel)
{
List<SpawnableEnemyWithRarity> outsideEnemies = ___currentLevel.OutsideEnemies;
NoFoxBase.mls.LogInfo((object)outsideEnemies);
SpawnableEnemyWithRarity val = null;
foreach (SpawnableEnemyWithRarity item in outsideEnemies)
{
if (item.enemyType.enemyName == "BushWolf")
{
val = item;
}
}
if (val != null)
{
outsideEnemies.Remove(val);
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
public class StartRoundPatch
{
[HarmonyPatch(typeof(StartOfRound), "SetPlanetsMold")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> setMoldPatch(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = instructions.ToList();
for (int i = 0; i < list.Count - 1; i++)
{
if (list[i + 1].opcode == OpCodes.Call && list[i + 1].operand == AccessTools.Method(typeof(NetworkBehaviour), "get_IsServer", (Type[])null, (Type[])null))
{
list.RemoveRange(i, 3);
break;
}
}
return list;
}
}
[HarmonyPatch(typeof(TimeOfDay))]
public class TimeDayPatch
{
[HarmonyPatch(typeof(TimeOfDay), "OnDayChanged")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> dayChangePatch(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = instructions.ToList();
for (int i = 0; i < list.Count - 1; i++)
{
if (list[i + 1].opcode == OpCodes.Callvirt && list[i + 1].operand == AccessTools.Method(typeof(StartOfRound), "SetPlanetsMold", (Type[])null, (Type[])null))
{
list.RemoveRange(i, 2);
break;
}
}
return list;
}
}
}