Decompiled source of Scout Utility Belt v1.0.0

plugins/OvrSlepr_ScoutUtilityBelt.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OvrSlepr.ScoutUtilityBelt.Items;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using Zorro.Core;

[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("OvrSlepr_ScoutUtilityBelt")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OvrSlepr_ScoutUtilityBelt")]
[assembly: AssemblyTitle("OvrSlepr_ScoutUtilityBelt")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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 OvrSlepr.ScoutUtilityBelt
{
	public class BeltInputController : MonoBehaviour
	{
		private Character? character;

		private ScoutUtilityBeltController? beltController;

		private bool initialized;

		public void Initialize(Character character, ScoutUtilityBeltController beltController)
		{
			if (!initialized)
			{
				this.character = character;
				this.beltController = beltController;
				initialized = true;
			}
		}

		private void Update()
		{
			if (initialized && !((Object)(object)character == (Object)null) && !((Object)(object)beltController == (Object)null) && character.IsLocal)
			{
				bool flag = Keyboard.current != null && ((ButtonControl)Keyboard.current.digit5Key).wasPressedThisFrame;
				bool flag2 = Gamepad.current != null && Gamepad.current.dpad.down.wasPressedThisFrame;
				if (flag || flag2)
				{
					ToggleBelt();
				}
			}
		}

		private void ToggleBelt()
		{
			if (!((Object)(object)beltController == (Object)null))
			{
				if ((Object)(object)beltController.AttachedItem != (Object)null)
				{
					beltController.TryRemoveItem();
				}
				else
				{
					TryAttachItem();
				}
			}
		}

		private void TryAttachItem()
		{
			Item currentItem = character.data.currentItem;
			if (!((Object)(object)currentItem == (Object)null))
			{
				ushort itemID = currentItem.itemID;
				if (itemID == 13 || itemID == 14 || itemID == 15 || itemID == 23 || itemID == 32 || itemID == 42 || itemID == 61 || itemID == 78 || (Plugin.MikuFumoItemID != 0 && itemID == Plugin.MikuFumoItemID))
				{
					beltController.TryAttachItem(currentItem);
				}
			}
		}
	}
	public class BeltPromptController : MonoBehaviour
	{
		private Character? character;

		private ScoutUtilityBeltController? beltController;

		private GameObject? promptObject;

		private TextMeshProUGUI? promptText;

		private TextMeshProUGUI? iconText;

		private const string KeyboardIcon = "<sprite=5 tint=1>";

		private const string GamepadIcon = "<sprite=13 tint=1>";

		private static readonly string[] AttachTranslations = new string[15]
		{
			"Attach to belt", "Attacher à la ceinture", "Fissa alla cintura", "Am Gürtel befestigen", "Sujetar al cinturón", "Sujetar al cinturón", "Prender ao cinto", "Закрепить на поясе", "Закріпити на поясі", "固定到腰带",
			"固定到腰帶", "ベルトに装着", "벨트에 장착", "Przypnij do pasa", "Kemerine tak"
		};

		private static readonly string[] RemoveTranslations = new string[15]
		{
			"Remove from belt", "Retirer de la ceinture", "Rimuovi dalla cintura", "Vom Gürtel entfernen", "Quitar del cinturón", "Quitar del cinturón", "Remover do cinto", "Снять с пояса", "Зняти з пояса", "从腰带取下",
			"從腰帶取下", "ベルトから外す", "벨트에서 제거", "Odepnij od pasa", "Kemerden çıkar"
		};

		private static string GetLocalizedPrompt(bool remove)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			int num = (int)LocalizedText.CURRENT_LANGUAGE;
			string[] array = (remove ? RemoveTranslations : AttachTranslations);
			if (num < 0 || num >= array.Length)
			{
				num = 0;
			}
			return array[num];
		}

		public void Initialize(Character character, ScoutUtilityBeltController beltController)
		{
			this.character = character;
			this.beltController = beltController;
		}

		private void Update()
		{
			if ((Object)(object)character == (Object)null || (Object)(object)beltController == (Object)null)
			{
				return;
			}
			if (!character.IsLocal)
			{
				SetPromptVisible(visible: false);
				return;
			}
			if ((Object)(object)promptObject == (Object)null)
			{
				CreatePrompt();
			}
			if (!((Object)(object)promptObject == (Object)null))
			{
				UpdatePrompt();
			}
		}

		private void CreatePrompt()
		{
			if ((Object)(object)GUIManager.instance == (Object)null)
			{
				return;
			}
			Transform val = FindChild(((Component)GUIManager.instance).transform, "ItemPromptLayout");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = FindChild(val, "ItemPromptMain");
			if (!((Object)(object)val2 == (Object)null))
			{
				promptObject = Object.Instantiate<GameObject>(((Component)val2).gameObject, val2.parent, false);
				((Object)promptObject).name = "ItemPromptBelt";
				promptText = promptObject.GetComponent<TextMeshProUGUI>();
				Transform val3 = FindChild(promptObject.transform, "UI_InputIcon");
				if ((Object)(object)val3 != (Object)null)
				{
					iconText = ((Component)val3).GetComponentInChildren<TextMeshProUGUI>();
				}
				if ((Object)(object)promptText == (Object)null || (Object)(object)iconText == (Object)null)
				{
					Object.Destroy((Object)(object)promptObject);
					promptObject = null;
				}
				else
				{
					promptObject.SetActive(false);
				}
			}
		}

		private void UpdatePrompt()
		{
			if ((Object)(object)promptText == (Object)null || (Object)(object)iconText == (Object)null || (Object)(object)beltController == (Object)null || (Object)(object)character == (Object)null)
			{
				return;
			}
			if ((Object)(object)beltController.AttachedItem != (Object)null)
			{
				((TMP_Text)promptText).text = GetLocalizedPrompt(remove: true);
				SetPromptVisible(visible: true);
			}
			else
			{
				Item currentItem = character.data.currentItem;
				if ((Object)(object)currentItem == (Object)null || !IsSupportedItem(currentItem.itemID))
				{
					SetPromptVisible(visible: false);
					return;
				}
				((TMP_Text)promptText).text = GetLocalizedPrompt(remove: false);
				SetPromptVisible(visible: true);
			}
			UpdateIcon();
		}

		private void UpdateIcon()
		{
			if (!((Object)(object)iconText == (Object)null))
			{
				string text = (((Object)(object)((TMP_Text)iconText).spriteAsset != (Object)null) ? ((Object)((TMP_Text)iconText).spriteAsset).name.ToLowerInvariant() : "");
				bool flag = text.Contains("keyboard");
				((TMP_Text)iconText).text = (flag ? "<sprite=5 tint=1>" : "<sprite=13 tint=1>");
			}
		}

		private void SetPromptVisible(bool visible)
		{
			if ((Object)(object)promptObject != (Object)null && promptObject.activeSelf != visible)
			{
				promptObject.SetActive(visible);
			}
		}

		private static bool IsSupportedItem(ushort itemID)
		{
			return itemID == 13 || itemID == 14 || itemID == 15 || itemID == 23 || itemID == 32 || itemID == 42 || itemID == 61 || itemID == 78 || (Plugin.MikuFumoItemID != 0 && itemID == Plugin.MikuFumoItemID);
		}

		private static Transform? FindChild(Transform parent, string childName)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == childName)
				{
					return val;
				}
				Transform val2 = FindChild(val, childName);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}

		private void OnDestroy()
		{
			if ((Object)(object)promptObject != (Object)null)
			{
				Object.Destroy((Object)(object)promptObject);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "GoDeadMode")]
	public static class CharacterDeathPatch
	{
		[HarmonyPrefix]
		private static void Prefix(Character __instance)
		{
			DropBeltItem(__instance);
		}

		private static void DropBeltItem(Character character)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)character == (Object)null || !((MonoBehaviourPun)character).photonView.IsMine)
			{
				return;
			}
			ScoutUtilityBeltController component = ((Component)character).GetComponent<ScoutUtilityBeltController>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)component.AttachedItem == (Object)null))
			{
				Vector3 val = character.LastLivingPosition;
				if (val == Vector3.zero)
				{
					val = character.Center;
				}
				component.RequestDropAttachedItemOnDeath(val + Vector3.up * 0.5f);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "FinishZombifying")]
	public static class CharacterZombifyDeathPatch
	{
		[HarmonyPrefix]
		private static void Prefix(Character __instance)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || !((MonoBehaviourPun)__instance).photonView.IsMine)
			{
				return;
			}
			ScoutUtilityBeltController component = ((Component)__instance).GetComponent<ScoutUtilityBeltController>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)component.AttachedItem == (Object)null))
			{
				Vector3 val = __instance.LastLivingPosition;
				if (val == Vector3.zero)
				{
					val = __instance.Center;
				}
				component.RequestDropAttachedItemOnDeath(val + Vector3.up * 0.5f);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Start")]
	internal static class CharacterPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Character __instance)
		{
			Plugin.InitializeCharacter(__instance);
		}
	}
	[BepInPlugin("OvrSlepr.ScoutUtilityBelt", "Scout Utility Belt", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private Harmony? harmony;

		internal static Transform? BugleVisualPrefab { get; private set; }

		internal static Transform? CompassVisualPrefab { get; private set; }

		internal static Transform? FlareVisualPrefab { get; private set; }

		internal static Transform? MegaphoneVisualPrefab { get; private set; }

		internal static Transform? BinocularsVisualPrefab { get; private set; }

		internal static Transform? LanternVisualPrefab { get; private set; }

		internal static Transform? PirateCompassVisualPrefab { get; private set; }

		internal static Transform? BingBongVisualPrefab { get; private set; }

		internal static Transform? MikuFumoVisualPrefab { get; private set; }

		internal static ushort MikuFumoItemID { get; private set; }

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			harmony = new Harmony("OvrSlepr.ScoutUtilityBelt");
			harmony.PatchAll();
			Log.LogInfo((object)"Scout Utility Belt loaded!");
			Log.LogInfo((object)"Harmony patches applied!");
			((MonoBehaviour)this).StartCoroutine(LoadCompassVisual());
			((MonoBehaviour)this).StartCoroutine(LoadFlareVisual());
			((MonoBehaviour)this).StartCoroutine(LoadMegaphoneVisual());
			((MonoBehaviour)this).StartCoroutine(LoadBinocularsVisual());
			((MonoBehaviour)this).StartCoroutine(LoadLanternVisual());
			((MonoBehaviour)this).StartCoroutine(LoadPirateCompassVisual());
			((MonoBehaviour)this).StartCoroutine(LoadBugleVisual());
			((MonoBehaviour)this).StartCoroutine(LoadBingBongVisual());
			((MonoBehaviour)this).StartCoroutine(LoadMikuFumoVisual());
		}

		private IEnumerator LoadCompassVisual()
		{
			Item compassItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)compassItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)23, ref foundItem))
				{
					compassItem = foundItem;
				}
				if ((Object)(object)compassItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			Log.LogInfo((object)"Original Compass item found!");
			Transform compassVisual = compassItem.transform.Find("Compass");
			if ((Object)(object)compassVisual == (Object)null)
			{
				Log.LogError((object)"[ScoutUtilityBelt] Compass visual child not found!");
				yield break;
			}
			CompassVisualPrefab = compassVisual;
			Log.LogInfo((object)"[ScoutUtilityBelt] Compass visual prefab loaded!");
			InitializeAllCharacters();
		}

		private IEnumerator LoadFlareVisual()
		{
			Item flareItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)flareItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)32, ref foundItem))
				{
					flareItem = foundItem;
				}
				if ((Object)(object)flareItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			Log.LogInfo((object)"Original Flare item found!");
			Transform flareMesh = flareItem.transform.Find("Mesh");
			if ((Object)(object)flareMesh == (Object)null)
			{
				Log.LogError((object)"[ScoutUtilityBelt] Flare Mesh not found!");
				yield break;
			}
			FlareVisualPrefab = flareMesh;
			Log.LogInfo((object)"[ScoutUtilityBelt] Flare Mesh loaded!");
			InitializeAllCharacters();
		}

		private IEnumerator LoadBugleVisual()
		{
			Item bugleItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)bugleItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)15, ref foundItem))
				{
					bugleItem = foundItem;
				}
				if ((Object)(object)bugleItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			Log.LogInfo((object)"Original Bugle item found!");
			Transform bugleVisual = bugleItem.transform.Find("Bugle");
			if ((Object)(object)bugleVisual == (Object)null)
			{
				Log.LogError((object)"[ScoutUtilityBelt] Bugle visual not found!");
				yield break;
			}
			BugleVisualPrefab = bugleVisual;
			Log.LogInfo((object)"[ScoutUtilityBelt] Bugle visual loaded!");
			InitializeAllCharacters();
		}

		private IEnumerator LoadMegaphoneVisual()
		{
			Item megaphoneItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)megaphoneItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)78, ref foundItem))
				{
					megaphoneItem = foundItem;
				}
				if ((Object)(object)megaphoneItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			Log.LogInfo((object)"Original Megaphone item found!");
			Transform megaphoneMesh = megaphoneItem.transform.Find("Mesh");
			if ((Object)(object)megaphoneMesh == (Object)null)
			{
				Log.LogError((object)"[ScoutUtilityBelt] Megaphone Mesh not found!");
				yield break;
			}
			MegaphoneVisualPrefab = megaphoneMesh;
			Log.LogInfo((object)"[ScoutUtilityBelt] Megaphone Mesh loaded!");
			InitializeAllCharacters();
		}

		private IEnumerator LoadBinocularsVisual()
		{
			Item binocularsItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)binocularsItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)14, ref foundItem))
				{
					binocularsItem = foundItem;
				}
				if ((Object)(object)binocularsItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			Log.LogInfo((object)"Original Binoculars item found!");
			Transform binocularsMesh = binocularsItem.transform.Find("binoculars");
			if ((Object)(object)binocularsMesh == (Object)null)
			{
				Log.LogError((object)"[ScoutUtilityBelt] Binoculars Mesh not found!");
				yield break;
			}
			BinocularsVisualPrefab = binocularsMesh;
			Log.LogInfo((object)"[ScoutUtilityBelt] Binoculars Mesh loaded!");
			InitializeAllCharacters();
		}

		private IEnumerator LoadLanternVisual()
		{
			Item lanternItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)lanternItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)42, ref foundItem))
				{
					lanternItem = foundItem;
				}
				if ((Object)(object)lanternItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			Log.LogInfo((object)"Original Lantern item found!");
			Transform lanternVisual = lanternItem.transform.Find("GasLantern");
			if ((Object)(object)lanternVisual == (Object)null)
			{
				Log.LogError((object)"[ScoutUtilityBelt] GasLantern not found!");
				yield break;
			}
			LanternVisualPrefab = lanternVisual;
			Log.LogInfo((object)"[ScoutUtilityBelt] Lantern visual loaded!");
			InitializeAllCharacters();
		}

		private IEnumerator LoadPirateCompassVisual()
		{
			Item pirateCompassItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)pirateCompassItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)61, ref foundItem))
				{
					pirateCompassItem = foundItem;
				}
				if ((Object)(object)pirateCompassItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			Log.LogInfo((object)"Original Pirate Compass item found!");
			Transform compassVisual = pirateCompassItem.transform.Find("Compass");
			if ((Object)(object)compassVisual == (Object)null)
			{
				Log.LogError((object)"[ScoutUtilityBelt] Pirate Compass Mesh not found!");
				yield break;
			}
			PirateCompassVisualPrefab = compassVisual;
			Log.LogInfo((object)"[ScoutUtilityBelt] Pirate Compass visual loaded!");
			InitializeAllCharacters();
		}

		private IEnumerator LoadBingBongVisual()
		{
			Item bingBongItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)bingBongItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)13, ref foundItem))
				{
					bingBongItem = foundItem;
				}
				if ((Object)(object)bingBongItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			Log.LogInfo((object)"Original BingBong item found!");
			BingBongVisualPrefab = bingBongItem.transform;
			Log.LogInfo((object)"[ScoutUtilityBelt] BingBong visual prefab loaded!");
			InitializeAllCharacters();
		}

		private IEnumerator LoadMikuFumoVisual()
		{
			Item mikuItem = null;
			Item foundItem = default(Item);
			while ((Object)(object)mikuItem == (Object)null)
			{
				if (ItemDatabase.TryGetItem((ushort)12671, ref foundItem))
				{
					mikuItem = foundItem;
				}
				if ((Object)(object)mikuItem == (Object)null)
				{
					yield return null;
				}
				foundItem = null;
			}
			MikuFumoItemID = mikuItem.itemID;
			Transform mikuModel = mikuItem.transform.Find("miku");
			if ((Object)(object)mikuModel == (Object)null)
			{
				Log.LogError((object)"[ScoutUtilityBelt] Miku model child not found!");
				yield break;
			}
			MikuFumoVisualPrefab = mikuModel;
			Log.LogInfo((object)("[ScoutUtilityBelt] Miku Fumo visual loaded! ID: " + MikuFumoItemID));
			InitializeAllCharacters();
		}

		private static void InitializeAllCharacters()
		{
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if ((Object)(object)allCharacter != (Object)null)
				{
					InitializeCharacter(allCharacter);
				}
			}
		}

		internal static void InitializeCharacter(Character character)
		{
			if (!((Object)(object)character == (Object)null))
			{
				ScoutUtilityBeltController scoutUtilityBeltController = ((Component)character).GetComponent<ScoutUtilityBeltController>();
				if ((Object)(object)scoutUtilityBeltController == (Object)null)
				{
					scoutUtilityBeltController = ((Component)character).gameObject.AddComponent<ScoutUtilityBeltController>();
				}
				BeltPromptController beltPromptController = ((Component)character).GetComponent<BeltPromptController>();
				if ((Object)(object)beltPromptController == (Object)null)
				{
					beltPromptController = ((Component)character).gameObject.AddComponent<BeltPromptController>();
				}
				beltPromptController.Initialize(character, scoutUtilityBeltController);
				scoutUtilityBeltController.Initialize(character);
				BeltInputController beltInputController = ((Component)character).GetComponent<BeltInputController>();
				if ((Object)(object)beltInputController == (Object)null)
				{
					beltInputController = ((Component)character).gameObject.AddComponent<BeltInputController>();
				}
				beltInputController.Initialize(character, scoutUtilityBeltController);
			}
		}
	}
	public class ScoutUtilityBeltController : MonoBehaviour
	{
		private Character? character;

		private bool removeRequestPending;

		private bool removeInProgress;

		private bool initialized;

		private bool deathDropRequested;

		private bool deathDropBroadcasted;

		public Transform? BeltRoot { get; private set; }

		public Transform? AttachmentPoint { get; private set; }

		public Item? AttachedItem { get; private set; }

		public void Initialize(Character character)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized && !((Object)(object)character == (Object)null))
			{
				this.character = character;
				Transform parent = (((Object)(object)character.refs.rigCreator != (Object)null) ? ((Component)character.refs.rigCreator).transform : ((Component)character).transform);
				Transform val = FindDeepChild(parent, "WaistR1");
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogWarning((object)("[ScoutUtilityBelt] WaistR1 not found on " + ((Object)character).name));
					return;
				}
				GameObject val2 = new GameObject("ScoutUtilityBelt");
				Transform transform = val2.transform;
				transform.SetParent(val, false);
				GameObject val3 = new GameObject("BeltAttachmentPoint");
				Transform transform2 = val3.transform;
				transform2.SetParent(transform, false);
				transform2.localPosition = Vector3.zero;
				transform2.localRotation = Quaternion.identity;
				transform2.localScale = Vector3.one;
				BeltRoot = transform;
				AttachmentPoint = transform2;
				initialized = true;
				Plugin.Log.LogInfo((object)("[ScoutUtilityBelt] Initialized on " + ((Object)character).name));
			}
		}

		private Rigidbody? GetHandRigidbody(BodypartType hand)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			object? obj = typeof(Character).GetMethod("GetBodypartRig", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(character, new object[1] { hand });
			return (Rigidbody?)((obj is Rigidbody) ? obj : null);
		}

		private void SetItemGround(Item item)
		{
			typeof(Item).GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[2]
			{
				typeof(ItemState),
				typeof(Character)
			}, null)?.Invoke(item, new object[2]
			{
				(object)(ItemState)0,
				null
			});
		}

		private void ReleaseItemFromHands(Item item)
		{
			if ((Object)(object)character == (Object)null || (Object)(object)item == (Object)null)
			{
				return;
			}
			CharacterItems items = character.refs.items;
			if ((Object)(object)character.data.currentItem == (Object)(object)item)
			{
				items.UnAttachEquippedItem();
			}
			Rigidbody handRigidbody = GetHandRigidbody((BodypartType)10);
			Rigidbody handRigidbody2 = GetHandRigidbody((BodypartType)7);
			if ((Object)(object)handRigidbody != (Object)null)
			{
				FixedJoint[] components = ((Component)handRigidbody).GetComponents<FixedJoint>();
				foreach (FixedJoint val in components)
				{
					if ((Object)(object)((Joint)val).connectedBody == (Object)(object)item.rig)
					{
						Object.Destroy((Object)(object)val);
					}
				}
			}
			if ((Object)(object)handRigidbody2 != (Object)null)
			{
				FixedJoint[] components2 = ((Component)handRigidbody2).GetComponents<FixedJoint>();
				foreach (FixedJoint val2 in components2)
				{
					if ((Object)(object)((Joint)val2).connectedBody == (Object)(object)item.rig)
					{
						Object.Destroy((Object)(object)val2);
					}
				}
			}
			item.holderCharacter = null;
			if ((Object)(object)character.data.currentItem == (Object)(object)item)
			{
				character.data.currentItem = null;
			}
		}

		private bool IsVisualPrefabLoaded(ushort itemID)
		{
			return itemID switch
			{
				23 => (Object)(object)Plugin.CompassVisualPrefab != (Object)null, 
				42 => (Object)(object)Plugin.LanternVisualPrefab != (Object)null, 
				61 => (Object)(object)Plugin.PirateCompassVisualPrefab != (Object)null, 
				78 => (Object)(object)Plugin.MegaphoneVisualPrefab != (Object)null, 
				32 => (Object)(object)Plugin.FlareVisualPrefab != (Object)null, 
				15 => (Object)(object)Plugin.BugleVisualPrefab != (Object)null, 
				14 => (Object)(object)Plugin.BinocularsVisualPrefab != (Object)null, 
				13 => (Object)(object)Plugin.BingBongVisualPrefab != (Object)null, 
				12671 => (Object)(object)Plugin.MikuFumoVisualPrefab != (Object)null, 
				_ => false, 
			};
		}

		private bool InitializeBeltVisual(Item item)
		{
			if ((Object)(object)AttachmentPoint == (Object)null)
			{
				return false;
			}
			switch (item.itemID)
			{
			case 23:
			{
				if ((Object)(object)Plugin.CompassVisualPrefab == (Object)null)
				{
					return false;
				}
				CompassBeltController compassBeltController = ((Component)this).GetComponent<CompassBeltController>();
				if ((Object)(object)compassBeltController == (Object)null)
				{
					compassBeltController = ((Component)this).gameObject.AddComponent<CompassBeltController>();
				}
				return compassBeltController.Initialize(Plugin.CompassVisualPrefab, AttachmentPoint);
			}
			case 42:
			{
				if ((Object)(object)Plugin.LanternVisualPrefab == (Object)null)
				{
					return false;
				}
				LanternBeltController lanternBeltController = ((Component)this).GetComponent<LanternBeltController>();
				if ((Object)(object)lanternBeltController == (Object)null)
				{
					lanternBeltController = ((Component)this).gameObject.AddComponent<LanternBeltController>();
				}
				return lanternBeltController.Initialize(Plugin.LanternVisualPrefab, AttachmentPoint);
			}
			case 61:
			{
				if ((Object)(object)Plugin.PirateCompassVisualPrefab == (Object)null)
				{
					return false;
				}
				PirateCompassBeltController pirateCompassBeltController = ((Component)this).GetComponent<PirateCompassBeltController>();
				if ((Object)(object)pirateCompassBeltController == (Object)null)
				{
					pirateCompassBeltController = ((Component)this).gameObject.AddComponent<PirateCompassBeltController>();
				}
				return pirateCompassBeltController.Initialize(Plugin.PirateCompassVisualPrefab, AttachmentPoint);
			}
			case 78:
			{
				if ((Object)(object)Plugin.MegaphoneVisualPrefab == (Object)null)
				{
					return false;
				}
				MegaphoneBeltController megaphoneBeltController = ((Component)this).GetComponent<MegaphoneBeltController>();
				if ((Object)(object)megaphoneBeltController == (Object)null)
				{
					megaphoneBeltController = ((Component)this).gameObject.AddComponent<MegaphoneBeltController>();
				}
				return megaphoneBeltController.Initialize(Plugin.MegaphoneVisualPrefab, AttachmentPoint);
			}
			case 32:
			{
				if ((Object)(object)Plugin.FlareVisualPrefab == (Object)null)
				{
					return false;
				}
				FlareBeltController flareBeltController = ((Component)this).GetComponent<FlareBeltController>();
				if ((Object)(object)flareBeltController == (Object)null)
				{
					flareBeltController = ((Component)this).gameObject.AddComponent<FlareBeltController>();
				}
				return flareBeltController.Initialize(Plugin.FlareVisualPrefab, AttachmentPoint);
			}
			case 15:
			{
				if ((Object)(object)Plugin.BugleVisualPrefab == (Object)null)
				{
					return false;
				}
				BugleBeltController bugleBeltController = ((Component)this).GetComponent<BugleBeltController>();
				if ((Object)(object)bugleBeltController == (Object)null)
				{
					bugleBeltController = ((Component)this).gameObject.AddComponent<BugleBeltController>();
				}
				return bugleBeltController.Initialize(Plugin.BugleVisualPrefab, AttachmentPoint);
			}
			case 14:
			{
				if ((Object)(object)Plugin.BinocularsVisualPrefab == (Object)null)
				{
					return false;
				}
				BinocularsBeltController binocularsBeltController = ((Component)this).GetComponent<BinocularsBeltController>();
				if ((Object)(object)binocularsBeltController == (Object)null)
				{
					binocularsBeltController = ((Component)this).gameObject.AddComponent<BinocularsBeltController>();
				}
				return binocularsBeltController.Initialize(Plugin.BinocularsVisualPrefab, AttachmentPoint);
			}
			case 13:
			{
				if ((Object)(object)Plugin.BingBongVisualPrefab == (Object)null)
				{
					return false;
				}
				BingBongBeltController bingBongBeltController = ((Component)this).GetComponent<BingBongBeltController>();
				if ((Object)(object)bingBongBeltController == (Object)null)
				{
					bingBongBeltController = ((Component)this).gameObject.AddComponent<BingBongBeltController>();
				}
				return bingBongBeltController.Initialize(Plugin.BingBongVisualPrefab, AttachmentPoint);
			}
			case 12671:
			{
				if ((Object)(object)Plugin.MikuFumoVisualPrefab == (Object)null)
				{
					return false;
				}
				MikuFumoBeltController mikuFumoBeltController = ((Component)this).GetComponent<MikuFumoBeltController>();
				if ((Object)(object)mikuFumoBeltController == (Object)null)
				{
					mikuFumoBeltController = ((Component)this).gameObject.AddComponent<MikuFumoBeltController>();
				}
				return mikuFumoBeltController.Initialize(Plugin.MikuFumoVisualPrefab, AttachmentPoint);
			}
			default:
				return false;
			}
		}

		private void RemoveBeltVisual(Item item)
		{
			switch (item.itemID)
			{
			case 23:
			{
				CompassBeltController component2 = ((Component)this).GetComponent<CompassBeltController>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.RemoveVisual();
				}
				break;
			}
			case 42:
			{
				LanternBeltController component6 = ((Component)this).GetComponent<LanternBeltController>();
				if ((Object)(object)component6 != (Object)null)
				{
					component6.RemoveVisual();
				}
				break;
			}
			case 61:
			{
				PirateCompassBeltController component8 = ((Component)this).GetComponent<PirateCompassBeltController>();
				if ((Object)(object)component8 != (Object)null)
				{
					component8.RemoveVisual();
				}
				break;
			}
			case 78:
			{
				MegaphoneBeltController component4 = ((Component)this).GetComponent<MegaphoneBeltController>();
				if ((Object)(object)component4 != (Object)null)
				{
					component4.RemoveVisual();
				}
				break;
			}
			case 32:
			{
				FlareBeltController component9 = ((Component)this).GetComponent<FlareBeltController>();
				if ((Object)(object)component9 != (Object)null)
				{
					component9.RemoveVisual();
				}
				break;
			}
			case 15:
			{
				BugleBeltController component7 = ((Component)this).GetComponent<BugleBeltController>();
				if ((Object)(object)component7 != (Object)null)
				{
					component7.RemoveVisual();
				}
				break;
			}
			case 14:
			{
				BinocularsBeltController component5 = ((Component)this).GetComponent<BinocularsBeltController>();
				if ((Object)(object)component5 != (Object)null)
				{
					component5.RemoveVisual();
				}
				break;
			}
			case 13:
			{
				BingBongBeltController component3 = ((Component)this).GetComponent<BingBongBeltController>();
				if ((Object)(object)component3 != (Object)null)
				{
					component3.RemoveVisual();
				}
				break;
			}
			case 12671:
			{
				MikuFumoBeltController component = ((Component)this).GetComponent<MikuFumoBeltController>();
				if ((Object)(object)component != (Object)null)
				{
					component.RemoveVisual();
				}
				break;
			}
			}
		}

		[PunRPC]
		private void RPCA_AttachItemToBelt(int itemViewID)
		{
			((MonoBehaviour)this).StartCoroutine(ApplyRemoteItemAttach(itemViewID));
		}

		private IEnumerator ApplyRemoteItemAttach(int itemViewID)
		{
			Item item = null;
			while ((Object)(object)item == (Object)null)
			{
				PhotonView itemView = PhotonView.Find(itemViewID);
				if ((Object)(object)itemView != (Object)null)
				{
					item = ((Component)itemView).GetComponent<Item>();
				}
				if ((Object)(object)item == (Object)null)
				{
					yield return null;
				}
			}
			while ((Object)(object)AttachmentPoint == (Object)null || !IsVisualPrefabLoaded(item.itemID))
			{
				yield return null;
			}
			if ((Object)(object)AttachedItem == (Object)(object)item)
			{
				yield break;
			}
			if ((Object)(object)AttachedItem != (Object)null)
			{
				Plugin.Log.LogWarning((object)"[ScoutUtilityBelt] Another item is already attached!");
				yield break;
			}
			if (!InitializeBeltVisual(item))
			{
				Plugin.Log.LogError((object)"[ScoutUtilityBelt] Failed to create remote item visual!");
				yield break;
			}
			item.OnStash();
			ReleaseItemFromHands(item);
			if ((Object)(object)character != (Object)null && character.refs.items.currentSelectedSlot.IsSome && (Object)(object)character.data.currentItem == (Object)null)
			{
				character.refs.items.currentSelectedSlot = Optionable<byte>.None;
			}
			SetItemGround(item);
			AttachedItem = item;
			item.SetKinematicNetworked(true);
			Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer renderer in componentsInChildren)
			{
				renderer.enabled = false;
			}
			Collider[] componentsInChildren2 = ((Component)item).GetComponentsInChildren<Collider>(true);
			foreach (Collider collider in componentsInChildren2)
			{
				collider.enabled = false;
			}
			Plugin.Log.LogInfo((object)("[ScoutUtilityBelt] Remote item attached! ID: " + item.itemID));
		}

		[PunRPC]
		private void RPCA_RequestRemoveItemFromBelt(int itemViewID, PhotonMessageInfo info)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.IsMasterClient && !((Object)(object)character == (Object)null) && info.Sender == ((MonoBehaviourPun)character).photonView.Owner)
			{
				HandleRemoveRequest(itemViewID, info.Sender);
			}
		}

		private void HandleRemoveRequest(int itemViewID, Player sender)
		{
			if (!PhotonNetwork.IsMasterClient || (Object)(object)character == (Object)null || removeInProgress)
			{
				SendRemoveResult(sender, success: false);
				return;
			}
			Item attachedItem = AttachedItem;
			if ((Object)(object)attachedItem == (Object)null || ((MonoBehaviourPun)attachedItem).photonView.ViewID != itemViewID)
			{
				SendRemoveResult(sender, success: false);
				return;
			}
			if ((Object)(object)character.data.currentItem != (Object)null)
			{
				SendRemoveResult(sender, success: false);
				return;
			}
			if (!character.player.HasEmptySlot(attachedItem.itemID))
			{
				SendRemoveResult(sender, success: false);
				return;
			}
			removeInProgress = true;
			ItemSlot val = default(ItemSlot);
			if (!character.player.AddItem(attachedItem.itemID, attachedItem.data, ref val) || val == null)
			{
				removeInProgress = false;
				SendRemoveResult(sender, success: false);
				return;
			}
			int itemSlotID = val.itemSlotID;
			((MonoBehaviourPun)character).photonView.RPC("RPCA_CompleteRemoveItemFromBelt", (RpcTarget)0, new object[2] { itemViewID, itemSlotID });
			SendRemoveResult(sender, success: true);
		}

		private void SendRemoveResult(Player target, bool success)
		{
			if (target == PhotonNetwork.LocalPlayer)
			{
				RPCA_RemoveRequestResult(success);
				return;
			}
			Character? obj = character;
			if (obj != null)
			{
				((MonoBehaviourPun)obj).photonView.RPC("RPCA_RemoveRequestResult", target, new object[1] { success });
			}
		}

		[PunRPC]
		private void RPCA_RemoveRequestResult(bool success)
		{
			removeRequestPending = false;
			if (!success)
			{
				Plugin.Log.LogWarning((object)"[ScoutUtilityBelt] Remove request rejected!");
			}
		}

		[PunRPC]
		private void RPCA_CompleteRemoveItemFromBelt(int itemViewID, int slotID)
		{
			((MonoBehaviour)this).StartCoroutine(ApplyRemoveItemFromBelt(itemViewID, slotID));
		}

		private IEnumerator ApplyRemoveItemFromBelt(int itemViewID, int slotID)
		{
			Item item = null;
			while ((Object)(object)item == (Object)null)
			{
				PhotonView itemView = PhotonView.Find(itemViewID);
				if ((Object)(object)itemView != (Object)null)
				{
					item = ((Component)itemView).GetComponent<Item>();
				}
				if ((Object)(object)item == (Object)null)
				{
					yield return null;
				}
			}
			if ((Object)(object)character == (Object)null)
			{
				yield break;
			}
			ItemSlot slot = null;
			while (slot == null || slot.IsEmpty() || (Object)(object)slot.prefab == (Object)null || slot.prefab.itemID != item.itemID)
			{
				slot = character.player.GetItemSlot((byte)slotID);
				if (slot == null || slot.IsEmpty() || (Object)(object)slot.prefab == (Object)null || slot.prefab.itemID != item.itemID)
				{
					yield return null;
				}
			}
			CharacterItems items = character.refs.items;
			if ((Object)(object)character.data.currentItem != (Object)null)
			{
				Plugin.Log.LogError((object)"[ScoutUtilityBelt] Cannot restore item: hands are occupied!");
				yield break;
			}
			Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer renderer in componentsInChildren)
			{
				renderer.enabled = true;
				renderer.forceRenderingOff = false;
			}
			Collider[] componentsInChildren2 = ((Component)item).GetComponentsInChildren<Collider>(true);
			foreach (Collider collider in componentsInChildren2)
			{
				collider.enabled = true;
			}
			items.currentSelectedSlot = Optionable<byte>.Some((byte)slotID);
			items.lastSelectedSlot = Optionable<byte>.Some((byte)slotID);
			items.Equip(item);
			RemoveBeltVisual(item);
			AttachedItem = null;
			if (PhotonNetwork.IsMasterClient)
			{
				removeInProgress = false;
			}
			if (((MonoBehaviourPun)character).photonView.IsMine && item.itemID == Plugin.MikuFumoItemID)
			{
				Component mikuSqueeze = ((Component)item).GetComponent("MikuFumoSqueeze");
				if ((Object)(object)mikuSqueeze != (Object)null)
				{
					((object)mikuSqueeze).GetType().GetMethod("RequestPickupSound", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(mikuSqueeze, null);
				}
			}
			Plugin.Log.LogInfo((object)("[ScoutUtilityBelt] Original item restored! ID: " + item.itemID));
		}

		public void RequestDropAttachedItemOnDeath(Vector3 dropPosition)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)character == (Object)null) && !((Object)(object)AttachedItem == (Object)null) && !deathDropRequested)
			{
				deathDropRequested = true;
				int viewID = ((MonoBehaviourPun)AttachedItem).photonView.ViewID;
				if (PhotonNetwork.IsMasterClient)
				{
					HandleDeathDropRequest(viewID, dropPosition);
					return;
				}
				((MonoBehaviourPun)character).photonView.RPC("RPCA_RequestDropAttachedItemOnDeath", (RpcTarget)2, new object[2] { viewID, dropPosition });
			}
		}

		private IEnumerator ApplyDeathDrop(int itemViewID, Vector3 dropPosition)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Item item = null;
			while ((Object)(object)item == (Object)null)
			{
				PhotonView itemView = PhotonView.Find(itemViewID);
				if ((Object)(object)itemView != (Object)null)
				{
					item = ((Component)itemView).GetComponent<Item>();
				}
				if ((Object)(object)item == (Object)null)
				{
					yield return null;
				}
			}
			if (!((Object)(object)character == (Object)null))
			{
				RemoveBeltVisual(item);
				item.OnStash();
				item.transform.position = dropPosition;
				item.transform.rotation = ((Component)character).transform.rotation;
				Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer renderer in componentsInChildren)
				{
					renderer.enabled = true;
					renderer.forceRenderingOff = false;
				}
				Collider[] componentsInChildren2 = ((Component)item).GetComponentsInChildren<Collider>(true);
				foreach (Collider collider in componentsInChildren2)
				{
					collider.enabled = true;
				}
				SetItemGround(item);
				if (PhotonNetwork.IsMasterClient)
				{
					item.SetKinematicNetworked(false, dropPosition, item.transform.rotation);
				}
				AttachedItem = null;
				removeRequestPending = false;
				removeInProgress = false;
				deathDropRequested = false;
				deathDropBroadcasted = false;
				Plugin.Log.LogInfo((object)("[ScoutUtilityBelt] Belt item dropped on death! ID: " + item.itemID));
			}
		}

		[PunRPC]
		private void RPCA_RequestDropAttachedItemOnDeath(int itemViewID, Vector3 dropPosition, PhotonMessageInfo info)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.IsMasterClient && !((Object)(object)character == (Object)null) && info.Sender == ((MonoBehaviourPun)character).photonView.Owner)
			{
				HandleDeathDropRequest(itemViewID, dropPosition);
			}
		}

		private void HandleDeathDropRequest(int itemViewID, Vector3 dropPosition)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.IsMasterClient && !((Object)(object)character == (Object)null) && !((Object)(object)AttachedItem == (Object)null) && !deathDropBroadcasted && ((MonoBehaviourPun)AttachedItem).photonView.ViewID == itemViewID)
			{
				deathDropRequested = true;
				deathDropBroadcasted = true;
				((MonoBehaviourPun)character).photonView.RPC("RPCA_DropAttachedItemOnDeath", (RpcTarget)0, new object[2] { itemViewID, dropPosition });
			}
		}

		[PunRPC]
		private void RPCA_DropAttachedItemOnDeath(int itemViewID, Vector3 dropPosition)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(ApplyDeathDrop(itemViewID, dropPosition));
		}

		public bool TryAttachItem(Item item)
		{
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)character == (Object)null || (Object)(object)AttachmentPoint == (Object)null)
			{
				return false;
			}
			if ((Object)(object)AttachedItem != (Object)null)
			{
				return false;
			}
			if ((Object)(object)character.data.currentItem != (Object)(object)item)
			{
				return false;
			}
			if (item.itemID != 13 && item.itemID != 14 && item.itemID != 15 && item.itemID != 23 && item.itemID != 32 && item.itemID != 42 && item.itemID != 61 && item.itemID != 78 && (Plugin.MikuFumoItemID == 0 || item.itemID != Plugin.MikuFumoItemID))
			{
				return false;
			}
			if (!IsVisualPrefabLoaded(item.itemID))
			{
				Plugin.Log.LogWarning((object)("[ScoutUtilityBelt] Item visual prefab is not loaded! ID: " + item.itemID));
				return false;
			}
			if (!character.refs.items.currentSelectedSlot.IsSome)
			{
				return false;
			}
			byte value = character.refs.items.currentSelectedSlot.Value;
			ItemSlot itemSlot = character.player.GetItemSlot(value);
			if (itemSlot == null || itemSlot.IsEmpty())
			{
				return false;
			}
			if (!InitializeBeltVisual(item))
			{
				return false;
			}
			item.OnStash();
			ReleaseItemFromHands(item);
			character.refs.items.currentSelectedSlot = Optionable<byte>.None;
			SetItemGround(item);
			deathDropRequested = false;
			deathDropBroadcasted = false;
			AttachedItem = item;
			Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				val.enabled = false;
			}
			Collider[] componentsInChildren2 = ((Component)item).GetComponentsInChildren<Collider>(true);
			foreach (Collider val2 in componentsInChildren2)
			{
				val2.enabled = false;
			}
			item.rig.linearVelocity = Vector3.zero;
			item.rig.angularVelocity = Vector3.zero;
			item.SetKinematic(true);
			character.player.EmptySlot(Optionable<byte>.Some(value), true);
			character.refs.items.RefreshAllCharacterCarryWeight();
			((MonoBehaviourPun)character).photonView.RPC("RPCA_AttachItemToBelt", (RpcTarget)1, new object[1] { ((MonoBehaviourPun)item).photonView.ViewID });
			Plugin.Log.LogInfo((object)("[ScoutUtilityBelt] Item attached to belt! ID: " + item.itemID));
			return true;
		}

		public bool TryRemoveItem()
		{
			if ((Object)(object)character == (Object)null || (Object)(object)AttachedItem == (Object)null)
			{
				return false;
			}
			if (removeRequestPending)
			{
				return false;
			}
			if ((Object)(object)character.data.currentItem != (Object)null)
			{
				Plugin.Log.LogWarning((object)"[ScoutUtilityBelt] Hands must be empty!");
				return false;
			}
			Item attachedItem = AttachedItem;
			removeRequestPending = true;
			int viewID = ((MonoBehaviourPun)attachedItem).photonView.ViewID;
			if (PhotonNetwork.IsMasterClient)
			{
				HandleRemoveRequest(viewID, PhotonNetwork.LocalPlayer);
			}
			else
			{
				((MonoBehaviourPun)character).photonView.RPC("RPCA_RequestRemoveItemFromBelt", (RpcTarget)2, new object[1] { viewID });
			}
			return true;
		}

		private Transform? FindDeepChild(Transform parent, string targetName)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == targetName)
				{
					return val;
				}
				Transform val2 = FindDeepChild(val, targetName);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}
	}
}
namespace OvrSlepr.ScoutUtilityBelt.Items
{
	public class BingBongBeltController : MonoBehaviour
	{
		private GameObject? bingBongObject;

