using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("DifficultModA")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DifficultModA")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f30fa901-4577-44d7-aeae-9f2213c42f4d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DifficultModA
{
[BepInPlugin("DifficultModA", "DifficultModA", "1.0.3")]
public class DifficultModPlugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("DifficultModA");
private static RoundManager currentRound;
private static bool isHost;
private static SelectableLevel currentLevel;
private static EnemyVent[] currentLevelVents;
private static DifficultModPlugin Instance;
private void Awake()
{
Instance = this;
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Istance of difficultmod was null.....");
Logger.CreateLogSource("DifficultModA").LogInfo((object)"The difficult mod is loaded!");
harmony.PatchAll(typeof(DifficultModPlugin));
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
}
[HarmonyPatch(typeof(RoundManager), "Start")]
[HarmonyPrefix]
private static void setIsHost()
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)("Host Status: " + ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost));
isHost = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;
}
[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
[HarmonyPrefix]
private static void ModifyLevel(ref SelectableLevel newLevel)
{
currentRound = RoundManager.Instance;
currentLevel = currentRound.currentLevel;
Logger.CreateLogSource("DifficultModA").LogInfo((object)"idk just seeing if plugin is loading.....");
SpawnEnemyWithConfigManager("dog", 10);
SpawnEnemyWithConfigManager("girl", 1);
}
[HarmonyPatch(typeof(RoundManager), "AdvanceHourAndSpawnNewBatchOfEnemies")]
[HarmonyPrefix]
private static void updateCurrentLevelInfo(ref EnemyVent[] ___allEnemyVents, ref SelectableLevel ___currentLevel)
{
currentLevel = ___currentLevel;
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Current level loaded!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
currentLevelVents = ___allEnemyVents;
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Current level vents loaded!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
private static void SpawnEnemyWithConfigManager(string enemyName, int numberOfEnemies)
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)"CFGMGR tried to spawn an enemy");
bool flag = false;
if ((Object)(object)currentLevel == (Object)null)
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Current Level is null1234567890'");
}
foreach (SpawnableEnemyWithRarity enemy in currentLevel.Enemies)
{
if (enemy.enemyType.enemyName.ToLower().Contains(enemyName.ToLower()))
{
try
{
flag = true;
_ = enemy.enemyType.enemyName;
SpawnEnemy(enemy, numberOfEnemies, inside: true);
Logger.CreateLogSource("DifficultModA").LogInfo((object)("Spawned " + enemy.enemyType.enemyName));
}
catch
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Could not spawn enemy");
}
break;
}
}
if (flag)
{
return;
}
foreach (SpawnableEnemyWithRarity outsideEnemy in currentLevel.OutsideEnemies)
{
if (outsideEnemy.enemyType.enemyName.ToLower().Contains(enemyName.ToLower()))
{
try
{
flag = true;
_ = outsideEnemy.enemyType.enemyName;
Logger.CreateLogSource("DifficultModA").LogInfo((object)outsideEnemy.enemyType.enemyName);
Logger.CreateLogSource("DifficultModA").LogInfo((object)("The index of " + outsideEnemy.enemyType.enemyName + " is " + currentLevel.OutsideEnemies.IndexOf(outsideEnemy)));
SpawnEnemy(outsideEnemy, numberOfEnemies, inside: false);
Logger.CreateLogSource("DifficultModA").LogInfo((object)("Spawned " + outsideEnemy.enemyType.enemyName));
break;
}
catch (Exception ex)
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Could not spawn enemy");
Logger.CreateLogSource("DifficultModA").LogInfo((object)("The game tossed an error: " + ex.Message));
break;
}
}
}
}
private static void SpawnEnemy(SpawnableEnemyWithRarity enemy, int amount, bool inside)
{
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Got to the main SpawnEnemy function");
if (inside)
{
try
{
for (int i = 0; i < amount; i++)
{
currentRound.SpawnEnemyOnServer(currentRound.allEnemyVents[Random.Range(0, currentRound.allEnemyVents.Length)].floorNode.position, currentRound.allEnemyVents[i].floorNode.eulerAngles.y, currentLevel.Enemies.IndexOf(enemy));
}
return;
}
catch
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Failed to spawn enemies, check your command.");
return;
}
}
for (int j = 0; j < amount; j++)
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)$"You wanted to spawn: {amount} enemies");
Logger.CreateLogSource("DifficultModA").LogInfo((object)("Spawned an enemy. Total Spawned: " + j));
Object.Instantiate<GameObject>(currentLevel.OutsideEnemies[currentLevel.OutsideEnemies.IndexOf(enemy)].enemyType.enemyPrefab, GameObject.FindGameObjectsWithTag("OutsideAINode")[Random.Range(0, GameObject.FindGameObjectsWithTag("OutsideAINode").Length - 1)].transform.position, Quaternion.Euler(Vector3.zero)).gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "DifficultModA";
public const string PLUGIN_NAME = "DifficultModA";
public const string PLUGIN_VERSION = "1.0.3";
}
}
namespace DifficultModA.Patches
{
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerTPatch
{
public static string BIRD_NAME = "Doublewing";
public static string BABOON_NAME = "BaboonBird";
public static string NICE_BEES_NAME = "DocileLocustBees";
[HarmonyPatch("GenerateNewFloor")]
[HarmonyPostfix]
private static void RemoveUselessStuffTable(ref SelectableLevel ___currentLevel)
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)"Somehow we got here.....?");
List<SpawnableEnemyWithRarity> outsideEnemies = ___currentLevel.OutsideEnemies;
int num = -1;
for (int i = 0; i < outsideEnemies.Count; i++)
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)outsideEnemies[i].enemyType.enemyName);
if (outsideEnemies[i].enemyType.enemyName == BIRD_NAME || outsideEnemies[i].enemyType.enemyName == BABOON_NAME || outsideEnemies[i].enemyType.enemyName == NICE_BEES_NAME)
{
num = i;
break;
}
}
if (num > -1)
{
Logger.CreateLogSource("DifficultModA").LogInfo((object)$"Removing enemy {num}");
outsideEnemies.RemoveAt(num);
}
}
}
}