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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
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("BeehivesEverywhere")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BeehivesEverywhere")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("90f49b5d-32e2-4d28-8bb2-2cf8221e18ba")]
[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 LethalCompanyModTemplate;
[BepInPlugin("inuyamazen.BeehivesEverywhere", "BeehivesEverywhere", "1.1.0.0")]
public class BeehivePlugin : BaseUnityPlugin
{
private static string[] names = new string[8] { "ExperimentationLevel", "AssuranceLevel", "VowLevel", "OffenseLevel", "MarchLevel", "RendLevel", "DineLevel", "TitanLevel" };
public const string modGUID = "inuyamazen.BeehivesEverywhere";
public const string modName = "BeehivesEverywhere";
public const string modVersion = "1.1.0.0";
private readonly Harmony harmony = new Harmony("inuyamazen.BeehivesEverywhere");
public static BeehivePlugin instance { get; private set; }
private void Awake()
{
ManualLogSource val = Logger.CreateLogSource("inuyamazen.BeehivesEverywhere");
val.LogMessage((object)"inuyamazen.BeehivesEverywhere has loaded succesfully.");
instance = this;
string[] array = names;
foreach (string text in array)
{
((BaseUnityPlugin)this).Config.Bind<int>("Rarity", text, 72, (ConfigDescription)null);
if (text == "TitanLevel")
{
((BaseUnityPlugin)this).Config.Bind<int>("MaxCount", text, 1, (ConfigDescription)null);
}
else
{
((BaseUnityPlugin)this).Config.Bind<int>("MaxCount", text, 6, (ConfigDescription)null);
}
}
harmony.PatchAll(typeof(BeehivesEverywhere));
}
}
[HarmonyPatch(typeof(RoundManager), "SpawnDaytimeEnemiesOutside")]
[HarmonyPatch("Update")]
internal class BeehivesEverywhere
{
private static SpawnableEnemyWithRarity bees;
[HarmonyPrefix]
private static void SpawnBees(ref RoundManager __instance)
{
SelectableLevel currentLevel = __instance.currentLevel;
int rarity = 72;
int maxCount = 6;
ConfigEntry<int> val = default(ConfigEntry<int>);
if (((BaseUnityPlugin)BeehivePlugin.instance).Config.TryGetEntry<int>("Rarity", ((Object)currentLevel).name, ref val))
{
rarity = val.Value;
}
ConfigEntry<int> val2 = default(ConfigEntry<int>);
if (((BaseUnityPlugin)BeehivePlugin.instance).Config.TryGetEntry<int>("MaxCount", ((Object)currentLevel).name, ref val2))
{
maxCount = val2.Value;
}
if (currentLevel.maxDaytimeEnemyPowerCount < 20)
{
currentLevel.maxDaytimeEnemyPowerCount = 20;
}
if (currentLevel.daytimeEnemiesProbabilityRange < 20f)
{
currentLevel.daytimeEnemiesProbabilityRange = 20f;
}
if (currentLevel.DaytimeEnemies == null)
{
currentLevel.DaytimeEnemies = new List<SpawnableEnemyWithRarity>();
}
bool flag = false;
foreach (SpawnableEnemyWithRarity daytimeEnemy in currentLevel.DaytimeEnemies)
{
if (((Object)daytimeEnemy.enemyType).name == "RedLocustBees")
{
flag = true;
daytimeEnemy.rarity = rarity;
daytimeEnemy.enemyType.MaxCount = maxCount;
bees = daytimeEnemy;
}
}
if (!flag && bees != null)
{
currentLevel.DaytimeEnemies.Add(bees);
Debug.LogWarning((object)("ADDED BEES TO: " + ((Object)currentLevel).name));
}
}
}