2025-01-17 22:14:51 +00:00
|
|
|
|
// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "GameplayAbilitySpecHandle.h"
|
|
|
|
|
#include "Components/GameFrameworkInitStateInterface.h"
|
|
|
|
|
#include "Components/PawnComponent.h"
|
|
|
|
|
#include "OLSHeroComponent.generated.h"
|
|
|
|
|
|
|
|
|
|
DECLARE_LOG_CATEGORY_EXTERN(LogOLSHeroComponent, Verbose, All);
|
|
|
|
|
|
|
|
|
|
namespace EEndPlayReason { enum Type : int; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Component that sets up input and camera handling for player controlled pawns (or bots that simulate players).
|
|
|
|
|
* This depends on a PawnExtensionComponent to coordinate initialization.
|
|
|
|
|
*/
|
|
|
|
|
UCLASS(Blueprintable, Meta=(BlueprintSpawnableComponent))
|
|
|
|
|
class OLS_API UOLSHeroComponent : public UPawnComponent, public IGameFrameworkInitStateInterface
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
UOLSHeroComponent(const FObjectInitializer& objectInitializer);
|
|
|
|
|
|
|
|
|
|
//~ Begin IGameFrameworkInitStateInterface interface
|
|
|
|
|
virtual FName GetFeatureName() const override;
|
|
|
|
|
virtual bool CanChangeInitState(UGameFrameworkComponentManager* manager, FGameplayTag currentState, FGameplayTag desiredState) const override;
|
|
|
|
|
virtual void HandleChangeInitState(UGameFrameworkComponentManager* manager, FGameplayTag currentState, FGameplayTag desiredState) override;
|
|
|
|
|
virtual void OnActorInitStateChanged(const FActorInitStateChangedParams& params) override;
|
|
|
|
|
virtual void CheckDefaultInitialization() override;
|
|
|
|
|
//~ End IGameFrameworkInitStateInterface interface
|
|
|
|
|
|
|
|
|
|
/** The name of the extension event sent via UGameFrameworkComponentManager when ability inputs are ready to bind */
|
|
|
|
|
static const FName NAME_BindInputsNow;
|
|
|
|
|
|
|
|
|
|
/** The name of this component-implemented feature */
|
|
|
|
|
static const FName NAME_ActorFeatureName;
|
|
|
|
|
|
2025-01-20 18:59:57 +00:00
|
|
|
|
/** Returns the hero component if one exists on the specified actor. */
|
|
|
|
|
UFUNCTION(BlueprintPure, Category = "Lyra|Hero")
|
|
|
|
|
static UOLSHeroComponent* FindHeroComponent(const AActor* actor);
|
|
|
|
|
|
|
|
|
|
|
2025-01-17 22:14:51 +00:00
|
|
|
|
/** Overrides the camera from an active gameplay ability */
|
2025-01-20 21:08:07 +00:00
|
|
|
|
void SetAbilityCameraMode(TSubclassOf<class UOLSCameraMode> CameraMode, const FGameplayAbilitySpecHandle& OwningSpecHandle);
|
2025-01-17 22:14:51 +00:00
|
|
|
|
|
|
|
|
|
/** Clears the camera override if it is set */
|
|
|
|
|
void ClearAbilityCameraMode(const FGameplayAbilitySpecHandle& owningSpecHandle);
|
|
|
|
|
|
|
|
|
|
/** Adds mode-specific input config */
|
|
|
|
|
void AddAdditionalInputConfig(const class UOLSInputConfigDataAsset* inputConfig);
|
|
|
|
|
|
|
|
|
|
/** Removes a mode-specific input config if it has been added */
|
|
|
|
|
void RemoveAdditionalInputConfig(const class UOLSInputConfigDataAsset* inputConfig);
|
|
|
|
|
|
|
|
|
|
/** True if this is controlled by a real player and has progressed far enough in initialization where additional input bindings can be added */
|
|
|
|
|
bool IsReadyToBindInputs() const;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
//~ Begin UActorComponent interface.
|
|
|
|
|
virtual void OnRegister() override;
|
|
|
|
|
virtual void BeginPlay() override;
|
|
|
|
|
virtual void EndPlay(const EEndPlayReason::Type endPlayReason) override;
|
|
|
|
|
//~ End UActorComponent interface.
|
|
|
|
|
|
|
|
|
|
virtual void InitializePlayerInput(UInputComponent* playerInputComponent);
|
|
|
|
|
|
|
|
|
|
void Input_AbilityInputTagPressed(FGameplayTag inputTag);
|
|
|
|
|
void Input_AbilityInputTagReleased(FGameplayTag inputTag);
|
|
|
|
|
|
|
|
|
|
void Input_Move(const struct FInputActionValue& inputActionValue);
|
|
|
|
|
void Input_LookMouse(const struct FInputActionValue& inputActionValue);
|
|
|
|
|
void Input_LookStick(const struct FInputActionValue& inputActionValue);
|
|
|
|
|
void Input_Crouch(const struct FInputActionValue& InputActionValue);
|
|
|
|
|
void Input_AutoRun(const struct FInputActionValue& inputActionValue);
|
|
|
|
|
|
2025-01-20 21:08:07 +00:00
|
|
|
|
TSubclassOf<class UOLSCameraMode> DetermineCameraMode() const;
|
2025-01-17 22:14:51 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
|
TArray<struct FOLSInputMappingContextAndPriority> DefaultInputMappings;
|
|
|
|
|
|
|
|
|
|
/** Camera mode set by an ability. */
|
2025-01-20 21:08:07 +00:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
TSubclassOf<class UOLSCameraMode> AbilityCameraMode;
|
2025-01-17 22:14:51 +00:00
|
|
|
|
|
|
|
|
|
/** Spec handle for the last ability to set a camera mode. */
|
|
|
|
|
FGameplayAbilitySpecHandle AbilityCameraModeOwningSpecHandle;
|
|
|
|
|
|
|
|
|
|
/** True when player input bindings have been applied, will never be true for non - players */
|
|
|
|
|
bool bIsReadyToBindInputs;
|
|
|
|
|
};
|