Add item drop command

This commit is contained in:
2026-05-17 11:05:28 -07:00
parent 03d856efbf
commit b48595f70d
7 changed files with 160 additions and 1 deletions
@@ -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;