Пример #1
0
    /// <summary>
    /// Same as above but can support stackables (playing item one at a time into a machine)
    /// returns the object that was removed from the stack also
    /// </summary>
    /// <param name="fromSlot"></param>
    /// <returns></returns>
    public static GameObject ServerVanishStackable(ItemSlot fromSlot)
    {
        if (fromSlot.ItemObject == null)
        {
            return(null);
        }
        var stackable = fromSlot.ItemObject.GetComponent <Stackable>();

        if (stackable != null)
        {
            var clone = stackable.ServerRemoveOne();
            ServerPerform(new InventoryMove(InventoryMoveType.Remove, clone.GetComponent <Pickupable>(), fromSlot, null, InventoryRemoveType.Vanish));
            return(clone);
        }
        else
        {
            ServerPerform(InventoryMove.Vanish(fromSlot));
            return(fromSlot.Item.gameObject);
        }
    }
Пример #2
0
 /// <summary>
 /// NOTE: This should RARELY be used, and this method may even be removed later!
 /// It's only here as a last resort / stopgap in case you can't figure out
 /// a better alternative. If you need to store an object for your component, use an ItemStorage
 /// on the object your component is on and transfer into it. It's bad to have items just hanging out at hidden pos.
 ///
 /// Inventory move in which the object in the slot is removed from inventory but neither dropped in the world,
 /// despawned, or made visible. Instead it is kept invisible at hiddenpos.
 /// </summary>
 /// <param name="fromSlot"></param>
 /// <returns>true if successful</returns>
 public static bool ServerVanish(ItemSlot fromSlot)
 {
     return(ServerPerform(InventoryMove.Vanish(fromSlot)));
 }