forked from TangoAlphaDev/Lean
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLyraHeroComponent.h
More file actions
139 lines (104 loc) · 5.64 KB
/
Copy pathLyraHeroComponent.h
File metadata and controls
139 lines (104 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/GameFrameworkInitStateInterface.h"
#include "Components/PawnComponent.h"
#include "GameplayAbilitySpecHandle.h"
#include "LyraHeroComponent.generated.h"
namespace EEndPlayReason { enum Type : int; }
struct FLoadedMappableConfigPair;
struct FMappableConfigPair;
class UGameFrameworkComponentManager;
class UInputComponent;
class ULyraCameraMode;
class ULyraInputConfig;
class UObject;
struct FActorInitStateChangedParams;
struct FFrame;
struct FGameplayTag;
struct FInputActionValue;
/**
* 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 LYRAGAME_API ULyraHeroComponent : public UPawnComponent, public IGameFrameworkInitStateInterface
{
GENERATED_BODY()
public:
ULyraHeroComponent(const FObjectInitializer& ObjectInitializer);
/** Returns the hero component if one exists on the specified actor. */
UFUNCTION(BlueprintPure, Category = "Lyra|Hero")
static ULyraHeroComponent* FindHeroComponent(const AActor* Actor) { return (Actor ? Actor->FindComponentByClass<ULyraHeroComponent>() : nullptr); }
/** Overrides the camera from an active gameplay ability */
void SetAbilityCameraMode(TSubclassOf<ULyraCameraMode> CameraMode, const FGameplayAbilitySpecHandle& OwningSpecHandle);
/** Clears the camera override if it is set */
void ClearAbilityCameraMode(const FGameplayAbilitySpecHandle& OwningSpecHandle);
/** Adds mode-specific input config */
void AddAdditionalInputConfig(const ULyraInputConfig* InputConfig);
/** Removes a mode-specific input config if it has been added */
void RemoveAdditionalInputConfig(const ULyraInputConfig* 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;
// @TangoAlphaDev
// reset the player input after re-possess so the abilities and input work
UFUNCTION(BlueprintCallable)
void ResetPlayerInputAfterPossess();
// Overrides the ability camera with a secondary ability camera
void SetSecondaryAbilityCameraMode(TSubclassOf<ULyraCameraMode> CameraMode, const FGameplayAbilitySpecHandle& OwningSpecHandle);
// Clears the secondary camera override if it is set
void ClearSecondaryAbilityCameraMode(const FGameplayAbilitySpecHandle& OwningSpecHandle);
// @TangoAlphaDev
/** 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;
//~ Begin IGameFrameworkInitStateInterface interface
virtual FName GetFeatureName() const override { return NAME_ActorFeatureName; }
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
protected:
virtual void OnRegister() override;
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void InitializePlayerInput(UInputComponent* PlayerInputComponent);
void Input_AbilityInputTagPressed(FGameplayTag InputTag);
void Input_AbilityInputTagReleased(FGameplayTag InputTag);
void Input_Move(const FInputActionValue& InputActionValue);
void Input_LookMouse(const FInputActionValue& InputActionValue);
void Input_LookStick(const FInputActionValue& InputActionValue);
void Input_Crouch(const FInputActionValue& InputActionValue);
void Input_AutoRun(const FInputActionValue& InputActionValue);
TSubclassOf<ULyraCameraMode> DetermineCameraMode() const;
void OnInputConfigActivated(const FLoadedMappableConfigPair& ConfigPair);
void OnInputConfigDeactivated(const FLoadedMappableConfigPair& ConfigPair);
protected:
/**
* Input Configs that should be added to this player when initializing the input. These configs
* will NOT be registered with the settings because they are added at runtime. If you want the config
* pair to be in the settings, then add it via the GameFeatureAction_AddInputConfig
*
* NOTE: You should only add to this if you do not have a game feature plugin accessible to you.
* If you do, then use the GameFeatureAction_AddInputConfig instead.
*/
UPROPERTY(EditAnywhere)
TArray<FMappableConfigPair> DefaultInputConfigs;
/** Camera mode set by an ability. */
UPROPERTY()
TSubclassOf<ULyraCameraMode> AbilityCameraMode;
/** 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 bReadyToBindInputs;
// @TangoAlphaDev
// Camera mode set by a secondary ability
UPROPERTY()
TSubclassOf<ULyraCameraMode> SecondaryAbilityCameraMode;
// Spec handle for the last ability to set a camera mode.
FGameplayAbilitySpecHandle SecondaryAbilityCameraModeOwningSpecHandle;
// Stores the original ability camera mode
TSubclassOf<ULyraCameraMode> StoredAbilityCameraMode;
// @TangoAlphaDev
};