using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ValheimMassPickup")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ValheimMassPickup")]
[assembly: AssemblyTitle("ValheimMassPickup")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace ValheimMassPickup
{
[BepInPlugin("com.dryzler.valheim.masspickup", "Dryzler's Mass Pickup", "1.0.0")]
[BepInProcess("valheim.exe")]
[HarmonyPatch]
public class ValheimMod : BaseUnityPlugin
{
private static FieldInfo m_interactMaskField = AccessTools.Field(typeof(Player), "m_interactMask");
private static MethodInfo _ExtractMethod = AccessTools.Method(typeof(Beehive), "Extract", (Type[])null, (Type[])null);
private readonly Harmony harmony = new Harmony("com.dryzler.valheim.masspickup");
public static ConfigEntry<KeyboardShortcut> MassActionHotkey { get; private set; }
public static ConfigEntry<int> MassInteractRange { get; private set; }
private void Awake()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
MassActionHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Dryzlers Mass Pickup", "Hotkey", new KeyboardShortcut((KeyCode)308, Array.Empty<KeyCode>()), "Activation hotkey for mass pickup.");
MassInteractRange = ((BaseUnityPlugin)this).Config.Bind<int>("Dryzlers Mass Pickup", "Pickup Range", 7, "Range of mass pickup.");
harmony.PatchAll();
}
[HarmonyPatch(typeof(Player), "Interact")]
public static void Prefix(Player __instance, GameObject go, bool hold, bool alt)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
if (((Character)__instance).InAttack() || ((Character)__instance).InDodge() || hold)
{
return;
}
KeyboardShortcut value = MassActionHotkey.Value;
if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
{
return;
}
Interactable componentInParent = go.GetComponentInParent<Interactable>();
Pickable val = (Pickable)(object)((componentInParent is Pickable) ? componentInParent : null);
Collider[] array;
if (val != null)
{
int num = (int)m_interactMaskField.GetValue(__instance);
array = Physics.OverlapSphere(go.transform.position, (float)MassInteractRange.Value, num);
foreach (Collider obj in array)
{
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
GameObject gameObject = ((Component)obj).gameObject;
obj2 = ((gameObject != null) ? gameObject.GetComponentInParent<Pickable>() : null);
}
Pickable val2 = (Pickable)obj2;
if (val2 != null && (Object)(object)val2 != (Object)(object)val && ((Object)val2.m_itemPrefab).name == ((Object)val.m_itemPrefab).name)
{
val2.Interact((Humanoid)(object)__instance, false, alt);
}
}
return;
}
Beehive val3 = (Beehive)(object)((componentInParent is Beehive) ? componentInParent : null);
if (val3 == null)
{
return;
}
int num2 = (int)m_interactMaskField.GetValue(__instance);
array = Physics.OverlapSphere(go.transform.position, (float)MassInteractRange.Value, num2);
foreach (Collider obj3 in array)
{
object obj4;
if (obj3 == null)
{
obj4 = null;
}
else
{
GameObject gameObject2 = ((Component)obj3).gameObject;
obj4 = ((gameObject2 != null) ? gameObject2.GetComponentInParent<Beehive>() : null);
}
Beehive val4 = (Beehive)obj4;
if (val4 != null && (Object)(object)val4 != (Object)(object)val3 && PrivateArea.CheckAccess(((Component)val4).transform.position, 0f, true, false))
{
_ExtractMethod.Invoke(val4, null);
}
}
}
}
}