Add developer travel command
This commit is contained in:
@@ -9,11 +9,18 @@
|
||||
#include "AgrarianSurvivalComponent.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "InputMappingContext.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "AgrarianGame.h"
|
||||
#include "Widgets/Input/SVirtualJoystick.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
const FVector GroundZeroDeveloperTravelHomeLocation(-22000.0f, -3500.0f, 1148.0f);
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
@@ -120,6 +127,16 @@ void AAgrarianGamePlayerController::AgrarianHeal()
|
||||
ServerAgrarianHeal();
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::AgrarianTravel(float X, float Y, float Z)
|
||||
{
|
||||
ServerAgrarianTravel(FVector(X, Y, Z));
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::AgrarianTravelHome()
|
||||
{
|
||||
ServerAgrarianTravel(GroundZeroDeveloperTravelHomeLocation);
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::ServerAgrarianGrantItem_Implementation(FName ItemId, int32 Quantity)
|
||||
{
|
||||
AAgrarianGameCharacter* AgrarianCharacter = GetPawn<AAgrarianGameCharacter>();
|
||||
@@ -196,3 +213,35 @@ void AAgrarianGamePlayerController::ServerAgrarianHeal_Implementation()
|
||||
SurvivalComponent->AddWarmth(37.0f - SurvivalComponent->Survival.BodyTemperature);
|
||||
ClientMessage(TEXT("Agrarian survival restored."));
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::ServerAgrarianTravel_Implementation(FVector Destination)
|
||||
{
|
||||
APawn* ControlledPawn = GetPawn();
|
||||
if (!ControlledPawn)
|
||||
{
|
||||
ClientMessage(TEXT("No controlled pawn found for developer travel."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Destination.ContainsNaN())
|
||||
{
|
||||
ControlledPawn->TeleportTo(Destination, ControlledPawn->GetActorRotation(), false, true);
|
||||
if (ACharacter* ControlledCharacter = Cast<ACharacter>(ControlledPawn))
|
||||
{
|
||||
if (UCharacterMovementComponent* Movement = ControlledCharacter->GetCharacterMovement())
|
||||
{
|
||||
Movement->StopMovementImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
ClientMessage(FString::Printf(
|
||||
TEXT("Developer travel complete: X %.1f Y %.1f Z %.1f"),
|
||||
Destination.X,
|
||||
Destination.Y,
|
||||
Destination.Z));
|
||||
}
|
||||
else
|
||||
{
|
||||
ClientMessage(TEXT("Developer travel failed: invalid destination."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,12 @@ public:
|
||||
UFUNCTION(Exec)
|
||||
void AgrarianHeal();
|
||||
|
||||
UFUNCTION(Exec)
|
||||
void AgrarianTravel(float X, float Y, float Z);
|
||||
|
||||
UFUNCTION(Exec)
|
||||
void AgrarianTravelHome();
|
||||
|
||||
protected:
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerAgrarianGrantItem(FName ItemId, int32 Quantity);
|
||||
@@ -78,4 +84,7 @@ protected:
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerAgrarianHeal();
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerAgrarianTravel(FVector Destination);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user