Effect Actor
This commit is contained in:
parent
1e629cdc1c
commit
794db4920a
Binary file not shown.
Binary file not shown.
45
Source/Aura/Private/Actor/AuraEffectActor.cpp
Normal file
45
Source/Aura/Private/Actor/AuraEffectActor.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright; GhostPacket Games
|
||||||
|
|
||||||
|
#include "Actor/AuraEffectActor.h"
|
||||||
|
|
||||||
|
#include "AbilitySystemComponent.h"
|
||||||
|
#include "AbilitySystemInterface.h"
|
||||||
|
#include "AbilitySystem/AuraAttributeSet.h"
|
||||||
|
#include "Components/SphereComponent.h"
|
||||||
|
|
||||||
|
AAuraEffectActor::AAuraEffectActor()
|
||||||
|
{
|
||||||
|
PrimaryActorTick.bCanEverTick = false;
|
||||||
|
|
||||||
|
Mesh = CreateDefaultSubobject<UStaticMeshComponent>("Mesh");
|
||||||
|
SetRootComponent(Mesh);
|
||||||
|
|
||||||
|
Sphere = CreateDefaultSubobject<USphereComponent>("Sphere");
|
||||||
|
Sphere->SetupAttachment(GetRootComponent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AAuraEffectActor::OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
|
{
|
||||||
|
// TODO: Change this to apply a Gameplay Effect. For now, using const_cast as a hack!
|
||||||
|
if (IAbilitySystemInterface* ASCInterface = Cast<IAbilitySystemInterface>(OtherActor))
|
||||||
|
{
|
||||||
|
const UAuraAttributeSet* AuraAttributeSet = Cast<UAuraAttributeSet>(ASCInterface->GetAbilitySystemComponent()->GetAttributeSet(UAuraAttributeSet::StaticClass()));
|
||||||
|
UAuraAttributeSet* MutableAuraAttributeSet = const_cast<UAuraAttributeSet*>(AuraAttributeSet);
|
||||||
|
MutableAuraAttributeSet->SetHealth (AuraAttributeSet->GetHealth() + 25.f);
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AAuraEffectActor::EndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void AAuraEffectActor::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
Sphere->OnComponentBeginOverlap.AddDynamic(this, &AAuraEffectActor::OnOverlap);
|
||||||
|
Sphere->OnComponentEndOverlap.AddDynamic(this, &AAuraEffectActor::EndOverlap);
|
||||||
|
}
|
35
Source/Aura/Public/Actor/AuraEffectActor.h
Normal file
35
Source/Aura/Public/Actor/AuraEffectActor.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright; GhostPacket Games
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "AuraEffectActor.generated.h"
|
||||||
|
|
||||||
|
class USphereComponent;
|
||||||
|
class UPrimitiveComponent;
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class AURA_API AAuraEffectActor : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
AAuraEffectActor();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
virtual void OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
virtual void EndOverlap(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UPROPERTY(VisibleAnywhere)
|
||||||
|
TObjectPtr<UStaticMeshComponent> Mesh;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere)
|
||||||
|
TObjectPtr<USphereComponent> Sphere;
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user