diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.dll b/Project/Binaries/Win64/UnrealEditor-Gasa.dll index 73bbc9d..ebec324 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-Gasa.dll and b/Project/Binaries/Win64/UnrealEditor-Gasa.dll differ diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb index 96157e8..34c626e 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb and b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb differ diff --git a/Project/Source/Gasa/AbilitySystem/GasaAbilitySystem.h b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystem.h index 27b40cd..f16bcd4 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAbilitySystem.h +++ b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystem.h @@ -2,3 +2,4 @@ #include "GasaCommon.h" + diff --git a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h index 7c8ad02..e6460e7 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h +++ b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h @@ -147,3 +147,12 @@ public: void GetLifetimeReplicatedProps( TArray< FLifetimeProperty >& OutLifetimeProps ) const override; #pragma endregion UObject }; + +namespace Gasa +{ + inline UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC ) + { + return Cast< UGasaAttributeSet >( ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ) ); + } + +} diff --git a/Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp b/Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp new file mode 100644 index 0000000..589f617 --- /dev/null +++ b/Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp @@ -0,0 +1,61 @@ +#include "GasaEffectActor.h" + +#include "AbilitySystemComponent.h" +#include "AbilitySystemInterface.h" +#include "GasaAttributeSet.h" +#include "Components/SphereComponent.h" + + +AGasaEffectActor::AGasaEffectActor() +{ + PrimaryActorTick.bCanEverTick = false; + + Mesh = CreateDefaultSubobject("Mesh"); + Sphere = CreateDefaultSubobject("Sphere"); + + SetRootComponent(Mesh); + Sphere->SetupAttachment(Mesh); +} + +void AGasaEffectActor::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent + , AActor* OtherActor + , UPrimitiveComponent* OtherComp + , int32 OtherBodyIndex + , bool bFromSweep + , FHitResult const& SweepResult) +{ + // Demo of "restricted way" + if ( ! OtherActor->Implements()) + return; + + IAbilitySystemInterface* ASI = Cast(OtherActor); + if (ASI == nullptr) + return; + + // TODO(Ed): Change this to use a gameplay effect instead + UAbilitySystemComponent* AbilitySystem = ASI->GetAbilitySystemComponent(); + UGasaAttributeSet* MutAttributes = const_cast(Gasa::GetAttributeSet(AbilitySystem)); + + MutAttributes->SetHealth( MutAttributes->GetHealth() + 25.f ); + Destroy(); +} + +void AGasaEffectActor::OnOverlapEnd(UPrimitiveComponent* OverlappedComponent + , AActor* OtherActor + , UPrimitiveComponent* OtherComp + , int32 OtherBodyIndex) +{ +} + +void AGasaEffectActor::BeginPlay() +{ + Super::BeginPlay(); +} + +void AGasaEffectActor::PostInitializeComponents() +{ + Super::PostInitializeComponents(); + + Sphere->OnComponentBeginOverlap.AddUniqueDynamic(this, &ThisClass::OnOverlapBegin); + Sphere->OnComponentEndOverlap.AddUniqueDynamic(this, &ThisClass::OnOverlapEnd); +} diff --git a/Project/Source/Gasa/AbilitySystem/GasaEffectActor.h b/Project/Source/Gasa/AbilitySystem/GasaEffectActor.h new file mode 100644 index 0000000..5650bdf --- /dev/null +++ b/Project/Source/Gasa/AbilitySystem/GasaEffectActor.h @@ -0,0 +1,39 @@ +#pragma once + +#include "GasaCommon.h" + +#include "GasaEffectActor.generated.h" + +UCLASS() +class GASA_API AGasaEffectActor : public AActor +{ + GENERATED_BODY() +public: + + UPROPERTY(VisibleAnywhere) + TObjectPtr Mesh; + UPROPERTY(VisibleAnywhere) + TObjectPtr Sphere; + + AGasaEffectActor(); + + UFUNCTION() + void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent + , AActor* OtherActor + , UPrimitiveComponent* OtherComp + , int32 OtherBodyIndex + , bool bFromSweep + , FHitResult const& SweepResult); + + UFUNCTION() + void OnOverlapEnd(UPrimitiveComponent* OverlappedComponent + , AActor* OtherActor + , UPrimitiveComponent* OtherComp + , int32 OtherBodyIndex); + +#pragma region Actor + void BeginPlay() override; + + void PostInitializeComponents() override; +#pragma endregion Actor +}; \ No newline at end of file diff --git a/Project/Source/Gasa/GasaCommon.h b/Project/Source/Gasa/GasaCommon.h index 1a93f75..03bdf69 100644 --- a/Project/Source/Gasa/GasaCommon.h +++ b/Project/Source/Gasa/GasaCommon.h @@ -23,6 +23,7 @@ class UAttributeSet; class UCameraComponent; class UInputAction; class UInputMappingContext; +class USphereComponent; class USpringArmComponent; #pragma endregion Engine Forwards @@ -41,6 +42,7 @@ class AGasaLevelScriptActor; class AGasaPlayerController; class UGasaAbilitySystemComp; +class UGasaAttributeSet; class UGasaDevOptions; #pragma endregion Forwards diff --git a/Project/Source/GasaGen/GasaGen.cpp b/Project/Source/GasaGen/GasaGen.cpp index 1af3241..8ebda2a 100644 --- a/Project/Source/GasaGen/GasaGen.cpp +++ b/Project/Source/GasaGen/GasaGen.cpp @@ -208,12 +208,24 @@ int gen_main() ); } + CodeNS ns_gasa = parse_namespace( code( + namespace Gasa + { + inline + UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC ) + { + return Cast(ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() )); + } + } + )); + header.print( Include_AttributeSet); header.print( Include_AbilitySystemComponent); header.print( Include_GasaAttributeSet_Generated); header.print( fmt_newline); header.print(umeta_uclass); header.print(GasaAttributeSet); + header.print(ns_gasa); } header.write(); }