77 lines
2.5 KiB
C++
77 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Engine/HitResult.h"
|
|
#include "GameFramework/PlayerController.h"
|
|
#include "InputEvents.h"
|
|
#include "PlayerControllerBase.generated.h"
|
|
|
|
UCLASS(BlueprintType, Blueprintable)
|
|
class INTEGRATION_API AlxPlayerControllerBase : public APlayerController
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
using InputMode = FlxEventRequests::InputMode;
|
|
|
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
|
static void SetLookAt(const UObject *Context, const FHitResult &HitResult);
|
|
|
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
|
static const FHitResult &GetLookAt(const UObject *Context);
|
|
|
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
|
static const AActor *GetLookAtActor(const UObject *Context);
|
|
|
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
|
static FVector2D GetLookAtPixel(const UObject *Context);
|
|
|
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
|
static void SetLookAtChanged(const UObject *Context);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Luprex|Input Events")
|
|
static void RequestEvents(const FlxEventRequest &Request);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Luprex|Input Events")
|
|
static void UnRequestEvents(UUserWidget *Widget);
|
|
|
|
// Blueprint events
|
|
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
|
void CalculateLookAt();
|
|
|
|
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
|
void LookAtChanged();
|
|
|
|
virtual void BeginPlay() override;
|
|
|
|
// Called by GameMode each tick.
|
|
void UpdateLookAt();
|
|
|
|
// Rebuild input component and switch input mode.
|
|
void UpdateEventDispatch();
|
|
|
|
// Handler for character mode hotkey presses.
|
|
void ForwardKeyEvent(FKey Key);
|
|
|
|
// Walk up from a Slate widget to find the nearest UMG widget class name.
|
|
static FString GetUserWidgetName(SWidget *W);
|
|
|
|
// Get the player controller, cast to AlxPlayerControllerBase.
|
|
static AlxPlayerControllerBase *FromContext(const UObject *Context);
|
|
|
|
UPROPERTY()
|
|
FHitResult CurrentLookAt;
|
|
|
|
UPROPERTY()
|
|
FlxEventRequests EventRequests;
|
|
|
|
// Input component for Character Mode: catches hotkeys only.
|
|
UPROPERTY()
|
|
UInputComponent *CharacterModeInput = nullptr;
|
|
|
|
// Current input mode.
|
|
InputMode CurrentInputMode = InputMode::GameOnly;
|
|
|
|
bool MustCallLookAtChanged = false;
|
|
};
|