83 lines
2.6 KiB
C++
83 lines
2.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Abilities/GameplayAbility.h"
|
|
#include "InteractionOption.generated.h"
|
|
|
|
class IInteractableTarget;
|
|
class UUserWidget;
|
|
|
|
/** */
|
|
USTRUCT(BlueprintType)
|
|
struct FInteractionOption
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/** The interactable target */
|
|
UPROPERTY(BlueprintReadWrite)
|
|
TScriptInterface<IInteractableTarget> InteractableTarget;
|
|
|
|
/** Simple text the interaction might return */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
FText Text;
|
|
|
|
/** Simple sub-text the interaction might return */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
FText SubText;
|
|
|
|
// METHODS OF INTERACTION
|
|
//--------------------------------------------------------------
|
|
|
|
// 1) Place an ability on the avatar that they can activate when they perform interaction.
|
|
|
|
/** The ability to grant the avatar when they get near interactable objects. */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
|
TSubclassOf<UGameplayAbility> InteractionAbilityToGrant;
|
|
|
|
// - OR -
|
|
|
|
// 2) Allow the object we're interacting with to have its own ability system and interaction ability, that we can activate instead.
|
|
|
|
/** The ability system on the target that can be used for the TargetInteractionHandle and sending the event, if needed. */
|
|
UPROPERTY(BlueprintReadOnly)
|
|
TObjectPtr<UAbilitySystemComponent> TargetAbilitySystem = nullptr;
|
|
|
|
/** The ability spec to activate on the object for this option. */
|
|
UPROPERTY(BlueprintReadOnly)
|
|
FGameplayAbilitySpecHandle TargetInteractionAbilityHandle;
|
|
|
|
// UI
|
|
//--------------------------------------------------------------
|
|
|
|
/** The widget to show for this kind of interaction. */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
TSoftClassPtr<UUserWidget> InteractionWidgetClass;
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
public:
|
|
FORCEINLINE bool operator==(const FInteractionOption& Other) const
|
|
{
|
|
return InteractableTarget == Other.InteractableTarget &&
|
|
InteractionAbilityToGrant == Other.InteractionAbilityToGrant&&
|
|
TargetAbilitySystem == Other.TargetAbilitySystem &&
|
|
TargetInteractionAbilityHandle == Other.TargetInteractionAbilityHandle &&
|
|
InteractionWidgetClass == Other.InteractionWidgetClass &&
|
|
Text.IdenticalTo(Other.Text) &&
|
|
SubText.IdenticalTo(Other.SubText);
|
|
}
|
|
|
|
FORCEINLINE bool operator!=(const FInteractionOption& Other) const
|
|
{
|
|
return !operator==(Other);
|
|
}
|
|
|
|
FORCEINLINE bool operator<(const FInteractionOption& Other) const
|
|
{
|
|
return InteractableTarget.GetInterface() < Other.InteractableTarget.GetInterface();
|
|
}
|
|
};
|