static bool Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item, bool fromInventoryGui)
        {
            var data = item.GetRuneData();

            if (data == null)
            {
                return(true);
            }
            if (inventory == null)
            {
                inventory = __instance.m_inventory;
            }

            if (RunicPower.IsOnCooldown(data))
            {
                Player.m_localPlayer.Message(MessageHud.MessageType.Center, "[" + data.name + "] is not ready yet.");
                return(false);
            }

            if (!__instance.ConsumeItem(inventory, item))
            {
                return(true);
            }

            var player = __instance as Player;

            new Rune(data, player).Cast();

            return(false);
        }
 public static bool Prefix(InventoryGui __instance, InventoryGrid grid, ItemDrop.ItemData item, Vector2i pos, InventoryGrid.Modifier mod)
 {
     // if we're not moving from the spellbars, do nothing (normal flow)
     if (__instance.m_dragInventory?.m_name != "spellsBarInventory")
     {
         return(true);
     }
     // if we moving TO the spellsbars, do nothing (normal flow)
     if (grid.m_inventory?.m_name == "spellsBarInventory")
     {
         return(true);
     }
     // so if we're moving from the spellsbar to another inventory
     ItemDrop.ItemData itemAt = grid.GetInventory().GetItemAt(pos.x, pos.y);
     if (itemAt != null)
     {
         // and there is an item at the destination
         var runeData = itemAt.GetRuneData();
         // and its not a rune
         if (runeData == null)
         {
             // we cant swap that!
             Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You can't swap a rune for a non-rune item.");
             return(false);
         }
     }
     return(true);
 }
示例#3
0
        private static bool Prefix(ref string __result, ItemDrop.ItemData item, int qualityLevel, bool crafting)
        {
            var data = item.GetRuneData();

            if (data == null)
            {
                return(true);
            }

            var rune = RunicPower.GetStaticRune(data);

            __result = rune.GetTooltip(item);

            return(false);
        }
示例#4
0
        public static bool Prefix(Inventory __instance, ref ItemDrop.ItemData item, ref bool __result)
        {
            // if we're not crafting/looting a rune, ignore this flow
            var ext = Player.m_localPlayer?.ExtendedPlayer(false);

            if (ext == null || (ext.craftingRuneItem == null && ext.lootingRuneItem == null))
            {
                return(true);
            }
            var rune = item.GetRuneData();

            if (rune == null)
            {
                return(true);
            }

            var inv = SpellsBar.invBarGrid.m_inventory;

            var qtyStack = item.m_stack;

            while (qtyStack > 0)
            {
                // checking if this item already exists in the inventory (with free stack space)
                ItemDrop.ItemData itemData = inv.FindFreeStackItem(item.m_shared.m_name, item.m_quality);
                // if it does
                if (itemData != null)
                {
                    // get the free space
                    var freeStack = itemData.m_shared.m_maxStackSize - itemData.m_stack;
                    // get how much can we add to it
                    var toAdd = (qtyStack >= freeStack) ? freeStack : qtyStack;
                    // add that to it
                    itemData.m_stack += toAdd;
                    // subs that much of the item stack
                    qtyStack -= toAdd;
                }
                else
                {
                    // updating its quantity
                    item.m_stack = qtyStack;
                    // if the item does not exist, check for a empty slot
                    Vector2i invPos = inv.FindEmptySlot(inv.TopFirst(item));
                    // if there is one
                    if (invPos.x >= 0)
                    {
                        // add the item to it
                        item.m_gridPos = invPos;
                        inv.m_inventory.Add(item);
                        // iv was changed
                        inv.Changed();
                        // we're done, stop here
                        __result = true;
                        return(false);
                    }
                    else
                    {
                        // if there is no empty slot on the spellsbar, let's return true so it goes the normal flow trying to add it to the base inventory
                        return(true);
                    }
                }
            }
            // iv was changed
            inv.Changed();
            // we're done, stop here
            __result = true;
            return(false);
        }