using System;
using System.Collections;
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 Mirror;
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("HurryUp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HurryUp")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("320a9897-ee38-4a37-af54-db180f04f294")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HurryUp
{
[BepInPlugin("rei.stonewards.hurryup", "HurryUp", "0.180.1")]
public class Plugin : BaseUnityPlugin
{
internal static Plugin Instance;
internal static ManualLogSource Log;
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<LaunchMode> Mode;
internal static ConfigEntry<KeyboardShortcut> LaunchKey;
private void Awake()
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable HurryUp.");
Mode = ((BaseUnityPlugin)this).Config.Bind<LaunchMode>("General", "Mode", LaunchMode.Keypress, "How the next wave is launched. Instant launches automatically. Keypress waits for the configured key.");
LaunchKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Launch Key", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Key used to launch the next wave when Mode is set to Keypress.");
Harmony val = new Harmony("rei.stonewards.hurryup");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"HurryUp loaded.");
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Enabled: {Enabled.Value}");
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Mode: {Mode.Value}");
ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
KeyboardShortcut value = LaunchKey.Value;
logger.LogInfo((object)$"Launch Key: {((KeyboardShortcut)(ref value)).MainKey}");
}
}
internal enum LaunchMode
{
Instant,
Keypress
}
}
namespace HurryUp.Patches
{
[HarmonyPatch(typeof(EnemyManager), "ServerCountdown")]
public static class ServerCountdownPatch
{
private static bool Prefix(EnemyManager __instance, ref IEnumerator __result)
{
if (!Plugin.Enabled.Value)
{
return true;
}
if (!NetworkServer.active)
{
return true;
}
__result = HurryUpCountdown(__instance);
return false;
}
private static IEnumerator HurryUpCountdown(EnemyManager enemyManager)
{
while ((Object)(object)DiggingManager.Instance == (Object)null)
{
yield return null;
}
yield return (object)new WaitUntil((Func<bool>)(() => DiggingManager.Instance.isLevelGenerated));
if (Plugin.Mode.Value == LaunchMode.Instant)
{
LaunchWave(enemyManager);
yield break;
}
Plugin.Log.LogInfo((object)$"Waiting for {Plugin.LaunchKey.Value} to launch the next wave.");
while (true)
{
KeyboardShortcut value = Plugin.LaunchKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
break;
}
yield return null;
}
LaunchWave(enemyManager);
}
private static void LaunchWave(EnemyManager enemyManager)
{
NetworkHelper.Instance.ServerUpdateCountdown(0f);
Plugin.Log.LogInfo((object)"Launching next wave.");
AccessTools.Method(typeof(EnemyManager), "LaunchWave", (Type[])null, (Type[])null).Invoke(enemyManager, null);
}
}
}