diff --git a/Content/Blueprints/Actor/Pickups/HealthPotion/BP_HealthPotion.uasset b/Content/Blueprints/Actor/Pickups/HealthPotion/BP_HealthPotion.uasset new file mode 100644 index 0000000..97dcc10 Binary files /dev/null and b/Content/Blueprints/Actor/Pickups/HealthPotion/BP_HealthPotion.uasset differ diff --git a/Content/Maps/StartupMap.umap b/Content/Maps/StartupMap.umap index 2775e3c..a4b52cb 100644 Binary files a/Content/Maps/StartupMap.umap and b/Content/Maps/StartupMap.umap differ diff --git a/Source/Aura/Private/Actor/AuraEffectActor.cpp b/Source/Aura/Private/Actor/AuraEffectActor.cpp new file mode 100644 index 0000000..f181360 --- /dev/null +++ b/Source/Aura/Private/Actor/AuraEffectActor.cpp @@ -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("Mesh"); + SetRootComponent(Mesh); + + Sphere = CreateDefaultSubobject("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(OtherActor)) + { + const UAuraAttributeSet* AuraAttributeSet = Cast(ASCInterface->GetAbilitySystemComponent()->GetAttributeSet(UAuraAttributeSet::StaticClass())); + UAuraAttributeSet* MutableAuraAttributeSet = const_cast(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); +} diff --git a/Source/Aura/Public/Actor/AuraEffectActor.h b/Source/Aura/Public/Actor/AuraEffectActor.h new file mode 100644 index 0000000..5677114 --- /dev/null +++ b/Source/Aura/Public/Actor/AuraEffectActor.h @@ -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 Mesh; + + UPROPERTY(VisibleAnywhere) + TObjectPtr Sphere; +};