Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
v1.2.1 (#19)
Browse files Browse the repository at this point in the history
* Adjust folder and rename interface #18

* Update file ver.
  • Loading branch information
lucoiso authored Nov 14, 2022
1 parent 94e8fb2 commit a91bef1
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 43 deletions.
2 changes: 2 additions & 0 deletions Config/DefaultModularFeatures_ExtraActions.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[CoreRedirects]
+ClassRedirects=(OldName="/Script/ModularFeatures_ExtraActions.AbilityInputBinding", NewName="/Script/ModularFeatures_ExtraActions.MFEA_AbilityInputBinding")
4 changes: 2 additions & 2 deletions ModularFeatures_ExtraActions.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.2.0",
"Version": 2,
"VersionName": "1.2.1",
"FriendlyName": "Modular Features: Extra Actions",
"Description": "Integrates GAS and Enhanced Input to the existing Game Features and Modular plugins.",
"Category": "Game Features",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Year: 2022
// Repo: https://github.com/lucoiso/UEModularFeatures_ExtraActions

#include "GameFeatureAction_AddAbilities.h"
#include "Actions/GameFeatureAction_AddAbilities.h"
#include "Components/GameFrameworkComponentManager.h"
#include "InputAction.h"
#include "ModularFeatures_InternalFuncs.h"
Expand Down Expand Up @@ -122,7 +122,7 @@ void UGameFeatureAction_AddAbilities::AddActorAbilities(AActor* TargetActor, con
if (!Ability.InputAction.IsNull())
{
// Get the target Ability Input Binding interface
const IAbilityInputBinding* const SetupInputInterface = ModularFeaturesHelper::GetAbilityInputBindingInterface(TargetActor, InputBindingOwnerOverride);
const IMFEA_AbilityInputBinding* const SetupInputInterface = ModularFeaturesHelper::GetAbilityInputBindingInterface(TargetActor, InputBindingOwnerOverride);

// If we can bind the input to the target interface, we must add the input reference to the ability data
if (UInputAction* const AbilityInput = Ability.InputAction.LoadSynchronous();
Expand Down Expand Up @@ -181,7 +181,7 @@ void UGameFeatureAction_AddAbilities::RemoveActorAbilities(AActor* TargetActor)
}

// Get the interface owner and try to remove the input bindings
if (const IAbilityInputBinding* const SetupInputInterface = ModularFeaturesHelper::GetAbilityInputBindingInterface(TargetActor, InputBindingOwnerOverride))
if (const IMFEA_AbilityInputBinding* const SetupInputInterface = ModularFeaturesHelper::GetAbilityInputBindingInterface(TargetActor, InputBindingOwnerOverride))
{
ModularFeaturesHelper::RemoveAbilityInputInInterfaceOwner(SetupInputInterface->_getUObject(), ActiveAbilities.InputReference);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Year: 2022
// Repo: https://github.com/lucoiso/UEModularFeatures_ExtraActions

#include "GameFeatureAction_AddAttribute.h"
#include "Actions/GameFeatureAction_AddAttribute.h"
#include "Components/GameFrameworkComponentManager.h"
#include "ModularFeatures_InternalFuncs.h"
#include "Runtime/Launch/Resources/Version.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Year: 2022
// Repo: https://github.com/lucoiso/UEModularFeatures_ExtraActions

#include "GameFeatureAction_AddEffects.h"
#include "Actions/GameFeatureAction_AddEffects.h"
#include "Components/GameFrameworkComponentManager.h"
#include "ModularFeatures_InternalFuncs.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Year: 2022
// Repo: https://github.com/lucoiso/UEModularFeatures_ExtraActions

#include "GameFeatureAction_AddInputs.h"
#include "Actions/GameFeatureAction_AddInputs.h"
#include "EnhancedInputSubsystems.h"
#include "InputMappingContext.h"
#include "Components/GameFrameworkComponentManager.h"
Expand Down Expand Up @@ -176,8 +176,8 @@ void UGameFeatureAction_AddInputs::RemoveActorInputs(AActor* TargetActor)
InputComponent->RemoveBinding(InputActionBinding);
}

// Verify and try to remove the ability bindings by calling the RemoveAbilityInputBinding from IAbilityInputBinding interface
if (const IAbilityInputBinding* const SetupInputInterface = ModularFeaturesHelper::GetAbilityInputBindingInterface(TargetActor, InputBindingOwnerOverride))
// Verify and try to remove the ability bindings by calling the RemoveAbilityInputBinding from IMFEA_AbilityInputBinding interface
if (const IMFEA_AbilityInputBinding* const SetupInputInterface = ModularFeaturesHelper::GetAbilityInputBindingInterface(TargetActor, InputBindingOwnerOverride))
{
ModularFeaturesHelper::RemoveAbilityInputInInterfaceOwner(SetupInputInterface->_getUObject(), AbilityActions);
}
Expand All @@ -197,7 +197,7 @@ void UGameFeatureAction_AddInputs::SetupActionBindings(AActor* TargetActor, UObj
FInputBindingData& NewInputData = ActiveExtensions.FindOrAdd(TargetActor);

// Get and store the interface owner before the for-loop
const IAbilityInputBinding* const SetupInputInterface = ModularFeaturesHelper::GetAbilityInputBindingInterface(TargetActor, InputBindingOwnerOverride);
const IMFEA_AbilityInputBinding* const SetupInputInterface = ModularFeaturesHelper::GetAbilityInputBindingInterface(TargetActor, InputBindingOwnerOverride);

// Load the enumeration and save it before the loop to avoid high disk consumption due to loading a soft reference a lot of times since there's only 1 enumeration
TWeakObjectPtr<UEnum> InputIDEnumeration_Ptr = ModularFeaturesHelper::LoadInputEnum();
Expand Down Expand Up @@ -233,7 +233,7 @@ void UGameFeatureAction_AddInputs::SetupActionBindings(AActor* TargetActor, UObj
continue;
}

// Try to bind this input by calling the function SetupAbilityInputBinding from IAbilityInputBinding interface
// Try to bind this input by calling the function SetupAbilityInputBinding from IMFEA_AbilityInputBinding interface
if (FGameplayAbilitySpec NewAbilitySpec = GetAbilitySpecInformationFromBindingData(TargetActor, AbilityBindingData, InputIDEnumeration_Ptr.Get());
ModularFeaturesHelper::BindAbilityInputToInterfaceOwner(SetupInputInterface, InputAction, NewAbilitySpec))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Year: 2022
// Repo: https://github.com/lucoiso/UEModularFeatures_ExtraActions

#include "GameFeatureAction_SpawnActors.h"
#include "Actions/GameFeatureAction_SpawnActors.h"
#include "Components/GameFrameworkComponentManager.h"

void UGameFeatureAction_SpawnActors::OnGameFeatureActivating(FGameFeatureActivatingContext& Context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Year: 2022
// Repo: https://github.com/lucoiso/UEModularFeatures_ExtraActions

#include "GameFeatureAction_WorldActionBase.h"
#include "Actions/GameFeatureAction_WorldActionBase.h"

void UGameFeatureAction_WorldActionBase::OnGameFeatureActivating(FGameFeatureActivatingContext& Context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// Year: 2022
// Repo: https://github.com/lucoiso/UEModularFeatures_ExtraActions

#include "AbilityInputBinding.h"
#include "Interfaces/MFEA_AbilityInputBinding.h"
24 changes: 11 additions & 13 deletions Source/Private/ModularFeatures_InternalFuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "AbilitySystemInterface.h"
#include "AbilityInputBinding.h"
#include "Interfaces/MFEA_AbilityInputBinding.h"
#include "EnhancedInputComponent.h"
#include "GameFramework/Controller.h"
#include "LogModularFeatures_ExtraActions.h"
Expand Down Expand Up @@ -57,7 +57,7 @@ namespace ModularFeaturesHelper
return GetPluginSettings()->InputBindingOwner;
}

IAbilityInputBinding* GetAbilityInputBindingInterface(AActor* InActor, const EInputBindingOwnerOverride& InOwner)
IMFEA_AbilityInputBinding* GetAbilityInputBindingInterface(AActor* InActor, const EInputBindingOwnerOverride& InOwner)
{
if (!IsValid(InActor))
{
Expand All @@ -68,8 +68,8 @@ namespace ModularFeaturesHelper
{
switch (GetValidatedInputBindingOwner(InOwner))
{
case EInputBindingOwner::Pawn: return Cast<IAbilityInputBinding>(TargetPawn);
case EInputBindingOwner::Controller: return Cast<IAbilityInputBinding>(TargetPawn->GetController());
case EInputBindingOwner::Pawn: return Cast<IMFEA_AbilityInputBinding>(TargetPawn);
case EInputBindingOwner::Controller: return Cast<IMFEA_AbilityInputBinding>(TargetPawn->GetController());
default: return nullptr;
}
}
Expand Down Expand Up @@ -116,7 +116,7 @@ namespace ModularFeaturesHelper
}

// Will be removed in the future - but i don't want to break existing projects :)
const bool BindAbilityInputToInterfaceOwnerWithID(const IAbilityInputBinding* TargetInterfaceOwner, UInputAction* InputAction, const int32 InputID)
const bool BindAbilityInputToInterfaceOwnerWithID(const IMFEA_AbilityInputBinding* TargetInterfaceOwner, UInputAction* InputAction, const int32 InputID)
{
if (!TargetInterfaceOwner)
{
Expand All @@ -125,12 +125,10 @@ namespace ModularFeaturesHelper
return false;
}

IAbilityInputBinding::Execute_SetupAbilityInputBinding(TargetInterfaceOwner->_getUObject(), InputAction, InputID);

return true;
}

const bool BindAbilityInputToInterfaceOwner(const IAbilityInputBinding* TargetInterfaceOwner, UInputAction* InputAction, const FGameplayAbilitySpec& AbilitySpec)
const bool BindAbilityInputToInterfaceOwner(const IMFEA_AbilityInputBinding* TargetInterfaceOwner, UInputAction* InputAction, const FGameplayAbilitySpec& AbilitySpec)
{
if (!BindAbilityInputToInterfaceOwnerWithID(TargetInterfaceOwner, InputAction, AbilitySpec.InputID))
{
Expand All @@ -140,19 +138,19 @@ namespace ModularFeaturesHelper
switch (GetPluginSettings()->AbilityBindingMode)
{
case (EAbilityBindingMode::InputID):
IAbilityInputBinding::Execute_SetupAbilityBindingByInput(TargetInterfaceOwner->_getUObject(), InputAction, AbilitySpec.InputID);
IMFEA_AbilityInputBinding::Execute_SetupAbilityBindingByInput(TargetInterfaceOwner->_getUObject(), InputAction, AbilitySpec.InputID);
break;

case (EAbilityBindingMode::AbilitySpec):
IAbilityInputBinding::Execute_SetupAbilityBindingBySpec(TargetInterfaceOwner->_getUObject(), InputAction, AbilitySpec);
IMFEA_AbilityInputBinding::Execute_SetupAbilityBindingBySpec(TargetInterfaceOwner->_getUObject(), InputAction, AbilitySpec);
break;

case (EAbilityBindingMode::AbilityTags):
IAbilityInputBinding::Execute_SetupAbilityBindingByTags(TargetInterfaceOwner->_getUObject(), InputAction, AbilitySpec.Ability->AbilityTags);
IMFEA_AbilityInputBinding::Execute_SetupAbilityBindingByTags(TargetInterfaceOwner->_getUObject(), InputAction, AbilitySpec.Ability->AbilityTags);
break;

case (EAbilityBindingMode::AbilityClass):
IAbilityInputBinding::Execute_SetupAbilityBindingByClass(TargetInterfaceOwner->_getUObject(), InputAction, TSubclassOf<UGameplayAbility>(AbilitySpec.Ability->GetClass()));
IMFEA_AbilityInputBinding::Execute_SetupAbilityBindingByClass(TargetInterfaceOwner->_getUObject(), InputAction, TSubclassOf<UGameplayAbility>(AbilitySpec.Ability->GetClass()));
break;

default:
Expand All @@ -174,7 +172,7 @@ namespace ModularFeaturesHelper
{
if (InputRef.IsValid())
{
IAbilityInputBinding::Execute_RemoveAbilityInputBinding(InterfaceOwner, InputRef.Get());
IMFEA_AbilityInputBinding::Execute_RemoveAbilityInputBinding(InterfaceOwner, InputRef.Get());
}

InputRef.Reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "CoreMinimal.h"
#include "GameplayAbilitySpec.h"
#include "GameFeatureAction_WorldActionBase.h"
#include "Actions/GameFeatureAction_WorldActionBase.h"
#include "GameFeatureAction_AddAbilities.generated.h"

class UGameplayAbility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "CoreMinimal.h"
#include "GameFeatureAction_WorldActionBase.h"
#include "Actions/GameFeatureAction_WorldActionBase.h"
#include "GameFeatureAction_AddAttribute.generated.h"

class UAttributeSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "CoreMinimal.h"
#include "GameplayTagContainer.h"
#include "GameplayEffectTypes.h"
#include "GameFeatureAction_WorldActionBase.h"
#include "Actions/GameFeatureAction_WorldActionBase.h"
#include "GameFeatureAction_AddEffects.generated.h"

class UGameplayEffect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "InputTriggers.h"
#include "EnhancedInputComponent.h"
#include "GameplayAbilitySpec.h"
#include "GameFeatureAction_WorldActionBase.h"
#include "Actions/GameFeatureAction_WorldActionBase.h"
#include "GameFeatureAction_AddInputs.generated.h"

class UGameplayAbility;
Expand Down Expand Up @@ -40,7 +40,7 @@ struct FAbilityInputBindingData
{
GENERATED_BODY()

/* Should this action setup call SetupAbilityInput/RemoveAbilityInputBinding using the IAbilityInputBinding interface? */
/* Should this action setup call SetupAbilityInput/RemoveAbilityInputBinding using the IMFEA_AbilityInputBinding interface? */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings")
bool bSetupAbilityInput = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "CoreMinimal.h"
#include "GameFeatureAction_WorldActionBase.h"
#include "Actions/GameFeatureAction_WorldActionBase.h"
#include "GameFeatureAction_SpawnActors.generated.h"

struct FComponentRequestHandle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,25 @@
#include "UObject/Interface.h"
#include "GameplayAbilitySpec.h"
#include "GameplayTagContainer.h"
#include "AbilityInputBinding.generated.h"
#include "MFEA_AbilityInputBinding.generated.h"

/**
*
*/
class UInputAction;

/* Your pawn or controller need this inferface to accept ability input bindings */
UINTERFACE(MinimalAPI, Blueprintable, Category = "MF Extra Actions | Modular Interfaces")
class UAbilityInputBinding : public UInterface
UINTERFACE(MinimalAPI, Blueprintable, Category = "MF Extra Actions | Interfaces", Meta = (DisplayName = "MF Extra Actions: Ability Input Binding"))
class UMFEA_AbilityInputBinding : public UInterface
{
GENERATED_BODY()
};

/* Your pawn or controller need this inferface to accept ability input bindings */
class MODULARFEATURES_EXTRAACTIONS_API IAbilityInputBinding
class MODULARFEATURES_EXTRAACTIONS_API IMFEA_AbilityInputBinding
{
GENERATED_IINTERFACE_BODY()

/* This function is needed for setup ability input binding inside your controller or pawn */
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "MF Extra Actions | Modular Interfaces", Meta = (Deprecated = "true", DeprecationMessage = "There are new functions to bind the input. Please check SetupAbilityBindingByInput, SetupAbilityBindingBySpec, SetupAbilityBindingByTags and SetupAbilityBindingByClass"))
void SetupAbilityInputBinding(UInputAction* Action, const int32 InputID);

/* Setup ability bind using input id - AbilityLocalInputPressed(InputID)*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "MF Extra Actions | Modular Interfaces")
void SetupAbilityBindingByInput(UInputAction* Action, const int32 InputID);
Expand Down
2 changes: 1 addition & 1 deletion Source/Public/MFEA_Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MODULARFEATURES_EXTRAACTIONS_API UMFEA_Settings : public UDeveloperSetting
bool bEnableAbilityAutoBinding;

public:
/* Determine the binding mode that will be used by this plugin - This choice affects which function from IAbilityInputBinding interface will be used to bind the abilities */
/* Determine the binding mode that will be used by this plugin - This choice affects which function from IMFEA_AbilityInputBinding interface will be used to bind the abilities */
UPROPERTY(GlobalConfig, EditAnywhere, Category = "Settings", Meta = (EditCondition = "!bEnableAbilityAutoBinding"))
EAbilityBindingMode AbilityBindingMode;

Expand Down

0 comments on commit a91bef1

Please sign in to comment.