/// <summary>
    /// Consume the indicated amount of the object in the slot if it is stackable, otherwise despawn it.
    /// </summary>
    /// <param name="fromSlot"></param>
    /// <returns>true if successful</returns>
    public static bool ServerConsume(ItemSlot fromSlot, int amountToConsume)
    {
        if (fromSlot.ItemObject == null)
        {
            return(false);
        }
        var stackable = fromSlot.ItemObject.GetComponent <Stackable>();

        if (stackable != null)
        {
            stackable.ServerConsume(amountToConsume);
            return(true);
        }
        else
        {
            return(ServerPerform(InventoryMove.Despawn(fromSlot)));
        }
    }
Example #2
0
 /// <summary>
 /// Inventory move in which the object in the slot is despawned directly from inventory and doesn't reappear
 /// in the world.
 /// </summary>
 /// <param name="fromSlot"></param>
 /// <returns>true if successful</returns>
 public static bool ServerDespawn(ItemSlot fromSlot)
 {
     return(ServerPerform(InventoryMove.Despawn(fromSlot)));
 }