:(
This commit is contained in:
47
Source/Aura/Public/Input/AuraInputComponent.h
Normal file
47
Source/Aura/Public/Input/AuraInputComponent.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright Echo Devgroup
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AuraInputConfig.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "AuraInputComponent.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraInputComponent : public UEnhancedInputComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
template<class UserClass, typename PressedFuncType, typename ReleasedFuncType, typename HeldFuncType>
|
||||
void BindAbilityActions(const UAuraInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc, HeldFuncType HeldFunc);
|
||||
};
|
||||
|
||||
template <class UserClass, typename PressedFuncType, typename ReleasedFuncType, typename HeldFuncType>
|
||||
void UAuraInputComponent::BindAbilityActions(const UAuraInputConfig* InputConfig, UserClass* Object,
|
||||
PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc, HeldFuncType HeldFunc)
|
||||
{
|
||||
check(InputConfig);
|
||||
|
||||
for (const FAuraInputAction& Action : InputConfig->AbilityInputActions)
|
||||
{
|
||||
if (Action.InputAction && Action.InputTag.IsValid())
|
||||
{
|
||||
if (PressedFunc)
|
||||
{
|
||||
BindAction(Action.InputAction, ETriggerEvent::Started, Object, PressedFunc, Action.InputTag);
|
||||
}
|
||||
if (ReleasedFunc)
|
||||
{
|
||||
BindAction(Action.InputAction, ETriggerEvent::Completed, Object, ReleasedFunc, Action.InputTag);
|
||||
}
|
||||
if (HeldFunc)
|
||||
{
|
||||
BindAction(Action.InputAction, ETriggerEvent::Triggered, Object, HeldFunc, Action.InputTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Source/Aura/Public/Input/AuraInputConfig.h
Normal file
37
Source/Aura/Public/Input/AuraInputConfig.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright Echo Devgroup
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "AuraInputConfig.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FAuraInputAction
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
const class UInputAction* InputAction = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
FGameplayTag InputTag = FGameplayTag();
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API UAuraInputConfig : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
const UInputAction* FindAbilityInputActionForTag(const FGameplayTag& InputTag, bool bLogNotFound = false) const;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
TArray<FAuraInputAction> AbilityInputActions;
|
||||
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user