document.write("
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AbilityTask_MoveCharacterToLocation.h"
#include "AbilityTask_FollowCursor.generated.h"
/**
* Simple delegate for callbacks on FollowCursor tasks.
*/
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FFollowCursorSimpleDelegate);
/**
* AbilityTask that sends movement input to the Avatar Pawn pointing from the Avatar Pawn to the location under the
* cursor. Stops once Avatar Pawn reaches an XY distance within a specified threshold.
*/
UCLASS()
class DANDELION_API UAbilityTask_FollowCursor : public UAbilityTask
{
GENERATED_BODY()
public:
/**
* Callback raised when the Avatar Pawn reaches an XY distance within a specified threshold.
*/
UPROPERTY(BlueprintAssignable)
FFollowCursorSimpleDelegate OnMoveComplete;
/**
* Enables ticking.
*/
UAbilityTask_FollowCursor();
/**
* Static constructor that initializes cached references and sets passed in parameters.
* @param OwningAbility The GA that initiated this task.
* @param TaskInstanceName The name of this task.
* @param StopDistance The XY distance that Avatar Pawn needs to befrom the TargetLocation in order to stop.
* @return A newly instantiated and initialized UAbilityTask_FollowCursor.
*/
UFUNCTION(
BlueprintCallable,
Category = "Ability|Tasks",
meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE")
)
static UAbilityTask_FollowCursor* FollowCursor(
UDandelionGameplayAbility* OwningAbility,
FName TaskInstanceName,
float StopDistance = 0.f
);
/**
* If this task is ever externally cancelled, stop any current player movement.
*/
virtual void ExternalCancel() override;
protected:
/**
* When this task activates, stop any current movement on the PlayerController.
*/
virtual void Activate() override;
/**
* Update the target location, and check to see if it's within the stop distance. End the task if so, otherwise send
* movement input to the PlayerController.
* @param DeltaTime The amount of time that has elapsed since this was last ticked.
*/
virtual void TickTask(float DeltaTime) override;
private:
/**
* Cached reference to the Pawn that was the Avatar Actor for the initiating GA.
*/
UPROPERTY(Transient)
TObjectPtr<APawn> PlayerPawn;
/**
* Cached reference to the PlayerController that possessed the Avatar Actor for the initiating GA.
*/
UPROPERTY(Transient)
TObjectPtr<ADandelionPlayerController> PlayerController;
/**
* The current world location this task is trying to move to.
*/
FVector TargetLocation;
/**
* The XY distance that Avatar Pawn needs to befrom the TargetLocation in order to stop.
*/
float StopDistance = 0.f;
/**
* Helper method that updates the TargetLocation with the hit result under the cursor if a hit was encountered.
*/
void UpdateTargetLocation();
};
AbilityTask_FollowCursor.h - Snippet hosted by \"Cacher\"
");