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); }
public bool TrySwap(IEntityContainer holder, int index1, int index2) { var item1 = holder[index1]; var item2 = holder[index2]; if (item1 == null && item2 == null) { return(false); } if (item1 != null) { item1.Get <InventoryItem>().Index = index2; holder.ContainerSystemSet(item1, index2); } if (item2 != null) { item2.Get <InventoryItem>().Index = index1; holder.ContainerSystemSet(item2, index1); } holder.Owner.Post(new ContainerChanged(holder)); return(true); }