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 SkitsMenace.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("SkitsMenace")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SkitsMenace")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dbb06aab-ad1a-42f7-9b42-4b4e9e95f351")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SkitsMenace
{
internal class EnemyUtil
{
}
[BepInPlugin("Skitbet.SkitsMenance", "SkitsMenance", "1.0.1")]
public class SkitsMenanceMod : BaseUnityPlugin
{
private const string modGUID = "Skitbet.SkitsMenance";
private const string modName = "SkitsMenance";
private const string modVersion = "1.0.1";
private readonly Harmony harmony = new Harmony("Skitbet.SkitsMenance");
internal ManualLogSource logger;
internal List<SpawnableEnemyWithRarity> IndoorEnemyCache;
internal List<SpawnableEnemyWithRarity> OutdoorEnemyCache;
internal Dictionary<string, int> CurrentLevelDefaultRarities;
internal bool EnemyCached;
public static SkitsMenanceMod instance { get; private set; }
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
logger = Logger.CreateLogSource("Skitbet.SkitsMenance");
logger.LogInfo((object)"Patching SkitsMenance Mod...");
harmony.PatchAll(typeof(RoundManagerPatch));
logger.LogInfo((object)"Patched SkitsMenance Mod!");
}
}
}
namespace SkitsMenace.Patches
{
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
[HarmonyPatch("LoadNewLevel")]
[HarmonyPrefix]
private static void ModifyLevel(ref SelectableLevel newLevel)
{
if (SkitsMenanceMod.instance.CurrentLevelDefaultRarities != null)
{
SkitsMenanceMod.instance.CurrentLevelDefaultRarities.Clear();
SkitsMenanceMod.instance.CurrentLevelDefaultRarities = null;
}
SkitsMenanceMod.instance.CurrentLevelDefaultRarities = GetDefaultRarities(newLevel);
if (!SkitsMenanceMod.instance.EnemyCached)
{
SkitsMenanceMod.instance.logger.LogInfo((object)"Caching....");
SkitsMenanceMod.instance.EnemyCached = true;
SkitsMenanceMod.instance.IndoorEnemyCache = FixIndoorEnemySpawns();
SkitsMenanceMod.instance.OutdoorEnemyCache = FixOutDoorEnemySpawns();
}
newLevel.Enemies = SkitsMenanceMod.instance.IndoorEnemyCache;
newLevel.OutsideEnemies = SkitsMenanceMod.instance.OutdoorEnemyCache;
}
internal static Dictionary<string, int> GetDefaultRarities(SelectableLevel newLevel)
{
Dictionary<string, int> dictionary = new Dictionary<string, int>();
foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
{
dictionary.Add(enemy.enemyType.enemyName, (enemy.rarity <= 5) ? Random.Range(6, 100) : enemy.rarity);
}
foreach (SpawnableEnemyWithRarity outsideEnemy in newLevel.OutsideEnemies)
{
dictionary.Add(outsideEnemy.enemyType.enemyName, (outsideEnemy.rarity <= 5) ? Random.Range(6, 100) : outsideEnemy.rarity);
}
return dictionary;
}
internal static List<SpawnableEnemyWithRarity> FixIndoorEnemySpawns()
{
SkitsMenanceMod.instance.logger.LogInfo((object)"Caching indoor enemies.");
List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
list.Add(RoundManagerPatch.getEntitySpawner<JesterAI>());
list.Add(RoundManagerPatch.getEntitySpawner<DressGirlAI>());
list.Add(RoundManagerPatch.getEntitySpawner<SandSpiderAI>());
list.Add(RoundManagerPatch.getEntitySpawner<CrawlerAI>());
list.Add(RoundManagerPatch.getEntitySpawner<BlobAI>());
list.Add(RoundManagerPatch.getEntitySpawner<CentipedeAI>());
list.Add(RoundManagerPatch.getEntitySpawner<FlowermanAI>());
list.Add(RoundManagerPatch.getEntitySpawner<HoarderBugAI>());
list.Add(RoundManagerPatch.getEntitySpawner<LassoManAI>());
list.Add(RoundManagerPatch.getEntitySpawner<PufferAI>());
list.Add(RoundManagerPatch.getEntitySpawner<SpringManAI>());
list.Add(RoundManagerPatch.getEntitySpawner<NutcrackerEnemyAI>());
SkitsMenanceMod.instance.logger.LogInfo((object)"Cached indoor enemies.");
return list;
}
internal static List<SpawnableEnemyWithRarity> FixOutDoorEnemySpawns()
{
SkitsMenanceMod.instance.logger.LogInfo((object)"Caching outdoor enemies.");
List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
list.Add(RoundManagerPatch.getEntitySpawner<DressGirlAI>());
list.Add(RoundManagerPatch.getEntitySpawner<SandWormAI>());
list.Add(RoundManagerPatch.getEntitySpawner<MouthDogAI>());
list.Add(RoundManagerPatch.getEntitySpawner<BaboonBirdAI>());
list.Add(RoundManagerPatch.getEntitySpawner<DocileLocustBeesAI>());
list.Add(RoundManagerPatch.getEntitySpawner<DoublewingAI>());
list.Add(RoundManagerPatch.getEntitySpawner<ForestGiantAI>());
SkitsMenanceMod.instance.logger.LogInfo((object)"Cached outdoor enemies.");
return list;
}
internal static SpawnableEnemyWithRarity getEntitySpawner<T>() where T : EnemyAI
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
T val = default(T);
Object[] array = Resources.FindObjectsOfTypeAll(typeof(T));
foreach (Object val2 in array)
{
val = (T)(object)val2;
}
SpawnableEnemyWithRarity val3 = new SpawnableEnemyWithRarity();
if ((Object)(object)val != (Object)null)
{
val3.enemyType = ((EnemyAI)val).enemyType;
int rarity;
if (SkitsMenanceMod.instance.CurrentLevelDefaultRarities.ContainsKey(((EnemyAI)val).enemyType.enemyName))
{
rarity = SkitsMenanceMod.instance.CurrentLevelDefaultRarities[((EnemyAI)val).enemyType.enemyName];
}
else
{
SkitsMenanceMod.instance.logger.LogInfo((object)("Couldn't find cached rareity for this level for the " + val3.enemyType.enemyName + ", defaulting to random value."));
rarity = Random.Range(6, 100);
}
val3.rarity = rarity;
}
return val3;
}
}
}