using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
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("TwoHandedFree")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TwoHandedFree")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ECA63F17-F1C6-4626-9659-7C1F15AA9508")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TwoHandedFree
{
[BepInPlugin("Incorrupted.TwoHandedFree", "TwoHandedFree", "3.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class TwoHandedPlugin : BaseUnityPlugin
{
public const string ModGUID = "Incorrupted.TwoHandedFree";
public const string ModName = "TwoHandedFree";
public const string ModVersion = "3.0.0";
private readonly Harmony _harmony = new Harmony("Incorrupted.TwoHandedFree");
public static TwoHandedPlugin Instance;
public static ConfigEntry<string> ConfigBlacklist;
public static LethalNetworkVariable<string> NetworkedBlacklist = new LethalNetworkVariable<string>("TwoHandedBlacklist");
public static Dictionary<string, bool> OriginalStates = new Dictionary<string, bool>();
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
ConfigBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Blacklist", "Gold bar", "Items to keep Two-Handed (comma separated).");
NetworkedBlacklist.OnValueChanged += OnBlacklistReceived;
_harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"TwoHandedFree loaded with LethalNetworkAPI!");
}
private void OnBlacklistReceived(string newVal)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("[Networking] Received Blacklist from Host: " + newVal));
ItemPatcher.ApplyPatches(newVal);
}
}
public static class ItemPatcher
{
public static void ApplyPatches(string blacklistString)
{
if (blacklistString == null)
{
blacklistString = "";
}
if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.allItemsList == (Object)null)
{
return;
}
List<string> list = (from s in blacklistString.ToLower().Split(new char[1] { ',' })
select s.Trim()).ToList();
foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
{
if (!TwoHandedPlugin.OriginalStates.ContainsKey(items.itemName))
{
TwoHandedPlugin.OriginalStates.Add(items.itemName, items.twoHanded);
}
if (TwoHandedPlugin.OriginalStates[items.itemName])
{
bool twoHanded = list.Contains(items.itemName.ToLower());
items.twoHanded = twoHanded;
}
}
}
}
[HarmonyPatch]
public static class GamePatches
{
[HarmonyPatch(typeof(StartOfRound), "Start")]
[HarmonyPostfix]
public static void OnGameStart()
{
if (GameNetworkManager.Instance.isHostingGame)
{
string value = TwoHandedPlugin.ConfigBlacklist.Value;
Debug.Log((object)("[Host] Broadcasting Blacklist: " + value));
TwoHandedPlugin.NetworkedBlacklist.Value = value;
}
}
[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
[HarmonyPostfix]
public static void OnLevelGen()
{
ItemPatcher.ApplyPatches(TwoHandedPlugin.NetworkedBlacklist.Value);
}
[HarmonyPatch(typeof(GrabbableObject), "Start")]
[HarmonyPostfix]
public static void OnItemSpawn(GrabbableObject __instance)
{
if ((Object)(object)__instance.itemProperties != (Object)null && TwoHandedPlugin.OriginalStates.ContainsKey(__instance.itemProperties.itemName))
{
ItemPatcher.ApplyPatches(TwoHandedPlugin.NetworkedBlacklist.Value);
}
}
}
}