Exemple #1
0
        private bool TryAddInternal(IEntityContainer holder, Entity item, int index, bool replace)
        {
            if (item == null || holder == null || holder.Contains(item))
            {
                return(false);
            }
            var inventoryItem = item.Get <InventoryItem>();

            if (inventoryItem == null)
            {
                return(false);
            }
            if (holder[index] != null)
            {
                if (!replace)
                {
                    return(false);
                }
                holder.Remove(holder[index]);
            }
            if (inventoryItem.Inventory != null)
            {
                inventoryItem.Inventory.Remove(item);
            }
            holder.ContainerSystemSet(item, index);
            ProcessHolderChange(holder, item, inventoryItem, index);
            return(true);
        }
Exemple #2
0
        public bool TryAdd(IEntityContainer holder, Entity item)
        {
            if (item == null || holder == null || holder.IsFull || holder.Contains(item))
            {
                return(false);
            }
            var inventoryItem = item.Get <InventoryItem>();

            if (inventoryItem == null)
            {
                return(false);
            }
            if (inventoryItem.Inventory != null)
            {
                inventoryItem.Inventory.Remove(item);
            }
            ProcessHolderChange(holder, item, inventoryItem, holder.ContainerSystemAdd(item));
            return(true);
        }