예제 #1
0
        /// <inheritdoc />
        public bool TryAddAt(IInventoryItem item, Vector2Int point)
        {
            if (!CanAddAt(item, point) || !_provider.AddInventoryItem(item))
            {
                onItemAddedFailed?.Invoke(item);
                return(false);
            }
            switch (_provider.inventoryRenderMode)
            {
            case InventoryRenderMode.Single:
                item.position = GetCenterPosition(item);
                break;

            case InventoryRenderMode.Grid:
                item.position = point;
                break;

            default:
                throw new NotImplementedException($"InventoryRenderMode.{_provider.inventoryRenderMode.ToString()} have not yet been implemented");
            }
            Rebuild(true);
            onItemAdded?.Invoke(item);
            return(true);
        }