using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BagNametag.Patches;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BagNametag")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A nametag to a bag")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+665e11bf38efab3b895128bafccf833fecf7bf0f")]
[assembly: AssemblyProduct("BagNametag")]
[assembly: AssemblyTitle("BagNametag")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 BagNametag
{
[BepInPlugin("dev.khivus.BagNametag", "BagNametag", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "dev.khivus.BagNametag";
public const string modName = "BagNametag";
public const string modVersion = "1.0.1";
private static Harmony _harmony = new Harmony("dev.khivus.BagNametag");
internal static ManualLogSource mls = Logger.CreateLogSource("dev.khivus.BagNametag");
private void Awake()
{
mls.LogInfo((object)"BagNametag loaded");
PatchAllStuff();
}
private static void PatchAllStuff()
{
_harmony.PatchAll(typeof(BeltBagItemPatch));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BagNametag";
public const string PLUGIN_NAME = "BagNametag";
public const string PLUGIN_VERSION = "0.1.0";
}
}
namespace BagNametag.Patches
{
[HarmonyPatch]
internal class BeltBagItemPatch
{
private static readonly Dictionary<BeltBagItem, string> BeltBagOwners = new Dictionary<BeltBagItem, string>();
private static BeltBagItem lastBagShown;
public static string GetOwner(BeltBagItem bag)
{
string value;
return BeltBagOwners.TryGetValue(bag, out value) ? value : null;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BeltBagItem), "PutObjectInBagLocalClient")]
public static void PutObjectInBagLocalClientPatch(BeltBagItem __instance)
{
if (__instance.objectsInBag.Count <= 0 && ((GrabbableObject)__instance).playerHeldBy.playerUsername != null)
{
BeltBagOwners[__instance] = ((GrabbableObject)__instance).playerHeldBy.playerUsername;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(BeltBagItem), "RemoveFromBagLocalClient")]
public static void RemoveFromBagLocalClientPatch(BeltBagItem __instance)
{
if (__instance.objectsInBag.Count == 0)
{
BeltBagOwners.Remove(__instance);
lastBagShown = null;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BeltBagItem), "TryCheckBagContents")]
public static void TryCheckBagContentsPatch(BeltBagItem __instance)
{
if ((Object)(object)__instance == (Object)null)
{
lastBagShown = null;
}
else if (!((Object)(object)lastBagShown == (Object)(object)__instance))
{
string owner = GetOwner(__instance);
if (owner != null)
{
HUDManager.Instance.DisplayTip("Belt Bag Owner", owner, false, false, "LC_Tip1");
lastBagShown = __instance;
}
}
}
}
}