79 lines
1.8 KiB
C
79 lines
1.8 KiB
C
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||
|
|
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#include "CoreMinimal.h"
|
||
|
|
#include "Templates/SubclassOf.h"
|
||
|
|
#include "GameFramework/PlayerController.h"
|
||
|
|
#include "MerchanTalePlayerController.generated.h"
|
||
|
|
|
||
|
|
class UNiagaraSystem;
|
||
|
|
class UInputMappingContext;
|
||
|
|
class UInputAction;
|
||
|
|
|
||
|
|
DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Player controller for a top-down perspective game.
|
||
|
|
* Implements point and click based controls
|
||
|
|
*/
|
||
|
|
UCLASS(abstract)
|
||
|
|
class AMerchanTalePlayerController : public APlayerController
|
||
|
|
{
|
||
|
|
GENERATED_BODY()
|
||
|
|
|
||
|
|
protected:
|
||
|
|
|
||
|
|
/** Time Threshold to know if it was a short press */
|
||
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
||
|
|
float ShortPressThreshold;
|
||
|
|
|
||
|
|
/** FX Class that we will spawn when clicking */
|
||
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
||
|
|
UNiagaraSystem* FXCursor;
|
||
|
|
|
||
|
|
/** MappingContext */
|
||
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
||
|
|
UInputMappingContext* DefaultMappingContext;
|
||
|
|
|
||
|
|
/** Jump Input Action */
|
||
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
||
|
|
UInputAction* SetDestinationClickAction;
|
||
|
|
|
||
|
|
/** Jump Input Action */
|
||
|
|
UPROPERTY(EditAnywhere, Category="Input")
|
||
|
|
UInputAction* SetDestinationTouchAction;
|
||
|
|
|
||
|
|
/** True if the controlled character should navigate to the mouse cursor. */
|
||
|
|
uint32 bMoveToMouseCursor : 1;
|
||
|
|
|
||
|
|
/** Set to true if we're using touch input */
|
||
|
|
uint32 bIsTouch : 1;
|
||
|
|
|
||
|
|
/** Saved location of the character movement destination */
|
||
|
|
FVector CachedDestination;
|
||
|
|
|
||
|
|
/** Time that the click input has been pressed */
|
||
|
|
float FollowTime = 0.0f;
|
||
|
|
|
||
|
|
public:
|
||
|
|
|
||
|
|
/** Constructor */
|
||
|
|
AMerchanTalePlayerController();
|
||
|
|
|
||
|
|
protected:
|
||
|
|
|
||
|
|
/** Initialize input bindings */
|
||
|
|
virtual void SetupInputComponent() override;
|
||
|
|
|
||
|
|
/** Input handlers */
|
||
|
|
void OnInputStarted();
|
||
|
|
void OnSetDestinationTriggered();
|
||
|
|
void OnSetDestinationReleased();
|
||
|
|
void OnTouchTriggered();
|
||
|
|
void OnTouchReleased();
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
|