Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Inventory Viewer v1.2.1
EmpressInvPeek.dll
Decompiled 3 months agousing 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 BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using Photon.Pun; 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("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c574138cfea486cfa7104eae1a6f135c166daf8b")] [assembly: AssemblyProduct("EmpressInvPeek")] [assembly: AssemblyTitle("EmpressInvPeek")] [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.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; } } [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 HostInventoryMod { [BepInPlugin("com.empress.hostinventory", "Host Inventory Viewer", "1.0.0")] public class HostInventoryPlugin : BaseUnityPlugin { private Dictionary<int, string[]> _inventoryCache = new Dictionary<int, string[]>(); private float _updateTimer = 0f; private const float UPDATE_INTERVAL = 0.25f; private GUIStyle _boxStyle; private GUIStyle _headerStyle; private GUIStyle _playerStyle; private GUIStyle _itemStyle; private GUIStyle _emptyStyle; private Texture2D _bgTexture; private Texture2D _headerTexture; private bool _isVisible = true; private Vector2 _position; private const float MOVE_SPEED = 5f; private ConfigEntry<float> _configPosX; private ConfigEntry<float> _configPosY; private ConfigEntry<bool> _configVisible; private void Awake() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); _configPosX = ((BaseUnityPlugin)this).Config.Bind<float>("Position", "X", (float)Screen.width - 260f, "X position of the inventory panel"); _configPosY = ((BaseUnityPlugin)this).Config.Bind<float>("Position", "Y", 10f, "Y position of the inventory panel"); _configVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "Visible", true, "Whether the inventory panel is visible"); _position = new Vector2(_configPosX.Value, _configPosY.Value); _isVisible = _configVisible.Value; } private void Start() { _inventoryCache = new Dictionary<int, string[]>(); } private void Update() { if (!PhotonNetwork.IsMasterClient || !Object.op_Implicit((Object)(object)NetworkManager.instance) || !Object.op_Implicit((Object)(object)GameDirector.instance)) { return; } if (Input.GetKeyDown((KeyCode)120)) { _isVisible = !_isVisible; _configVisible.Value = _isVisible; ((BaseUnityPlugin)this).Config.Save(); } if (_isVisible) { bool flag = false; if (Input.GetKey((KeyCode)273)) { _position.y -= 5f; flag = true; } if (Input.GetKey((KeyCode)274)) { _position.y += 5f; flag = true; } if (Input.GetKey((KeyCode)276)) { _position.x -= 5f; flag = true; } if (Input.GetKey((KeyCode)275)) { _position.x += 5f; flag = true; } if (flag) { _position.x = Mathf.Clamp(_position.x, 0f, (float)(Screen.width - 250)); _position.y = Mathf.Clamp(_position.y, 0f, (float)(Screen.height - 100)); _configPosX.Value = _position.x; _configPosY.Value = _position.y; ((BaseUnityPlugin)this).Config.Save(); } } _updateTimer += Time.deltaTime; if (_updateTimer >= 0.25f) { _updateTimer = 0f; RefreshInventoryCache(); } } private void RefreshInventoryCache() { _inventoryCache.Clear(); if ((Object)(object)ItemManager.instance == (Object)null || ItemManager.instance.spawnedItems == null) { return; } foreach (ItemAttributes spawnedItem in ItemManager.instance.spawnedItems) { if ((Object)(object)spawnedItem == (Object)null) { continue; } ItemEquippable component = ((Component)spawnedItem).GetComponent<ItemEquippable>(); if (!((Object)(object)component != (Object)null) || !component.IsEquipped()) { continue; } int num = (int)GetPrivateField(component, "ownerPlayerId"); int num2 = (int)GetInventorySpotIndex(component); if (num != -1 && num2 >= 0 && num2 < 3) { if (!_inventoryCache.ContainsKey(num)) { _inventoryCache[num] = new string[3] { "", "", "" }; } string text = spawnedItem.itemName; if (!string.IsNullOrEmpty(spawnedItem.instanceName)) { text = spawnedItem.instanceName; } _inventoryCache[num][num2] = text; } } } private object GetPrivateField(object instance, string fieldName) { return instance.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance); } private object GetInventorySpotIndex(object instance) { return instance.GetType().GetField("inventorySpotIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance); } private void InitializeStyles() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_002a: 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) //IL_004e: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown _bgTexture = new Texture2D(1, 1); _bgTexture.SetPixel(0, 0, new Color(0.1f, 0.1f, 0.15f, 0.95f)); _bgTexture.Apply(); _headerTexture = new Texture2D(1, 1); _headerTexture.SetPixel(0, 0, new Color(0.2f, 0.4f, 0.7f, 0.95f)); _headerTexture.Apply(); _boxStyle = new GUIStyle(GUI.skin.box); _boxStyle.normal.background = _bgTexture; _boxStyle.border = new RectOffset(2, 2, 2, 2); _boxStyle.padding = new RectOffset(12, 12, 12, 12); _headerStyle = new GUIStyle(GUI.skin.label); _headerStyle.normal.textColor = new Color(1f, 1f, 1f, 1f); _headerStyle.fontSize = 16; _headerStyle.fontStyle = (FontStyle)1; _headerStyle.alignment = (TextAnchor)4; _headerStyle.normal.background = _headerTexture; _headerStyle.padding = new RectOffset(0, 0, 8, 8); _playerStyle = new GUIStyle(GUI.skin.label); _playerStyle.normal.textColor = new Color(0.9f, 0.9f, 1f, 1f); _playerStyle.fontSize = 13; _playerStyle.fontStyle = (FontStyle)1; _playerStyle.padding = new RectOffset(0, 0, 4, 2); _itemStyle = new GUIStyle(GUI.skin.label); _itemStyle.normal.textColor = new Color(0.4f, 1f, 0.6f, 1f); _itemStyle.fontSize = 12; _itemStyle.padding = new RectOffset(16, 0, 2, 2); _emptyStyle = new GUIStyle(GUI.skin.label); _emptyStyle.normal.textColor = new Color(0.5f, 0.5f, 0.5f, 0.7f); _emptyStyle.fontSize = 11; _emptyStyle.fontStyle = (FontStyle)2; _emptyStyle.padding = new RectOffset(16, 0, 2, 2); } private void OnGUI() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient || !_isVisible) { return; } if ((Object)(object)_bgTexture == (Object)null) { InitializeStyles(); } float num = 250f; float num2 = CalculateContentHeight(); float num3 = Mathf.Min(num2, (float)Screen.height - _position.y - 20f); GUI.depth = -1000; GUILayout.BeginArea(new Rect(_position.x, _position.y, num, num3), _boxStyle); GUILayout.Label("⚡ INVENTORY TRACKER", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); if (Object.op_Implicit((Object)(object)GameDirector.instance) && GameDirector.instance.PlayerList != null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player == (Object)null) { continue; } string playerName = player.playerName; if (!((Object)(object)player.physGrabber != (Object)null) || !((Object)(object)player.physGrabber.photonView != (Object)null)) { continue; } int viewID = player.physGrabber.photonView.ViewID; GUILayout.Label("▸ " + playerName, _playerStyle, Array.Empty<GUILayoutOption>()); if (_inventoryCache.ContainsKey(viewID)) { string[] array = _inventoryCache[viewID]; for (int i = 0; i < 3; i++) { if (!string.IsNullOrEmpty(array[i])) { GUILayout.Label($" [{i + 1}] {array[i]}", _itemStyle, Array.Empty<GUILayoutOption>()); } else { GUILayout.Label($" [{i + 1}] empty", _emptyStyle, Array.Empty<GUILayoutOption>()); } } } else { GUILayout.Label(" no items", _emptyStyle, Array.Empty<GUILayoutOption>()); } GUILayout.Space(6f); } } GUILayout.FlexibleSpace(); GUIStyle val = new GUIStyle(GUI.skin.label); val.fontSize = 9; val.normal.textColor = new Color(0.7f, 0.7f, 0.7f, 0.6f); val.alignment = (TextAnchor)7; GUILayout.Label("X: Toggle | Arrows: Move", val, Array.Empty<GUILayoutOption>()); GUILayout.EndArea(); } private float CalculateContentHeight() { float num = 60f; if (Object.op_Implicit((Object)(object)GameDirector.instance) && GameDirector.instance.PlayerList != null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null)) { num += 100f; } } } return num; } } }