481 lines
16 KiB
C++
481 lines
16 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/PlayerController.h"
|
|
#include "InputActionValue.h"
|
|
#include "EnhancedActionKeyMapping.h"
|
|
#include "InputMappingContext.h"
|
|
#include "MyCharacter.h"
|
|
#include "InventoryComponent.h"
|
|
#include "Blueprint/UserWidget.h"
|
|
#include "UI/InventoryWidget.h"
|
|
#include "UI/BookOfAlchemyWidget.h"
|
|
#include "UI/MainMenuWidget.h"
|
|
#include "UI/MainGameWidget.h"
|
|
|
|
#include "EleriPlayerController.generated.h"
|
|
|
|
class ASeedBedActor;
|
|
class UItemDataAsset;
|
|
|
|
UENUM(BlueprintType)
|
|
enum class UiInputType : uint8 {
|
|
NONE,
|
|
SELECT,
|
|
BACK,
|
|
TABLEFT,
|
|
TABRIGHT,
|
|
UP,
|
|
LEFT,
|
|
RIGHT,
|
|
DOWN,
|
|
MAX
|
|
};
|
|
|
|
UENUM(BlueprintType)
|
|
enum class ECameraRigType : uint8 {
|
|
PLAYER,
|
|
OBJECT
|
|
};
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnUiButtonPressed, const UiInputType, InputType);
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnWatering, const bool, Started);
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnChangeInputContext, const int32, Index);
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRemovalModeToggle, const bool, Active);
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPlayerToggleFlying, const bool, Active);
|
|
|
|
DECLARE_DELEGATE_OneParam(FOnMinigameComplete, int32 /*Score*/);
|
|
|
|
class UMoveActorsComponent;
|
|
class ABookOfAlchemyManager;
|
|
class AAlchemyManager;
|
|
class UEleriBaseWidget;
|
|
class USelectionManager;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UCLASS()
|
|
class PROJECTELERI_API AEleriPlayerController : public APlayerController {
|
|
GENERATED_BODY()
|
|
|
|
protected:
|
|
AEleriPlayerController(const FObjectInitializer& ObjectInitializer);
|
|
|
|
private:
|
|
UPROPERTY()
|
|
UCharacterMovementComponent* MovementComponent;
|
|
|
|
UPROPERTY()
|
|
ABookOfAlchemyManager* BookOfAlchemyManager;
|
|
|
|
UPROPERTY()
|
|
AAlchemyManager* AlchemyManager;
|
|
|
|
UPROPERTY()
|
|
UMoveActorsComponent* MoveActorsComp;
|
|
|
|
UPROPERTY()
|
|
TArray<UUserWidget*> MenuStack;
|
|
|
|
UPROPERTY()
|
|
bool Sprinting;
|
|
|
|
UPROPERTY()
|
|
bool Watering;
|
|
|
|
UPROPERTY()
|
|
UMainGameWidget* MainGameUI;
|
|
|
|
UPROPERTY()
|
|
bool OrdersOpen;
|
|
UPROPERTY()
|
|
UUserWidget* OrdersUI;
|
|
|
|
UPROPERTY()
|
|
bool TickBookAnimating = false;
|
|
UPROPERTY()
|
|
float TickBookTimer = 0.6f;
|
|
|
|
UPROPERTY()
|
|
USelectionManager* SelectionManagerInventorySlots;
|
|
|
|
public:
|
|
UPROPERTY()
|
|
bool PlacingStuff;
|
|
|
|
protected:
|
|
virtual void BeginPlay() override;
|
|
|
|
public:
|
|
UFUNCTION(BlueprintCallable, BlueprintPure)
|
|
FORCEINLINE USelectionManager* GetSelectionManagerInventorySlot() { return SelectionManagerInventorySlots; }
|
|
|
|
UFUNCTION(BlueprintPure, Category = "Eleri Player Controller")
|
|
FORCEINLINE ABookOfAlchemyManager* GetBookOfAlchemyManager() { return BookOfAlchemyManager; }
|
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
FOnChangeInputContext OnChangeInputContext;
|
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
FOnRemovalModeToggle OnRemovalModeToggle;
|
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
FOnPlayerToggleFlying OnPlayerToggleFlying;
|
|
|
|
UPROPERTY(BlueprintReadOnly)
|
|
AMyCharacter* PlayerCharacter;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
bool Paused;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI")
|
|
TSubclassOf<UMainGameWidget> MainGameWidgetBlueprint;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI")
|
|
TSubclassOf<UUserWidget> OrdersBlueprint;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI")
|
|
TSubclassOf<UEleriBaseWidget> AlchemyUiBlueprint;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI")
|
|
TSubclassOf<UEleriBaseWidget> DialoguieUiBlueprint;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
float MinMovementSpeed;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
float MaxMovementSpeed;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputMappingContext* MovementContext;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* MoveAction;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* SprintAction;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* JumpAction;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* LookAction;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* ToggleCameraLook;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* WateringAction;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* WateringThrowAction;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* StartFlyingAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputMappingContext* FlyingContext;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input")
|
|
UInputMappingContext* UiContext;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input")
|
|
UInputAction* OpenMainMenuAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input")
|
|
UInputAction* InventoryAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input")
|
|
UInputAction* BookAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input")
|
|
UInputAction* OrdersAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input")
|
|
UInputAction* CalendarAction;
|
|
|
|
// UI INPUT ACTIONS
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputMappingContext* MainUiContext;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputAction* UiUpAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputAction* UiDownAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputAction* UiRightAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputAction* UiLeftAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputAction* UiConfirmAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputAction* UiBackAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputAction* UiTabLeftAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "UI Input Gamepad")
|
|
UInputAction* UiTabRightAction;
|
|
UPROPERTY(BlueprintAssignable)
|
|
FOnUiButtonPressed OnUiButtonPressed;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Action Input")
|
|
UInputMappingContext* ActionContext;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Action Input")
|
|
UInputAction* InteractAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Action Input")
|
|
UInputAction* InteractExitAction;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Action Input")
|
|
UInputAction* WaterSeedAction;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
|
UInputAction* BookNextPageAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
|
UInputAction* BookPreviousPageAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
|
UInputAction* BookItemTabAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
|
UInputAction* BookPotionTabAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
|
UInputAction* BookNextLetterAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
|
UInputAction* BookPreviousLetterAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
|
UInputAction* BookExitAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
|
UInputMappingContext* BookModeContext;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Alchemy Input")
|
|
UInputAction* AlchemyStirringDirectionalInput;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Alchemy Input")
|
|
UInputAction* AlchemyConfirmInput;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Alchemy Input")
|
|
UInputMappingContext* AlchemyMinigameContext;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
bool bFlying = false;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
bool bAnimatingFlying = false;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
float MovementVelocity = 3.0f;
|
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
FOnWatering OnWatering;
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
|
FVector2D MovementDirection;
|
|
|
|
public:
|
|
virtual void Tick(float DeltaTime) override;
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
UMainGameWidget* GetMainGameWidget() { return MainGameUI; }
|
|
|
|
const inline bool IsInMenu() { return MainGameUI->AnyWidgetOpen(); }
|
|
const inline bool IsSprinting() { return Sprinting; }
|
|
const inline bool IsPaused() { return Paused; }
|
|
const inline bool IsDialogueOpen() { return MainGameUI ? MainGameUI->IsDialogueOpen() : false; }
|
|
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "UI")
|
|
const inline bool MenuStackEmpty() { return MenuStack.Num() == 0; }
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
const inline bool IsWatering() { return Watering; }
|
|
UFUNCTION(BlueprintCallable)
|
|
const inline bool IsPlacingStuff() { return PlacingStuff; }
|
|
UFUNCTION(BlueprintCallable, BlueprintPure)
|
|
bool IsFlying() const { return bFlying; }
|
|
|
|
virtual void SetupInputComponent() override;
|
|
virtual void ClientRestart_Implementation(class APawn* NewPawn) override;
|
|
|
|
void OnMove(const FInputActionValue& Value);
|
|
void OnSprint(const FInputActionValue& Value);
|
|
void OnStopSprint(const FInputActionValue& Value);
|
|
void OnJump(const FInputActionValue& Value);
|
|
void OnStopJump(const FInputActionValue& Value);
|
|
void OnLook(const FInputActionValue& Value);
|
|
void OnLookEnable(const FInputActionValue& Value);
|
|
void OnLookDisable(const FInputActionValue& Value);
|
|
void OnWateringActionStart(const FInputActionValue& Value);
|
|
void OnWateringActionEnd(const FInputActionValue& Value);
|
|
void OnWateringThrowAction(const FInputActionValue& Value);
|
|
void OnStartFlyingAction(const FInputActionValue& Value);
|
|
void OnFlyUpwardsAction(const FInputActionValue& Value);
|
|
void OnFlyDownwardsAction(const FInputActionValue& Value);
|
|
|
|
// UI INPUT ACTIONS
|
|
void OnControllerUpAction(const FInputActionValue& Value);
|
|
void OnControllerDownAction(const FInputActionValue& Value);
|
|
void OnControllerLeftAction(const FInputActionValue& Value);
|
|
void OnControllerRightAction(const FInputActionValue& Value);
|
|
void OnControllerConfirmAction(const FInputActionValue& Value);
|
|
void OnControllerBackAction(const FInputActionValue& Value);
|
|
void OnControllerTabLeftAction(const FInputActionValue& Value);
|
|
void OnControllerTabRightAction(const FInputActionValue& Value);
|
|
|
|
void OnMainMenuToggle(const FInputActionValue& Value);
|
|
void OnInventoryToggle(const FInputActionValue& Value);
|
|
void OnBookToggle(const FInputActionValue& Value);
|
|
void OnOrdersToggle(const FInputActionValue& Value);
|
|
void OnCalendarToggle(const FInputActionValue& Value);
|
|
|
|
void OnBookNextPage(const FInputActionValue& Value);
|
|
void OnBookPreviousPage(const FInputActionValue& Value);
|
|
void OnBookItemTab(const FInputActionValue& Value);
|
|
void OnBookPotionTab(const FInputActionValue& Value);
|
|
void OnBookNextLetter(const FInputActionValue& Value);
|
|
void OnBookPreviousLetter(const FInputActionValue& Value);
|
|
void OnBookExit(const FInputActionValue& Value);
|
|
|
|
void OnAlchemyStirringDirectionInput(const FInputActionValue& Value);
|
|
void OnAlchemyConfirmInput(const FInputActionValue& Value);
|
|
|
|
UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "RestrictTabs"))
|
|
UUserWidget* OpenInventory(bool JustSelecting, bool Shop, UInventoryComponent* Inventory, TArray<EInventoryTabType> RestrictTabs, bool bSelectMultiple = true, bool bShowDescription = true, bool bShowPropertyMap = false);
|
|
UFUNCTION(BlueprintCallable)
|
|
void CloseInventory();
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
UUserWidget* OpenBookOfAlchemy(UItemDataAsset* ItemToPresent);
|
|
UFUNCTION(BlueprintCallable)
|
|
void CloseBookOfAlchemy();
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
void CloseOrdersUI();
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
UMainMenuWidget* OpenMainMenu();
|
|
UFUNCTION(BlueprintCallable)
|
|
void CloseMainMenu();
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
UEleriBaseWidget* ToggleAlchemyMenu(bool bOpen);
|
|
UFUNCTION(BlueprintCallable)
|
|
UEleriBaseWidget* ToggleDialogueWindow(bool bOpen);
|
|
UFUNCTION(BlueprintCallable)
|
|
UEleriBaseWidget* ToggleNotificationWindow(bool bOpen);
|
|
|
|
UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "InRestrictTabs"))
|
|
UTradeWidget* OpenTradeWindow(UInventoryComponent* Inventory, const TArray<EInventoryTabType>& InRestrictTabs);
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
UCalendarScreen* OpenCalendarWindow();
|
|
|
|
// Bazar
|
|
UFUNCTION(BlueprintCallable)
|
|
UEleriBaseWidget* OpenBazarWindow();
|
|
UFUNCTION(BlueprintCallable)
|
|
void ToggleBazarInput(bool bActive);
|
|
|
|
void OnInteract(const FInputActionValue& Value);
|
|
void OnInteractExit(const FInputActionValue& Value);
|
|
void OnHarvestSeed(const FInputActionValue& Value);
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
void StartMinigame(EMinigameType MinigameType, const TSoftObjectPtr<UBaseMinigameDataAsset>& DataAsset);
|
|
UFUNCTION(BlueprintCallable)
|
|
void CloseMinigame(int32 Score);
|
|
FOnMinigameComplete OnMinigameComplete;
|
|
|
|
// PLANTING
|
|
/** Seed the player selected in the inventory, it is what the planting action plants */
|
|
UFUNCTION(BlueprintCallable)
|
|
void SetSeedToPlant(UItemDataAsset* SeedData, bool bHighQuality = false);
|
|
|
|
/** Forgets the selected seed, the seed beds stop being highlighted for it */
|
|
UFUNCTION(BlueprintCallable)
|
|
void ClearSeedToPlant();
|
|
|
|
UFUNCTION(BlueprintCallable, BlueprintPure)
|
|
UItemDataAsset* GetSeedToPlant() const { return SeedToPlant; }
|
|
|
|
UFUNCTION(BlueprintCallable, BlueprintPure)
|
|
bool IsSeedToPlantHighQuality() const { return bSeedToPlantHighQuality; }
|
|
|
|
/** Plants the selected seed into the closest free slot of the closest seed bed, removes it from the inventory */
|
|
UFUNCTION(BlueprintCallable)
|
|
void TryPlantSelectedSeed();
|
|
|
|
/** True while the player is in planting mode, the seed beds in range are highlighted then */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure)
|
|
bool IsPlantingModeActive() const;
|
|
|
|
/** Enters / leaves planting mode, the highlights of the seed beds in range follow it */
|
|
UFUNCTION(BlueprintCallable)
|
|
void SetPlantingMode(bool bActive);
|
|
|
|
UPROPERTY(BlueprintReadOnly, Category = "Planting")
|
|
UItemDataAsset* SeedToPlant;
|
|
|
|
UPROPERTY(BlueprintReadOnly, Category = "Planting")
|
|
bool bSeedToPlantHighQuality = false;
|
|
|
|
void OnPlantSeedAction(const FInputActionValue& Value);
|
|
|
|
// REMOVE MODE
|
|
protected:
|
|
public:
|
|
UPROPERTY(EditDefaultsOnly, Category = "Locomotion Input")
|
|
UInputAction* StartObjectRemovalModeAction;
|
|
|
|
// Remove mode actions
|
|
UPROPERTY(EditDefaultsOnly, Category = "Remove Mode Input")
|
|
UInputAction* RemoveAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Remove Mode Input")
|
|
UInputAction* ExitRemoveModeAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Remove Mode Input")
|
|
UInputAction* StartMovingAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Remove Mode Input")
|
|
UInputAction* PlaceObjectAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Remove Mode Input")
|
|
UInputAction* RotateObjectAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Remove Mode Input")
|
|
UInputAction* ToggleGridAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Remove Mode Input")
|
|
UInputMappingContext* RemoveModeContext;
|
|
|
|
// Remove Mode actions
|
|
void OnStartObjectRemovalAction(const FInputActionValue& Value);
|
|
void OnRemoveAction(const FInputActionValue& Value);
|
|
UFUNCTION(BlueprintCallable)
|
|
void ExitRemoveMode();
|
|
void OnExitRemoveModeAction(const FInputActionValue& Value);
|
|
void OnStartMovingAction(const FInputActionValue& Value);
|
|
void OnPlaceObjectAction(const FInputActionValue& Value);
|
|
void OnRotateObjectAction(const FInputActionValue& Value);
|
|
void OnToggleGridAction(const FInputActionValue& Value);
|
|
|
|
/* INTERACTION STUFF BEGIN */
|
|
public:
|
|
void AddInteractableObject(UObject* ObjectToAdd);
|
|
void RemoveInteractableObject(UObject* ObjectToAdd);
|
|
void ToggleInteractionMenu(bool bActive);
|
|
|
|
protected:
|
|
UPROPERTY(Transient)
|
|
TArray<UObject*> ActorsOverlappingWith;
|
|
UPROPERTY(Transient)
|
|
UObject* SelectedInteractable;
|
|
UPROPERTY(Transient)
|
|
bool bIsInteractionMenuVisible = false;
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = "Interaction Menu Input")
|
|
UInputAction* InteractionMenuSelectAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Interaction Menu Input")
|
|
UInputAction* InteractionMenuUpAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Interaction Menu Input")
|
|
UInputAction* InteractionMenuDownAction;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Interaction Menu Input")
|
|
UInputMappingContext* InteractionMenuContext;
|
|
|
|
void OnInteractionMenuSelectAction(const FInputActionValue& Value);
|
|
void OnInteractionMenuUpAction(const FInputActionValue& Value);
|
|
void OnInteractionMenuDownAction(const FInputActionValue& Value);
|
|
|
|
/* INTERACTION STUFF END */
|
|
|
|
public:
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "INFO")
|
|
bool bBookAnimating = false;
|
|
void DisableBookAnimating();
|
|
};
|