public void AddStockToShelf(ShelfContainer shelf) { // Check if there is something equipped if (!stateMachine.equippedItem) { return; } // Get stock type that is equipped StockTypes equippedType = stateMachine.equippedItem.GetComponent <StockItem>().GetStockType(); int result = shelf.AddStock(equippedType); if (result == 0) { Object.Destroy(stateMachine.equippedItem); } }
private void AddStockToShelf(ShelfContainer shelf) { // Check if there is something equipped if (!_equippedItem) { return; } int result = 0; switch (_equippedItem.tag) { case "Product": { // Get stock type that is equipped StockTypes equippedType = _equippedItem.GetComponent <StockItem>().GetStockType(); result = shelf.AddStock(equippedType); break; } case "StockCrate": { StockCrate crateComponent = _equippedItem.GetComponent <StockCrate>(); if (crateComponent) { result = shelf.AddCrate(crateComponent); } break; } } if (result == 0) { Destroy(_equippedItem); } }