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.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
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("LCStunShovel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCStunShovel")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1ce9ce13-d333-4236-b6f1-79a6a6b81e1f")]
[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 ShovelStunMod;
[BepInPlugin("com.capybara.shovelstun", "Shovel Stun Mod", "1.0.0")]
public class ShovelStunPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Shovel), "HitShovel")]
public static class Shovel_HitShovel_Patch
{
public static void Postfix(Shovel __instance)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
try
{
PlayerControllerB val = (PlayerControllerB)AccessTools.Field(typeof(Shovel), "previousPlayerHeldBy").GetValue(__instance);
List<RaycastHit> list = (List<RaycastHit>)AccessTools.Field(typeof(Shovel), "objectsHitByShovelList").GetValue(__instance);
if ((Object)(object)val == (Object)null || list == null || list.Count == 0)
{
return;
}
foreach (RaycastHit item in list)
{
RaycastHit current = item;
EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref current)).transform).GetComponent<EnemyAICollisionDetect>();
if (!((Object)(object)component == (Object)null) && !((Object)(object)component.mainScript == (Object)null))
{
component.mainScript.SetEnemyStunned(true, StunDuration.Value, val);
Log.LogInfo((object)$"[ShovelStunMod] Stunned {((Object)component.mainScript).name} for {StunDuration.Value}s (by {val.playerUsername})");
}
}
}
catch (Exception arg)
{
Log.LogError((object)$"[ShovelStunMod] Error applying stun: {arg}");
}
}
}
internal static ManualLogSource Log;
internal static ConfigEntry<float> StunDuration;
private void Awake()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
StunDuration = ((BaseUnityPlugin)this).Config.Bind<float>("General", "StunDuration", 1.3f, "How long (in seconds) enemies are stunned when hit by the shovel. Beware that enemies have different stun multipliers.\n\nFor example, Hoarding Bugs have a 0.75 multiplier, meaning that any stuns last 25% less on them.");
try
{
ConfigEntry<float> stunDuration = StunDuration;
FloatSliderOptions val = new FloatSliderOptions();
((BaseRangeOptions<float>)val).Min = 0f;
((BaseRangeOptions<float>)val).Max = 25f;
((BaseOptions)val).RequiresRestart = false;
FloatSliderConfigItem val2 = new FloatSliderConfigItem(stunDuration, val);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
}
catch (Exception ex)
{
Log.LogWarning((object)("LethalConfig registration skipped: " + ex.Message));
}
Harmony.CreateAndPatchAll(typeof(Shovel_HitShovel_Patch), (string)null);
}
}