		private static readonly Vector3 BingBongPosition = new Vector3(0.1f, 0.6236f, 1.2f);

		private static readonly Vector3 BingBongRotation = new Vector3(17.4292f, 176.7982f, 266.55f);

		private static readonly Vector3 BingBongScale = new Vector3(2.3f, 2.3f, 2.3f);

		public bool Initialize(Transform bingBongPrefab, Transform attachmentPoint)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bingBongObject != (Object)null)
			{
				return true;
			}
			if ((Object)(object)bingBongPrefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			Transform val = FindDeepChild(bingBongPrefab, "Holder");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogError((object)"[ScoutUtilityBelt] BingBong Holder not found!");
				return false;
			}
			bingBongObject = Object.Instantiate<GameObject>(((Component)val).gameObject, attachmentPoint, false);
			((Object)bingBongObject).name = "BeltBingBong_Visual";
			Transform transform = bingBongObject.transform;
			transform.localPosition = BingBongPosition;
			transform.localRotation = Quaternion.Euler(BingBongRotation);
			transform.localScale = BingBongScale;
			Collider[] componentsInChildren = bingBongObject.GetComponentsInChildren<Collider>(true);
			Collider[] array = componentsInChildren;
			foreach (Collider val2 in array)
			{
				Object.Destroy((Object)(object)val2);
			}
			bingBongObject.SetActive(true);
			Renderer[] componentsInChildren2 = bingBongObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array2 = componentsInChildren2;
			foreach (Renderer val3 in array2)
			{
				val3.enabled = true;
				val3.forceRenderingOff = false;
			}
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] BingBong visual created!");
			return true;
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)bingBongObject == (Object)null))
			{
				Object.Destroy((Object)(object)bingBongObject);
				bingBongObject = null;
			}
		}

		private void OnDestroy()
		{
			RemoveVisual();
		}

		private Transform? FindDeepChild(Transform parent, string targetName)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == targetName)
				{
					return val;
				}
				Transform val2 = FindDeepChild(val, targetName);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}
	}
	public class BinocularsBeltController : MonoBehaviour
	{
		private GameObject? binocularsObject;

		private static readonly Vector3 BinocularsPosition = new Vector3(0.7218f, 1.0727f, 0.1f);

		private static readonly Vector3 BinocularsRotation = new Vector3(357.7762f, 91.1868f, 14.428f);

		private static readonly Vector3 BinocularsScale = new Vector3(0.4f, 0.4f, 0.4f);

		public bool Initialize(Transform binocularsPrefab, Transform attachmentPoint)
		{
			//IL_006b: 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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)binocularsObject != (Object)null)
			{
				return true;
			}
			if ((Object)(object)binocularsPrefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			binocularsObject = Object.Instantiate<GameObject>(((Component)binocularsPrefab).gameObject, attachmentPoint, false);
			((Object)binocularsObject).name = "BeltBinoculars_Visual";
			Transform transform = binocularsObject.transform;
			transform.localPosition = BinocularsPosition;
			transform.localRotation = Quaternion.Euler(BinocularsRotation);
			transform.localScale = BinocularsScale;
			Collider[] componentsInChildren = binocularsObject.GetComponentsInChildren<Collider>(true);
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				Object.Destroy((Object)(object)val);
			}
			binocularsObject.SetActive(true);
			Renderer[] componentsInChildren2 = binocularsObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array2 = componentsInChildren2;
			foreach (Renderer val2 in array2)
			{
				val2.enabled = true;
				val2.forceRenderingOff = false;
			}
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Binoculars visual created!");
			return true;
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)binocularsObject == (Object)null))
			{
				Object.Destroy((Object)(object)binocularsObject);
				binocularsObject = null;
			}
		}

		private void OnDestroy()
		{
			RemoveVisual();
		}
	}
	public class BugleBeltController : MonoBehaviour
	{
		private GameObject? bugleObject;

		private static readonly Vector3 BuglePosition = new Vector3(0.5544f, 0.8664f, -0.4296f);

		private static readonly Vector3 BugleRotation = new Vector3(349.0894f, 312.4979f, 27.72f);

		private static readonly Vector3 BugleScale = new Vector3(0.3108f, 0.3836f, 0.3218f);

		public bool Initialize(Transform itemPrefab, Transform attachmentPoint)
		{
			//IL_006b: 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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bugleObject != (Object)null)
			{
				return true;
			}
			if ((Object)(object)itemPrefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			bugleObject = Object.Instantiate<GameObject>(((Component)itemPrefab).gameObject, attachmentPoint, false);
			((Object)bugleObject).name = "BeltBugle_Visual";
			Transform transform = bugleObject.transform;
			transform.localPosition = BuglePosition;
			transform.localRotation = Quaternion.Euler(BugleRotation);
			transform.localScale = BugleScale;
			Collider[] componentsInChildren = bugleObject.GetComponentsInChildren<Collider>(true);
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				Object.Destroy((Object)(object)val);
			}
			bugleObject.SetActive(true);
			Renderer[] componentsInChildren2 = bugleObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array2 = componentsInChildren2;
			foreach (Renderer val2 in array2)
			{
				val2.enabled = true;
				val2.forceRenderingOff = false;
			}
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Bugle visual prepared!");
			return true;
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)bugleObject == (Object)null))
			{
				Object.Destroy((Object)(object)bugleObject);
				bugleObject = null;
			}
		}

		private void OnDestroy()
		{
			RemoveVisual();
		}
	}
	public class CompassBeltController : MonoBehaviour
	{
		private GameObject? compassObject;

		private static readonly Vector3 CompassPosition = new Vector3(0.7145f, 1.12f, -0.1f);

		private static readonly Vector3 CompassRotation = new Vector3(298.4655f, 202.9772f, 334.9f);

		private static readonly Vector3 CompassScale = new Vector3(0.4f, 0.4f, 0.4f);

		public bool Initialize(Transform compassPrefab, Transform attachmentPoint)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)compassObject != (Object)null)
			{
				return true;
			}
			if ((Object)(object)compassPrefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			compassObject = Object.Instantiate<GameObject>(((Component)compassPrefab).gameObject, attachmentPoint, false);
			((Object)compassObject).name = "BeltCompass_Visual";
			Transform transform = compassObject.transform;
			transform.localPosition = CompassPosition;
			transform.localRotation = Quaternion.Euler(CompassRotation);
			transform.localScale = CompassScale;
			MonoBehaviour[] componentsInChildren = compassObject.GetComponentsInChildren<MonoBehaviour>(true);
			MonoBehaviour[] array = componentsInChildren;
			foreach (MonoBehaviour val in array)
			{
				if (((object)val).GetType().Name == "CompassPointer")
				{
					((Behaviour)val).enabled = false;
					Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] CompassPointer disabled!");
				}
			}
			Transform val2 = FindDeepChild(transform, "Needle");
			if ((Object)(object)val2 != (Object)null)
			{
				Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Original needle transform preserved!");
			}
			else
			{
				Plugin.Log.LogWarning((object)"[ScoutUtilityBelt] Needle not found!");
			}
			Collider[] componentsInChildren2 = compassObject.GetComponentsInChildren<Collider>(true);
			Collider[] array2 = componentsInChildren2;
			foreach (Collider val3 in array2)
			{
				Object.Destroy((Object)(object)val3);
			}
			compassObject.SetActive(true);
			Renderer[] componentsInChildren3 = compassObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array3 = componentsInChildren3;
			foreach (Renderer val4 in array3)
			{
				val4.enabled = true;
				val4.forceRenderingOff = false;
			}
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Compass visual created!");
			return true;
		}

		private Transform? FindDeepChild(Transform parent, string targetName)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == targetName)
				{
					return val;
				}
				Transform val2 = FindDeepChild(val, targetName);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}

		private void OnDestroy()
		{
			if ((Object)(object)compassObject != (Object)null)
			{
				Object.Destroy((Object)(object)compassObject);
			}
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)compassObject == (Object)null))
			{
				Object.Destroy((Object)(object)compassObject);
				compassObject = null;
				Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Compass visual removed!");
			}
		}
	}
	public class FlareBeltController : MonoBehaviour
	{
		private GameObject? flareObject;

		private static readonly Vector3 FlarePosition = new Vector3(1f, 1f, -0.6f);

		private static readonly Vector3 FlareRotation = new Vector3(7.3319f, 309.9452f, 0.0018f);

		private static readonly Vector3 FlareScale = new Vector3(0.1f, 0.1f, 0.1f);

		public bool Initialize(Transform flarePrefab, Transform attachmentPoint)
		{
			//IL_006b: 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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)flareObject != (Object)null)
			{
				return true;
			}
			if ((Object)(object)flarePrefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			flareObject = Object.Instantiate<GameObject>(((Component)flarePrefab).gameObject, attachmentPoint, false);
			((Object)flareObject).name = "BeltFlare_Visual";
			Transform transform = flareObject.transform;
			transform.localPosition = FlarePosition;
			transform.localRotation = Quaternion.Euler(FlareRotation);
			transform.localScale = FlareScale;
			Collider[] componentsInChildren = flareObject.GetComponentsInChildren<Collider>(true);
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				Object.Destroy((Object)(object)val);
			}
			flareObject.SetActive(true);
			Renderer[] componentsInChildren2 = flareObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array2 = componentsInChildren2;
			foreach (Renderer val2 in array2)
			{
				val2.enabled = true;
				val2.forceRenderingOff = false;
			}
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Flare visual created!");
			return true;
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)flareObject == (Object)null))
			{
				Object.Destroy((Object)(object)flareObject);
				flareObject = null;
			}
		}

		private void OnDestroy()
		{
			RemoveVisual();
		}
	}
	public class LanternBeltController : MonoBehaviour
	{
		private GameObject? lanternObject;

		private static readonly Vector3 LanternPosition = new Vector3(1.6109f, 1.34f, -0.4f);

		private static readonly Vector3 LanternRotation = new Vector3(74.6031f, 99.3523f, 182.046f);

		private static readonly Vector3 LanternScale = new Vector3(0.4f, 0.4f, 0.4f);

		public bool Initialize(Transform lanternPrefab, Transform attachmentPoint)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)lanternObject != (Object)null)
			{
				return true;
			}
			if ((Object)(object)lanternPrefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			lanternObject = Object.Instantiate<GameObject>(((Component)lanternPrefab).gameObject, attachmentPoint, false);
			((Object)lanternObject).name = "BeltLantern_Visual";
			Transform transform = lanternObject.transform;
			transform.localPosition = LanternPosition;
			transform.localRotation = Quaternion.Euler(LanternRotation);
			transform.localScale = LanternScale;
			Collider[] componentsInChildren = lanternObject.GetComponentsInChildren<Collider>(true);
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				Object.Destroy((Object)(object)val);
			}
			Transform val2 = FindDeepChild(transform, "Particles");
			if ((Object)(object)val2 != (Object)null)
			{
				((Component)val2).gameObject.SetActive(false);
			}
			Transform val3 = FindDeepChild(transform, "test-vfx-fire (2)");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).gameObject.SetActive(false);
			}
			Light[] componentsInChildren2 = lanternObject.GetComponentsInChildren<Light>(true);
			Light[] array2 = componentsInChildren2;
			foreach (Light val4 in array2)
			{
				((Behaviour)val4).enabled = false;
			}
			Renderer[] componentsInChildren3 = lanternObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array3 = componentsInChildren3;
			foreach (Renderer val5 in array3)
			{
				val5.enabled = true;
				val5.forceRenderingOff = false;
			}
			lanternObject.SetActive(true);
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Lantern visual created without effects!");
			return true;
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)lanternObject == (Object)null))
			{
				Object.Destroy((Object)(object)lanternObject);
				lanternObject = null;
			}
		}

		private Transform? FindDeepChild(Transform parent, string targetName)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == targetName)
				{
					return val;
				}
				Transform val2 = FindDeepChild(val, targetName);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}

		private void OnDestroy()
		{
			RemoveVisual();
		}
	}
	public class MegaphoneBeltController : MonoBehaviour
	{
		private GameObject? megaphoneObject;

		private static readonly Vector3 MegaphonePosition = new Vector3(0.4f, 0.5f, 0.8f);

		private static readonly Vector3 MegaphoneRotation = new Vector3(34.0524f, 358.3165f, 129.85f);

		private static readonly Vector3 MegaphoneScale = new Vector3(0.5f, 0.5364f, 0.5f);

		public bool Initialize(Transform megaphonePrefab, Transform attachmentPoint)
		{
			//IL_006b: 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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)megaphoneObject != (Object)null)
			{
				return true;
			}
			if ((Object)(object)megaphonePrefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			megaphoneObject = Object.Instantiate<GameObject>(((Component)megaphonePrefab).gameObject, attachmentPoint, false);
			((Object)megaphoneObject).name = "BeltMegaphone_Visual";
			Transform transform = megaphoneObject.transform;
			transform.localPosition = MegaphonePosition;
			transform.localRotation = Quaternion.Euler(MegaphoneRotation);
			transform.localScale = MegaphoneScale;
			Collider[] componentsInChildren = megaphoneObject.GetComponentsInChildren<Collider>(true);
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				Object.Destroy((Object)(object)val);
			}
			megaphoneObject.SetActive(true);
			Renderer[] componentsInChildren2 = megaphoneObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array2 = componentsInChildren2;
			foreach (Renderer val2 in array2)
			{
				val2.enabled = true;
				val2.forceRenderingOff = false;
			}
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Megaphone visual created!");
			return true;
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)megaphoneObject == (Object)null))
			{
				Object.Destroy((Object)(object)megaphoneObject);
				megaphoneObject = null;
			}
		}

		private void OnDestroy()
		{
			RemoveVisual();
		}
	}
	public class MikuFumoBeltController : MonoBehaviour
	{
		private Transform? visual;

		private static readonly Vector3 Position = new Vector3(0.4291f, 0.4f, 0.9f);

		private static readonly Vector3 Rotation = new Vector3(354.0558f, 0.1251f, 91.5467f);

		private static readonly Vector3 Scale = new Vector3(0.25f, 0.25f, 0.25f);

		public bool Initialize(Transform prefab, Transform attachmentPoint)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)visual != (Object)null)
			{
				return true;
			}
			if ((Object)(object)prefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			visual = Object.Instantiate<Transform>(prefab, attachmentPoint);
			((Object)visual).name = "MikuFumoBeltVisual";
			visual.localPosition = Position;
			visual.localRotation = Quaternion.Euler(Rotation);
			visual.localScale = Scale;
			Collider[] componentsInChildren = ((Component)visual).GetComponentsInChildren<Collider>(true);
			foreach (Collider val in componentsInChildren)
			{
				Object.Destroy((Object)(object)val);
			}
			Renderer[] componentsInChildren2 = ((Component)visual).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren2)
			{
				val2.enabled = true;
			}
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Miku Fumo visual created!");
			return true;
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)visual == (Object)null))
			{
				Object.Destroy((Object)(object)((Component)visual).gameObject);
				visual = null;
			}
		}

		private void OnDestroy()
		{
			RemoveVisual();
		}
	}
	public class PirateCompassBeltController : MonoBehaviour
	{
		private GameObject? pirateCompassObject;

		private static readonly Vector3 PirateCompassPosition = new Vector3(0.7145f, 1.12f, -0.1f);

		private static readonly Vector3 PirateCompassRotation = new Vector3(298.4655f, 202.9772f, 334.9f);

		private static readonly Vector3 PirateCompassScale = new Vector3(0.4f, 0.4f, 0.4f);

		public bool Initialize(Transform compassPrefab, Transform attachmentPoint)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pirateCompassObject != (Object)null)
			{
				return true;
			}
			if ((Object)(object)compassPrefab == (Object)null || (Object)(object)attachmentPoint == (Object)null)
			{
				return false;
			}
			pirateCompassObject = Object.Instantiate<GameObject>(((Component)compassPrefab).gameObject, attachmentPoint, false);
			((Object)pirateCompassObject).name = "BeltPirateCompass_Visual";
			Transform transform = pirateCompassObject.transform;
			transform.localPosition = PirateCompassPosition;
			transform.localRotation = Quaternion.Euler(PirateCompassRotation);
			transform.localScale = PirateCompassScale;
			MonoBehaviour[] componentsInChildren = pirateCompassObject.GetComponentsInChildren<MonoBehaviour>(true);
			MonoBehaviour[] array = componentsInChildren;
			foreach (MonoBehaviour val in array)
			{
				if (((object)val).GetType().Name == "CompassPointer")
				{
					((Behaviour)val).enabled = false;
				}
			}
			Collider[] componentsInChildren2 = pirateCompassObject.GetComponentsInChildren<Collider>(true);
			Collider[] array2 = componentsInChildren2;
			foreach (Collider val2 in array2)
			{
				Object.Destroy((Object)(object)val2);
			}
			Renderer[] componentsInChildren3 = pirateCompassObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array3 = componentsInChildren3;
			foreach (Renderer val3 in array3)
			{
				val3.enabled = true;
				val3.forceRenderingOff = false;
			}
			pirateCompassObject.SetActive(true);
			Plugin.Log.LogInfo((object)"[ScoutUtilityBelt] Pirate Compass visual created!");
			return true;
		}

		public void RemoveVisual()
		{
			if (!((Object)(object)pirateCompassObject == (Object)null))
			{
				Object.Destroy((Object)(object)pirateCompassObject);
				pirateCompassObject = null;
			}
		}

		private void OnDestroy()
		{
			RemoveVisual();
		}
	}
}