26. Effect Actor complete
This commit is contained in:
parent
c2e5793a7d
commit
7b9e277bc1
Binary file not shown.
Binary file not shown.
BIN
Project/Content/Core/Pickups/BP_HealthPotion.uasset
(Stored with Git LFS)
Normal file
BIN
Project/Content/Core/Pickups/BP_HealthPotion.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Project/Content/Levels/StartupMap.umap
(Stored with Git LFS)
BIN
Project/Content/Levels/StartupMap.umap
(Stored with Git LFS)
Binary file not shown.
@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
#include "GasaCommon.h"
|
#include "GasaCommon.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,3 +147,12 @@ public:
|
|||||||
void GetLifetimeReplicatedProps( TArray< FLifetimeProperty >& OutLifetimeProps ) const override;
|
void GetLifetimeReplicatedProps( TArray< FLifetimeProperty >& OutLifetimeProps ) const override;
|
||||||
#pragma endregion UObject
|
#pragma endregion UObject
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace Gasa
|
||||||
|
{
|
||||||
|
inline UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC )
|
||||||
|
{
|
||||||
|
return Cast< UGasaAttributeSet >( ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
61
Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp
Normal file
61
Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp
Normal file
@ -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<UStaticMeshComponent>("Mesh");
|
||||||
|
Sphere = CreateDefaultSubobject<USphereComponent>("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<UAbilitySystemInterface>())
|
||||||
|
return;
|
||||||
|
|
||||||
|
IAbilitySystemInterface* ASI = Cast<IAbilitySystemInterface>(OtherActor);
|
||||||
|
if (ASI == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// TODO(Ed): Change this to use a gameplay effect instead
|
||||||
|
UAbilitySystemComponent* AbilitySystem = ASI->GetAbilitySystemComponent();
|
||||||
|
UGasaAttributeSet* MutAttributes = const_cast<UGasaAttributeSet*>(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);
|
||||||
|
}
|
39
Project/Source/Gasa/AbilitySystem/GasaEffectActor.h
Normal file
39
Project/Source/Gasa/AbilitySystem/GasaEffectActor.h
Normal file
@ -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<UStaticMeshComponent> Mesh;
|
||||||
|
UPROPERTY(VisibleAnywhere)
|
||||||
|
TObjectPtr<USphereComponent> 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
|
||||||
|
};
|
@ -23,6 +23,7 @@ class UAttributeSet;
|
|||||||
class UCameraComponent;
|
class UCameraComponent;
|
||||||
class UInputAction;
|
class UInputAction;
|
||||||
class UInputMappingContext;
|
class UInputMappingContext;
|
||||||
|
class USphereComponent;
|
||||||
class USpringArmComponent;
|
class USpringArmComponent;
|
||||||
#pragma endregion Engine Forwards
|
#pragma endregion Engine Forwards
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ class AGasaLevelScriptActor;
|
|||||||
class AGasaPlayerController;
|
class AGasaPlayerController;
|
||||||
|
|
||||||
class UGasaAbilitySystemComp;
|
class UGasaAbilitySystemComp;
|
||||||
|
class UGasaAttributeSet;
|
||||||
class UGasaDevOptions;
|
class UGasaDevOptions;
|
||||||
#pragma endregion Forwards
|
#pragma endregion Forwards
|
||||||
|
|
||||||
|
@ -208,12 +208,24 @@ int gen_main()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CodeNS ns_gasa = parse_namespace( code(
|
||||||
|
namespace Gasa
|
||||||
|
{
|
||||||
|
inline
|
||||||
|
UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC )
|
||||||
|
{
|
||||||
|
return Cast<UGasaAttributeSet>(ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
header.print( Include_AttributeSet);
|
header.print( Include_AttributeSet);
|
||||||
header.print( Include_AbilitySystemComponent);
|
header.print( Include_AbilitySystemComponent);
|
||||||
header.print( Include_GasaAttributeSet_Generated);
|
header.print( Include_GasaAttributeSet_Generated);
|
||||||
header.print( fmt_newline);
|
header.print( fmt_newline);
|
||||||
header.print(umeta_uclass);
|
header.print(umeta_uclass);
|
||||||
header.print(GasaAttributeSet);
|
header.print(GasaAttributeSet);
|
||||||
|
header.print(ns_gasa);
|
||||||
}
|
}
|
||||||
header.write();
|
header.write();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user