Add item drop command
This commit is contained in:
@@ -72,6 +72,14 @@ bool UAgrarianInventoryComponent::AddItem(const FAgrarianItemStack& Stack)
|
||||
|
||||
bool UAgrarianInventoryComponent::RemoveItem(FName ItemId, int32 Quantity)
|
||||
{
|
||||
FAgrarianItemStack RemovedStack;
|
||||
return ExtractItem(ItemId, Quantity, RemovedStack);
|
||||
}
|
||||
|
||||
bool UAgrarianInventoryComponent::ExtractItem(FName ItemId, int32 Quantity, FAgrarianItemStack& OutStack)
|
||||
{
|
||||
OutStack = FAgrarianItemStack();
|
||||
|
||||
if (!GetOwner() || !GetOwner()->HasAuthority() || Quantity <= 0 || !HasItem(ItemId, Quantity))
|
||||
{
|
||||
return false;
|
||||
@@ -87,6 +95,13 @@ bool UAgrarianInventoryComponent::RemoveItem(FName ItemId, int32 Quantity)
|
||||
}
|
||||
|
||||
const int32 Removed = FMath::Min(Stack.Quantity, Remaining);
|
||||
if (OutStack.ItemId == NAME_None)
|
||||
{
|
||||
OutStack = Stack;
|
||||
OutStack.Quantity = 0;
|
||||
}
|
||||
|
||||
OutStack.Quantity += Removed;
|
||||
Stack.Quantity -= Removed;
|
||||
Remaining -= Removed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user