Ejemplo n.º 1
0
        public static MagicInventory Create(long playerID)
        {
            var newInv = new MagicInventory()
            {
                PlayerID = playerID
            };

            AllContainers[playerID] = newInv;
            return(newInv);
        }
Ejemplo n.º 2
0
        public static void Postfix()
        {
            if (Player.m_localPlayer == null)
            {
                return;
            }
            ZNetView nview = (ZNetView)typeof(Player).GetField("m_nview", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(Player.m_localPlayer);

            long playerID = nview.GetZDO().GetLong("playerID");

            if (File.Exists(Path.Combine(MagicInventory.PocketContainerPath, playerID.ToString() + "_pocket.txt")))
            {
                var inv = MagicInventory.Create(playerID);
                inv.LoadOverride();
            }
        }
Ejemplo n.º 3
0
        public static void OpenMagicInventory(InventoryGui inventoryGui, int width, int height)
        {
            Player player = Player.m_localPlayer;

            if ((bool)player)
            {
                ZNetView nview = (ZNetView)typeof(Player).GetField("m_nview", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(player);

                long playerID = nview.GetZDO().GetLong("playerID");

                MagicContainer magicContainer = player.gameObject.GetComponent <MagicInventory.MagicContainer>();
                bool           newContainer   = magicContainer == null;
                if (newContainer)
                {
                    magicContainer = player.gameObject.AddComponent <MagicInventory.MagicContainer>();
                }

                MagicInventory.AllContainers.TryGetValue(playerID, out var magicInventory);

                if (magicInventory == null)
                {
                    magicInventory = MagicInventory.Create(playerID);
                }
                magicInventory.Width  = width;
                magicInventory.Height = height;
                typeof(Container).GetField("m_inventory", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).SetValue(magicContainer, magicInventory);

                if (newContainer)
                {
                    Action onContainerChanged = () => typeof(Container).GetMethod("OnContainerChanged", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(magicContainer, null);
                    magicInventory.m_onChanged = (Action)Delegate.Combine(magicInventory.m_onChanged, onContainerChanged);
                }

                inventoryGui.Show(magicContainer);
            }
        }