using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Gear;
using HarmonyLib;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyDescription("Controls bot resource pickups.")]
[assembly: AssemblyCopyright("Copyright © Dteyn 2026 (github.com/Dteyn)")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d2b16d41-68a4-4f88-b437-8b2b0c4c9a2f")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BotPackControl")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BotPackControl")]
[assembly: AssemblyTitle("BotPackControl")]
[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 BotPackControl
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.github.dteyn.gtfo-botpackcontrol";
public const string PLUGIN_NAME = "GTFO BotPackControl";
public const string PLUGIN_VERSION = "1.0.0";
}
[BepInPlugin("com.github.dteyn.gtfo-botpackcontrol", "GTFO BotPackControl", "1.0.0")]
public class Main : BasePlugin
{
internal static ManualLogSource? Logger { get; private set; }
public override void Load()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BasePlugin)this).Log;
ManualLogSource? logger = Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("GTFO BotPackControl");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded.");
}
logger.LogInfo(val);
new Harmony("com.github.dteyn.gtfo-botpackcontrol").PatchAll();
}
}
public enum ResourcePackType
{
Ammo,
Medipack,
Tool,
Disinfect
}
[HarmonyPatch(typeof(Interact_Timed), "PlayerCanInteract")]
internal static class Patch_PlayerCanInteract
{
[HarmonyPrefix]
private static bool Prefix(Interact_Timed __instance, PlayerAgent source, ref bool __result)
{
if (SNet.IsMaster && source != null)
{
SNet_Player owner = source.Owner;
if (((owner != null) ? new bool?(owner.IsBot) : null).GetValueOrDefault())
{
Item itemFromInteract = GetItemFromInteract((Component?)(object)__instance);
if ((Object)(object)itemFromInteract == (Object)null || !TryGetPackType(itemFromInteract, out var packType))
{
return true;
}
if (!Config.IsPackAllowed(packType))
{
__result = false;
return false;
}
return true;
}
}
return true;
}
private static bool TryGetPackType(Item? item, out ResourcePackType packType)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected I4, but got Unknown
packType = ResourcePackType.Medipack;
ResourcePackPickup val = ((item != null) ? ((Component)item).GetComponentInParent<ResourcePackPickup>() : null);
if ((Object)(object)val == (Object)null)
{
return false;
}
packType = (int)val.m_packType switch
{
0 => ResourcePackType.Medipack,
1 => ResourcePackType.Ammo,
2 => ResourcePackType.Tool,
9 => ResourcePackType.Disinfect,
_ => ResourcePackType.Medipack,
};
return true;
}
private static Item? GetItemFromInteract(Component? interact)
{
if ((Object)(object)interact == (Object)null)
{
return null;
}
LG_PickupItem_Sync componentInParent = interact.GetComponentInParent<LG_PickupItem_Sync>();
return ((componentInParent != null) ? componentInParent.item : null) ?? interact.GetComponentInParent<Item>();
}
}
public static class Config
{
private static readonly ConfigEntry<bool> allowMedi;
private static readonly ConfigEntry<bool> allowAmmo;
private static readonly ConfigEntry<bool> allowTool;
private static readonly ConfigEntry<bool> allowDisinfect;
static Config()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "BotPackControl.cfg"), true);
allowMedi = val.Bind<bool>("Allowed Packs", "Medipack", true, "Bots are allowed to pick up Medical Packs");
allowAmmo = val.Bind<bool>("Allowed Packs", "Ammo", false, "Bots are allowed to pick up Ammo Packs");
allowTool = val.Bind<bool>("Allowed Packs", "Tool Refill", false, "Bots are allowed to pick up Tool Refill Packs");
allowDisinfect = val.Bind<bool>("Allowed Packs", "Disinfect", false, "Bots are allowed to pick up Disinfect Packs");
}
public static bool IsPackAllowed(ResourcePackType packType)
{
return packType switch
{
ResourcePackType.Medipack => allowMedi.Value,
ResourcePackType.Ammo => allowAmmo.Value,
ResourcePackType.Tool => allowTool.Value,
ResourcePackType.Disinfect => allowDisinfect.Value,
_ => false,
};
}
}
}