Add stack splitting
This commit is contained in:
@@ -139,6 +139,17 @@ void AAgrarianGamePlayerController::AgrarianDropItem(FName ItemId, int32 Quantit
|
||||
ServerAgrarianDropItem(ItemId, Quantity);
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::AgrarianSplitStack(int32 StackIndex, int32 SplitQuantity)
|
||||
{
|
||||
if (StackIndex < 0 || SplitQuantity <= 0)
|
||||
{
|
||||
ClientMessage(TEXT("Usage: AgrarianSplitStack <StackIndex> <SplitQuantity>"));
|
||||
return;
|
||||
}
|
||||
|
||||
ServerAgrarianSplitStack(StackIndex, SplitQuantity);
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::AgrarianTravel(float X, float Y, float Z)
|
||||
{
|
||||
ServerAgrarianTravel(FVector(X, Y, Z));
|
||||
@@ -268,6 +279,26 @@ void AAgrarianGamePlayerController::ServerAgrarianDropItem_Implementation(FName
|
||||
ClientMessage(FString::Printf(TEXT("Dropped %d x %s."), DroppedStack.Quantity, *ItemId.ToString()));
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::ServerAgrarianSplitStack_Implementation(int32 StackIndex, int32 SplitQuantity)
|
||||
{
|
||||
AAgrarianGameCharacter* AgrarianCharacter = GetPawn<AAgrarianGameCharacter>();
|
||||
UAgrarianInventoryComponent* InventoryComponent = AgrarianCharacter ? AgrarianCharacter->GetInventoryComponent() : nullptr;
|
||||
if (!InventoryComponent)
|
||||
{
|
||||
ClientMessage(TEXT("No Agrarian inventory component found."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (InventoryComponent->SplitStackByIndex(StackIndex, SplitQuantity))
|
||||
{
|
||||
ClientMessage(FString::Printf(TEXT("Split %d items from stack %d."), SplitQuantity, StackIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
ClientMessage(FString::Printf(TEXT("Could not split %d items from stack %d."), SplitQuantity, StackIndex));
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::ServerAgrarianTravel_Implementation(FVector Destination)
|
||||
{
|
||||
APawn* ControlledPawn = GetPawn();
|
||||
|
||||
Reference in New Issue
Block a user