// (C)2022 InterKaos Games. #pragma once #include "CoreMinimal.h" #include "AbilitySystemComponent.h" #include "Abilities/Tasks/AbilityTask.h" #include "AbilityTask_InputDirection.generated.h" DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FKaosInputDirectionTargetDataDelegate, const FGameplayAbilityTargetDataHandle&, Data); /** * Gets the current input from the local player and its camera forward vector and spits out the location. * This is then replicated to server who waits for said data before continuing the ability. */ UCLASS() class KAOSGAME_API UAbilityTask_InputDirection : public UAbilityTask { GENERATED_UCLASS_BODY() UPROPERTY(BlueprintAssignable) FKaosInputDirectionTargetDataDelegate ValidData; UPROPERTY(BlueprintAssignable) FKaosInputDirectionTargetDataDelegate Cancelled; UFUNCTION() void OnTargetDataReplicatedCallback(const FGameplayAbilityTargetDataHandle& Data, FGameplayTag ActivationTag); UFUNCTION() void OnTargetDataReplicatedCancelledCallback(); void ProduceDirection(); /** Spawns target actor and waits for it to return valid data or to be canceled. */ UFUNCTION(BlueprintCallable, meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "true", HideSpawnParms = "Instigator"), Category = "Ability|Tasks") static UAbilityTask_InputDirection* GetInputDirection(UGameplayAbility* OwningAbility, FName TaskInstanceName); virtual void Activate() override; /** Called when the ability is asked to confirm from an outside node. What this means depends on the individual task. By default, this does nothing other than ending if bEndTask is true. */ virtual void ExternalConfirm(bool bEndTask) override; /** Called when the ability is asked to cancel from an outside node. What this means depends on the individual task. By default, this does nothing other than ending the task. */ virtual void ExternalCancel() override; protected: void RegisterTargetDataCallbacks(); virtual void OnDestroy(bool AbilityEnded) override; protected: FDelegateHandle OnTargetDataReplicatedCallbackDelegateHandle; };