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", "1.1.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))
{
string enemyName = component.mainScript.enemyType.enemyName;
if (ParsedEnemyBlacklist.Contains(enemyName))
{
Log.LogError((object)("[ShovelStun] Skipped stun on blacklisted enemy: " + enemyName));
continue;
}
component.mainScript.SetEnemyStunned(true, StunDuration.Value, val);
Log.LogWarning((object)("[ShovelStun] Stunned " + enemyName + "!"));
}
}
}
catch (Exception arg)
{
Log.LogError((object)$"[ShovelStun] Error applying stun: {arg}");
}
}
}
internal static ManualLogSource Log;
internal static ConfigEntry<float> StunDuration;
internal static ConfigEntry<string> EnemyBlacklist;
internal static HashSet<string> ParsedEnemyBlacklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
private void Awake()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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.5 multiplier, meaning that any stuns last 50% less on them.");
EnemyBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("General", "EnemyBlacklist", "ForestGiant, Jester", "Comma-separated list of enemy names that cannot be stunned by the shovel.\nExample: ForestGiant, Jester, BaboonHawk\n\nChanges take effect immediately without needing to restart.");
ParseBlacklist();
((BaseUnityPlugin)this).Config.SettingChanged += delegate
{
ParseBlacklist();
};
try
{
ConfigEntry<float> stunDuration = StunDuration;
FloatSliderOptions val = new FloatSliderOptions();
((BaseRangeOptions<float>)val).Min = 0f;
((BaseRangeOptions<float>)val).Max = 25f;
((BaseOptions)val).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(stunDuration, val));
}
catch (Exception ex)
{
Log.LogWarning((object)("LethalConfig registration skipped: " + ex.Message));
}
Harmony.CreateAndPatchAll(typeof(Shovel_HitShovel_Patch), (string)null);
Log.LogWarning((object)"[ShovelStun] loaded successfully and ready!");
}
private static void ParseBlacklist()
{
ParsedEnemyBlacklist.Clear();
string[] array = EnemyBlacklist.Value.Split(new char[1] { ',' });
foreach (string text in array)
{
string text2 = text.Trim();
if (!string.IsNullOrEmpty(text2))
{
ParsedEnemyBlacklist.Add(text2);
}
}
}
}