mirror of
https://github.com/Ed94/Cog.git
synced 2026-07-27 09:50:02 +00:00
Start to add hit impact on the sample
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,33 @@
|
|||||||
|
#include "CogSampleAbilitySystemComponent.h"
|
||||||
|
|
||||||
|
#include "AbilitySystemGlobals.h"
|
||||||
|
#include "GameplayCueManager.h"
|
||||||
|
#include "GameplayEffectTypes.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void UCogSampleAbilitySystemComponent::ExecuteGameplayCueLocal(const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters) const
|
||||||
|
{
|
||||||
|
if (AActor* ActorAvatar = AbilityActorInfo->AvatarActor.Get())
|
||||||
|
{
|
||||||
|
UAbilitySystemGlobals::Get().GetGameplayCueManager()->HandleGameplayCue(ActorAvatar, GameplayCueTag, EGameplayCueEvent::Type::Executed, GameplayCueParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void UCogSampleAbilitySystemComponent::AddGameplayCueLocal(const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters) const
|
||||||
|
{
|
||||||
|
if (AActor* ActorAvatar = AbilityActorInfo->AvatarActor.Get())
|
||||||
|
{
|
||||||
|
UAbilitySystemGlobals::Get().GetGameplayCueManager()->HandleGameplayCue(ActorAvatar, GameplayCueTag, EGameplayCueEvent::Type::OnActive, GameplayCueParameters);
|
||||||
|
UAbilitySystemGlobals::Get().GetGameplayCueManager()->HandleGameplayCue(ActorAvatar, GameplayCueTag, EGameplayCueEvent::Type::WhileActive, GameplayCueParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void UCogSampleAbilitySystemComponent::RemoveGameplayCueLocal(const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters) const
|
||||||
|
{
|
||||||
|
if (AActor* ActorAvatar = AbilityActorInfo->AvatarActor.Get())
|
||||||
|
{
|
||||||
|
UAbilitySystemGlobals::Get().GetGameplayCueManager()->HandleGameplayCue(ActorAvatar, GameplayCueTag, EGameplayCueEvent::Type::Removed, GameplayCueParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "AbilitySystemComponent.h"
|
||||||
|
#include "CogSampleAbilitySystemComponent.generated.h"
|
||||||
|
|
||||||
|
UCLASS(BlueprintType)
|
||||||
|
class UCogSampleAbilitySystemComponent : public UAbilitySystemComponent
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "GameplayCue", Meta = (AutoCreateRefTerm = "GameplayCueParameters", GameplayTagFilter = "GameplayCue"))
|
||||||
|
void ExecuteGameplayCueLocal(const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters) const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "GameplayCue", Meta = (AutoCreateRefTerm = "GameplayCueParameters", GameplayTagFilter = "GameplayCue"))
|
||||||
|
void AddGameplayCueLocal(const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters) const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "GameplayCue", Meta = (AutoCreateRefTerm = "GameplayCueParameters", GameplayTagFilter = "GameplayCue"))
|
||||||
|
void RemoveGameplayCueLocal(const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters) const;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "Camera/CameraComponent.h"
|
#include "Camera/CameraComponent.h"
|
||||||
#include "CogCommon.h"
|
#include "CogCommon.h"
|
||||||
|
#include "CogSampleAbilitySystemComponent.h"
|
||||||
#include "CogSampleAttributeSet_Health.h"
|
#include "CogSampleAttributeSet_Health.h"
|
||||||
#include "CogSampleAttributeSet_Misc.h"
|
#include "CogSampleAttributeSet_Misc.h"
|
||||||
#include "CogSampleCharacterMovementComponent.h"
|
#include "CogSampleCharacterMovementComponent.h"
|
||||||
@@ -64,7 +65,7 @@ ACogSampleCharacter::ACogSampleCharacter(const FObjectInitializer& ObjectInitial
|
|||||||
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
|
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
|
||||||
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
|
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
|
||||||
|
|
||||||
AbilitySystem = CreateDefaultSubobject<UAbilitySystemComponent>(TEXT("AbilitySystem"));
|
AbilitySystem = CreateDefaultSubobject<UCogSampleAbilitySystemComponent>(TEXT("AbilitySystem"));
|
||||||
AbilitySystem->SetIsReplicated(true);
|
AbilitySystem->SetIsReplicated(true);
|
||||||
AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Full);
|
AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Full);
|
||||||
}
|
}
|
||||||
@@ -798,3 +799,24 @@ void ACogSampleCharacter::GetTargetCapsules(TArray<const UCapsuleComponent*>& Ca
|
|||||||
Capsules.Add(GetCapsuleComponent());
|
Capsules.Add(GetCapsuleComponent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool ACogSampleCharacter::GetMontage(FName MontageName, UAnimMontage*& Montage, bool bPrintWarning) const
|
||||||
|
{
|
||||||
|
Montage = nullptr;
|
||||||
|
|
||||||
|
if (MontageTable == nullptr)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FString ContextString(TEXT("GetMontage"));
|
||||||
|
FCogSampleMontageTableRow* Row = MontageTable->FindRow<FCogSampleMontageTableRow>(MontageName, ContextString, bPrintWarning);
|
||||||
|
|
||||||
|
if (Row == nullptr)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Montage = Row->Montage;
|
||||||
|
return Montage != nullptr;
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "CogCommonDebugFilteredActorInterface.h"
|
#include "CogCommonDebugFilteredActorInterface.h"
|
||||||
#include "CogSampleDamageEvent.h"
|
#include "CogSampleDamageEvent.h"
|
||||||
#include "CogSampleDefines.h"
|
#include "CogSampleDefines.h"
|
||||||
|
#include "CogSampleDamageableInterface.h"
|
||||||
#include "CogSampleTargetableInterface.h"
|
#include "CogSampleTargetableInterface.h"
|
||||||
#include "CogSampleTeamInterface.h"
|
#include "CogSampleTeamInterface.h"
|
||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
@@ -16,9 +17,9 @@
|
|||||||
#include "InputActionValue.h"
|
#include "InputActionValue.h"
|
||||||
#include "CogSampleCharacter.generated.h"
|
#include "CogSampleCharacter.generated.h"
|
||||||
|
|
||||||
class UAbilitySystemComponent;
|
|
||||||
class UCogAbilitySystemComponent;
|
|
||||||
class UCameraComponent;
|
class UCameraComponent;
|
||||||
|
class UCogAbilitySystemComponent;
|
||||||
|
class UCogSampleAbilitySystemComponent;
|
||||||
class UGameplayAbility;
|
class UGameplayAbility;
|
||||||
class UGameplayEffect;
|
class UGameplayEffect;
|
||||||
class UInputAction;
|
class UInputAction;
|
||||||
@@ -58,6 +59,19 @@ public:
|
|||||||
bool ActivateWhenGiven = false;
|
bool ActivateWhenGiven = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FCogSampleMontageTableRow : public FTableRowBase
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
FCogSampleMontageTableRow() {}
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||||
|
UAnimMontage* Montage = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCogSampleCharacterEventDelegate, ACogSampleCharacter*, Character);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCogSampleCharacterEventDelegate, ACogSampleCharacter*, Character);
|
||||||
|
|
||||||
@@ -69,6 +83,7 @@ class ACogSampleCharacter : public ACharacter
|
|||||||
, public ICogCommonAllegianceActorInterface
|
, public ICogCommonAllegianceActorInterface
|
||||||
, public ICogSampleTeamInterface
|
, public ICogSampleTeamInterface
|
||||||
, public ICogSampleTargetableInterface
|
, public ICogSampleTargetableInterface
|
||||||
|
, public ICogSampleDamageableInterface
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
@@ -118,6 +133,14 @@ public:
|
|||||||
|
|
||||||
virtual void GetTargetCapsules(TArray<const UCapsuleComponent*>& Capsules) const override;
|
virtual void GetTargetCapsules(TArray<const UCapsuleComponent*>& Capsules) const override;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ICogSampleDamageableInterface overrides
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
virtual void HandleDamageReceived(const FCogSampleDamageEventParams& Params) override;
|
||||||
|
|
||||||
|
virtual void HandleDamageDealt(const FCogSampleDamageEventParams& Params) override;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
// Team
|
// Team
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -182,16 +205,12 @@ public:
|
|||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
bool IsInitialized() const { return bIsInitialized; }
|
bool IsInitialized() const { return bIsInitialized; }
|
||||||
|
|
||||||
void HandleDamageReceived(const FCogSampleDamageEventParams& Params);
|
|
||||||
|
|
||||||
void HandleDamageDealt(const FCogSampleDamageEventParams& Params);
|
|
||||||
|
|
||||||
void OnKilled(AActor* InInstigator, AActor* InCauser, const FGameplayEffectSpec& InEffectSpec, float InMagnitude);
|
void OnKilled(AActor* InInstigator, AActor* InCauser, const FGameplayEffectSpec& InEffectSpec, float InMagnitude);
|
||||||
|
|
||||||
void OnRevived(AActor* InInstigator, AActor* InCauser, const FGameplayEffectSpec& InEffectSpec, float InMagnitude);
|
void OnRevived(AActor* InInstigator, AActor* InCauser, const FGameplayEffectSpec& InEffectSpec, float InMagnitude);
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, Category = Ability, meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(BlueprintReadOnly, Category = Ability, meta = (AllowPrivateAccess = "true"))
|
||||||
UAbilitySystemComponent* AbilitySystem = nullptr;
|
UCogSampleAbilitySystemComponent* AbilitySystem = nullptr;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Ability)
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Ability)
|
||||||
TArray<TSubclassOf<UAttributeSet>> AttributeSets;
|
TArray<TSubclassOf<UAttributeSet>> AttributeSets;
|
||||||
@@ -229,6 +248,15 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
int32 ApplyRootMotion(const FCogSampleRootMotionParams& Params);
|
int32 ApplyRootMotion(const FCogSampleRootMotionParams& Params);
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Montage
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Animation", meta = (RowType = "/Script/CogSample.FCogSampleMontageTableRow"))
|
||||||
|
UDataTable* MontageTable = nullptr;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, BlueprintPure=false)
|
||||||
|
bool GetMontage(FName MontageName, UAnimMontage*& Montage, bool bPrintWarning) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ACogSamplePlayerController;
|
friend class ACogSamplePlayerController;
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "CogSampleDamageEvent.generated.h"
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
USTRUCT(BlueprintType)
|
|
||||||
struct FCogSampleDamageEventParams
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
UPROPERTY(BlueprintReadWrite)
|
|
||||||
float MitigatedDamage = 0;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite)
|
|
||||||
float UnmitigatedDamage = 0;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite)
|
|
||||||
AActor* DamageDealer = nullptr;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite)
|
|
||||||
AActor* DamageReceiver = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCogSampleDamageEventDelegate, const FCogSampleDamageEventParams&, Params);
|
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "CogSampleDamageableInterface.generated.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FCogSampleDamageEventParams
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
float MitigatedDamage = 0;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
float UnmitigatedDamage = 0;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
AActor* DamageDealer = nullptr;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
AActor* DamageReceiver = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCogSampleDamageEventDelegate, const FCogSampleDamageEventParams&, Params);
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
UINTERFACE(MinimalAPI, Blueprintable)
|
||||||
|
class UCogSampleDamageableInterface : public UInterface
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
class ICogSampleDamageableInterface
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void HandleDamageReceived(const FCogSampleDamageEventParams& Params) {}
|
||||||
|
|
||||||
|
virtual void HandleDamageDealt(const FCogSampleDamageEventParams& Params) {}
|
||||||
|
};
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
#include "CogSampleExecCalculation_Damage.h"
|
#include "CogSampleExecCalculation_Damage.h"
|
||||||
|
|
||||||
|
#include "CogSampleAbilitySystemComponent.h"
|
||||||
#include "CogSampleAttributeSet_Health.h"
|
#include "CogSampleAttributeSet_Health.h"
|
||||||
#include "CogSampleCharacter.h"
|
#include "CogSampleCharacter.h"
|
||||||
|
#include "CogSampleDamageableInterface.h"
|
||||||
#include "CogSampleFunctionLibrary_Tag.h"
|
#include "CogSampleFunctionLibrary_Tag.h"
|
||||||
|
#include "CogSampleGameplayEffectContext.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
struct FCogSampleDamageStatics
|
struct FCogSampleDamageStatics
|
||||||
@@ -37,22 +40,37 @@ UCogSampleExecCalculation_Damage::UCogSampleExecCalculation_Damage()
|
|||||||
void UCogSampleExecCalculation_Damage::Execute_Implementation(const FGameplayEffectCustomExecutionParameters& ExecutionParams, OUT FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const
|
void UCogSampleExecCalculation_Damage::Execute_Implementation(const FGameplayEffectCustomExecutionParameters& ExecutionParams, OUT FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const
|
||||||
{
|
{
|
||||||
const FGameplayEffectSpec& EffectSpec = ExecutionParams.GetOwningSpec();
|
const FGameplayEffectSpec& EffectSpec = ExecutionParams.GetOwningSpec();
|
||||||
const FGameplayEffectContextHandle Context = EffectSpec.GetContext();
|
FGameplayEffectContextHandle EffectContext = EffectSpec.GetContext();
|
||||||
|
|
||||||
FAggregatorEvaluateParameters EvaluationParameters;
|
FAggregatorEvaluateParameters EvaluationParameters;
|
||||||
EvaluationParameters.SourceTags = EffectSpec.CapturedSourceTags.GetAggregatedTags();
|
EvaluationParameters.SourceTags = EffectSpec.CapturedSourceTags.GetAggregatedTags();
|
||||||
EvaluationParameters.TargetTags = EffectSpec.CapturedTargetTags.GetAggregatedTags();
|
EvaluationParameters.TargetTags = EffectSpec.CapturedTargetTags.GetAggregatedTags();
|
||||||
|
|
||||||
UAbilitySystemComponent* TargetAbilitySystem = ExecutionParams.GetTargetAbilitySystemComponent();
|
UCogSampleAbilitySystemComponent* TargetAbilitySystem = Cast<UCogSampleAbilitySystemComponent>(ExecutionParams.GetTargetAbilitySystemComponent());
|
||||||
UAbilitySystemComponent* SourceAbilitySystem = ExecutionParams.GetSourceAbilitySystemComponent();
|
AActor* TargetActor = (TargetAbilitySystem != nullptr) ? TargetAbilitySystem->GetAvatarActor() : nullptr;
|
||||||
ACogSampleCharacter* TargetCharacter = (TargetAbilitySystem != nullptr) ? Cast<ACogSampleCharacter>(TargetAbilitySystem->AbilityActorInfo.IsValid() ? TargetAbilitySystem->GetAvatarActor() : nullptr) : nullptr;
|
|
||||||
ACogSampleCharacter* SourceCharacter = (SourceAbilitySystem != nullptr) ? Cast<ACogSampleCharacter>(SourceAbilitySystem->AbilityActorInfo.IsValid() ? SourceAbilitySystem->GetAvatarActor() : nullptr) : nullptr;
|
|
||||||
|
|
||||||
if (TargetCharacter == nullptr)
|
UCogSampleAbilitySystemComponent* SourceAbilitySystem = Cast<UCogSampleAbilitySystemComponent>(ExecutionParams.GetSourceAbilitySystemComponent());
|
||||||
|
AActor* SourceActor = (SourceAbilitySystem != nullptr) ? SourceAbilitySystem->GetAvatarActor() : nullptr;
|
||||||
|
|
||||||
|
if (TargetActor == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FHitResult HitResult;
|
||||||
|
if (const FHitResult* HitResultPtr = EffectContext.GetHitResult())
|
||||||
|
{
|
||||||
|
HitResult = *HitResultPtr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HitResult.Location = TargetActor->GetActorLocation();
|
||||||
|
HitResult.Normal = TargetActor->GetActorForwardVector();
|
||||||
|
HitResult.ImpactNormal = TargetActor->GetActorForwardVector();
|
||||||
|
EffectContext.AddHitResult(HitResult, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FGameplayTagContainer SpecAssetTags;
|
FGameplayTagContainer SpecAssetTags;
|
||||||
EffectSpec.GetAllAssetTags(SpecAssetTags);
|
EffectSpec.GetAllAssetTags(SpecAssetTags);
|
||||||
|
|
||||||
@@ -88,16 +106,75 @@ void UCogSampleExecCalculation_Damage::Execute_Implementation(const FGameplayEff
|
|||||||
OutExecutionOutput.AddOutputModifier(FGameplayModifierEvaluatedData(UCogSampleAttributeSet_Health::GetHealthAttribute(), EGameplayModOp::Additive, -MitigatedDamage));
|
OutExecutionOutput.AddOutputModifier(FGameplayModifierEvaluatedData(UCogSampleAttributeSet_Health::GetHealthAttribute(), EGameplayModOp::Additive, -MitigatedDamage));
|
||||||
|
|
||||||
FCogSampleDamageEventParams Params;
|
FCogSampleDamageEventParams Params;
|
||||||
Params.DamageDealer = SourceCharacter;
|
Params.DamageDealer = SourceActor;
|
||||||
Params.DamageReceiver = TargetCharacter;
|
Params.DamageReceiver = TargetActor;
|
||||||
Params.MitigatedDamage = MitigatedDamage;
|
Params.MitigatedDamage = MitigatedDamage;
|
||||||
Params.UnmitigatedDamage = UnmitigatedDamage;
|
Params.UnmitigatedDamage = UnmitigatedDamage;
|
||||||
|
|
||||||
TargetCharacter->HandleDamageReceived(Params);
|
if (ICogSampleDamageableInterface* DamageReceiver = Cast<ICogSampleDamageableInterface>(TargetActor))
|
||||||
|
|
||||||
if (SourceCharacter != nullptr)
|
|
||||||
{
|
{
|
||||||
SourceCharacter->HandleDamageDealt(Params);
|
DamageReceiver->HandleDamageReceived(Params);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ICogSampleDamageableInterface* DamageDealer = Cast<ICogSampleDamageableInterface>(SourceActor))
|
||||||
|
{
|
||||||
|
DamageDealer->HandleDamageDealt(Params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UCogSampleFunctionLibrary_Damage::ExecuteDamageGameplayCue(TargetAbilitySystem, HitResult, MitigatedDamage, EffectContext, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void UCogSampleFunctionLibrary_Damage::ExecuteDamageGameplayCue(
|
||||||
|
UCogSampleAbilitySystemComponent* TargetAbilitySystem,
|
||||||
|
const FHitResult& HitResult,
|
||||||
|
float Damage,
|
||||||
|
const FGameplayEffectContextHandle& EffectContext,
|
||||||
|
bool IsPredicted)
|
||||||
|
{
|
||||||
|
ensure(TargetAbilitySystem);
|
||||||
|
if (TargetAbilitySystem == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AActor* TargetActor = TargetAbilitySystem->GetAvatarActor();
|
||||||
|
if (TargetActor == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FCogSampleGameplayEffectContext* TypedContext = FCogSampleGameplayEffectContext::ExtractEffectContext(EffectContext);
|
||||||
|
ensure(TypedContext);
|
||||||
|
if (TypedContext == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypedContext->bGameplayCueIsPredicted = IsPredicted;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------------------------
|
||||||
|
// We check for >= 1 instead of >= 0 because we can use damage values between 0 and 1.
|
||||||
|
//-----------------------------------------------------------------------------------------------------
|
||||||
|
if (Damage > 0.0f)
|
||||||
|
{
|
||||||
|
FGameplayCueParameters GameplayCueParameters;
|
||||||
|
GameplayCueParameters.RawMagnitude = Damage;
|
||||||
|
GameplayCueParameters.EffectContext = EffectContext;
|
||||||
|
GameplayCueParameters.Instigator = TypedContext->GetInstigator();
|
||||||
|
GameplayCueParameters.EffectCauser = TypedContext->GetEffectCauser();
|
||||||
|
GameplayCueParameters.PhysicalMaterial = HitResult.PhysMaterial;
|
||||||
|
GameplayCueParameters.Location = HitResult.Location;
|
||||||
|
GameplayCueParameters.Normal = HitResult.ImpactNormal;
|
||||||
|
|
||||||
|
if (IsPredicted)
|
||||||
|
{
|
||||||
|
TargetAbilitySystem->ExecuteGameplayCueLocal(Tag_GameplayCue_DamageReceived, GameplayCueParameters);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TargetAbilitySystem->ExecuteGameplayCue(Tag_GameplayCue_DamageReceived, GameplayCueParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "GameplayEffectExecutionCalculation.h"
|
#include "GameplayEffectExecutionCalculation.h"
|
||||||
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
#include "CogSampleExecCalculation_Damage.generated.h"
|
#include "CogSampleExecCalculation_Damage.generated.h"
|
||||||
|
|
||||||
|
class UCogSampleAbilitySystemComponent;
|
||||||
|
struct FHitResult;
|
||||||
|
struct FGameplayEffectContextHandle;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class UCogSampleExecCalculation_Damage : public UGameplayEffectExecutionCalculation
|
class UCogSampleExecCalculation_Damage : public UGameplayEffectExecutionCalculation
|
||||||
{
|
{
|
||||||
@@ -14,3 +19,20 @@ public:
|
|||||||
|
|
||||||
virtual void Execute_Implementation(const FGameplayEffectCustomExecutionParameters& ExecutionParams, OUT FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const override;
|
virtual void Execute_Implementation(const FGameplayEffectCustomExecutionParameters& ExecutionParams, OUT FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UCLASS(meta = (ScriptName = "CogSampleFunctionLibrary_Damage"))
|
||||||
|
class COGSAMPLE_API UCogSampleFunctionLibrary_Damage : public UBlueprintFunctionLibrary
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
static void ExecuteDamageGameplayCue(
|
||||||
|
UCogSampleAbilitySystemComponent* TargetAbilitySystem,
|
||||||
|
const FHitResult& HitResult,
|
||||||
|
float HealthDamage,
|
||||||
|
const FGameplayEffectContextHandle& EffectContext,
|
||||||
|
bool IsPredicted);
|
||||||
|
|
||||||
|
};
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ UE_DEFINE_GAMEPLAY_TAG(Tag_Effect_Type_Heal_Full, "Effect.Type.Heal.Full");
|
|||||||
UE_DEFINE_GAMEPLAY_TAG(Tag_Effect_Type_Heal_Revive, "Effect.Type.Heal.Revive");
|
UE_DEFINE_GAMEPLAY_TAG(Tag_Effect_Type_Heal_Revive, "Effect.Type.Heal.Revive");
|
||||||
UE_DEFINE_GAMEPLAY_TAG(Tag_Effect_Type_Hidden, "Effect.Type.Hidden");
|
UE_DEFINE_GAMEPLAY_TAG(Tag_Effect_Type_Hidden, "Effect.Type.Hidden");
|
||||||
|
|
||||||
|
UE_DEFINE_GAMEPLAY_TAG(Tag_GameplayCue_DamageReceived, "GameplayCue.DamageReceived");
|
||||||
|
|
||||||
UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Dead, "Status.Dead");
|
UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Dead, "Status.Dead");
|
||||||
UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Ghost, "Status.Ghost");
|
UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Ghost, "Status.Ghost");
|
||||||
UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Immobilized, "Status.Immobilized");
|
UE_DEFINE_GAMEPLAY_TAG(Tag_Status_Immobilized, "Status.Immobilized");
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Effect_Type_Heal_Full);
|
|||||||
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Effect_Type_Heal_Revive);
|
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Effect_Type_Heal_Revive);
|
||||||
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Effect_Type_Hidden);
|
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Effect_Type_Hidden);
|
||||||
|
|
||||||
|
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_GameplayCue_DamageReceived);
|
||||||
|
|
||||||
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Dead);
|
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Dead);
|
||||||
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Ghost);
|
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Ghost);
|
||||||
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Immobilized);
|
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag_Status_Immobilized);
|
||||||
|
|||||||
@@ -249,4 +249,15 @@ void UCogSampleEffectContextLibrary::EffectContextGetAllFloatValues(FGameplayEff
|
|||||||
{
|
{
|
||||||
Entries = TypedEffectContext->FloatValues;
|
Entries = TypedEffectContext->FloatValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool UCogSampleEffectContextLibrary::EffectContextGetGameplayCueIsPredicted(FGameplayEffectContextHandle EffectContext)
|
||||||
|
{
|
||||||
|
if (FCogSampleGameplayEffectContext* TypedEffectContext = FCogSampleGameplayEffectContext::ExtractEffectContext(EffectContext))
|
||||||
|
{
|
||||||
|
return TypedEffectContext->bGameplayCueIsPredicted;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ public:
|
|||||||
|
|
||||||
bool CanGameplayCueBePredicted();
|
bool CanGameplayCueBePredicted();
|
||||||
|
|
||||||
|
/* NOT REPLICATED - Is this effect context made for a local gameplay cue. Used to know if a remote gameplay cue
|
||||||
|
* created by the local player should be filtered when a local gameplay cue is played instead.
|
||||||
|
*/
|
||||||
|
bool bGameplayCueIsPredicted = false;
|
||||||
|
|
||||||
/* REPLICATED */
|
/* REPLICATED */
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TArray<FCogSampleGameplayEffectContextFloatValue> FloatValues;
|
TArray<FCogSampleGameplayEffectContextFloatValue> FloatValues;
|
||||||
@@ -91,6 +96,9 @@ class UCogSampleEffectContextLibrary : public UBlueprintFunctionLibrary
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure)
|
||||||
|
static bool EffectContextGetGameplayCueIsPredicted(FGameplayEffectContextHandle EffectContext);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
static void EffectContextSetFloatValue(FGameplayEffectContextHandle EffectContext, FName Name, float Value);
|
static void EffectContextSetFloatValue(FGameplayEffectContextHandle EffectContext, FName Name, float Value);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user