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 HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoBeeLoss")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoBeeLoss")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("08042aca-0b43-4240-a152-9a4e143055cd")]
[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")]
[BepInPlugin("NoBeeLoss", "No Bee Loss", "1.0.0")]
public class NoBeeLoss : BaseUnityPlugin
{
public const string PluginGuid = "NoBeeLoss";
public const string PluginName = "No Bee Loss";
public const string PluginVersion = "1.0.0";
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
HiveBeeLossPatcher.Apply(new Harmony("NoBeeLoss"));
}
}
internal static class HiveBeeLossPatcher
{
public static void Apply(Harmony harmony)
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(typeof(Hive), "Work", (Type[])null, (Type[])null);
if (methodInfo == null)
{
return;
}
Type type = null;
IteratorStateMachineAttribute customAttribute = methodInfo.GetCustomAttribute<IteratorStateMachineAttribute>();
if (customAttribute != null)
{
type = customAttribute.StateMachineType;
}
if (type == null)
{
type = typeof(Hive).GetNestedTypes(BindingFlags.NonPublic).FirstOrDefault((Type t) => t.Name.Contains("<Work>"));
}
if (!(type == null))
{
MethodInfo methodInfo2 = AccessTools.Method(type, "MoveNext", (Type[])null, (Type[])null);
if (!(methodInfo2 == null))
{
HarmonyMethod val = new HarmonyMethod(typeof(HiveBeeLossPatcher), "Transpiler", (Type[])null);
harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
}
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
FieldInfo fieldInfo = AccessTools.Field(typeof(Hive), "_ssBees");
if (fieldInfo == null)
{
return list;
}
int num = 0;
bool flag = false;
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (!flag && val.opcode == OpCodes.Ldfld && val.operand is FieldInfo fieldInfo2 && fieldInfo2 == fieldInfo)
{
num = 80;
}
if (!flag && num > 0)
{
num--;
if (val.opcode == OpCodes.Ldc_I4_1 && i + 1 < list.Count && list[i + 1].opcode == OpCodes.Sub)
{
list[i] = new CodeInstruction(OpCodes.Ldc_I4_0, (object)null);
flag = true;
num = 0;
}
}
}
return list;
}
}