Construct Ability System Component and Attribute Set

This commit is contained in:
2024-11-18 20:20:40 -04:00
parent 0b02776458
commit 97fded2abb
11 changed files with 100 additions and 5 deletions

View File

@ -8,9 +8,9 @@ public class Aura : ModuleRules
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "GameplayAbilities" });
PrivateDependencyModuleNames.AddRange(new string[] { });
PrivateDependencyModuleNames.AddRange(new string[] { "GameplayTags", "GameplayTasks" });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

View File

@ -0,0 +1,4 @@
// Assets provided by DruidMechanics. Copyright Jonathan Rampersad 2024
#include "AbilitySystem/AuraAbilitySystemComponent.h"

View File

@ -0,0 +1,4 @@
// Assets provided by DruidMechanics. Copyright Jonathan Rampersad 2024
#include "AbilitySystem/AuraAttributeSet.h"

View File

@ -14,6 +14,11 @@ AAuraCharacterBase::AAuraCharacterBase()
}
UAbilitySystemComponent* AAuraCharacterBase::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}
// Called when the game starts or when spawned
void AAuraCharacterBase::BeginPlay()
{

View File

@ -2,6 +2,9 @@
#include "Character/AuraEnemy.h"
#include "AbilitySystem/AuraAbilitySystemComponent.h"
#include "AbilitySystem/AuraAttributeSet.h"
#include "Aura/Aura.h"
AAuraEnemy::AAuraEnemy()
@ -13,6 +16,11 @@ AAuraEnemy::AAuraEnemy()
Weapon->SetRenderCustomDepth(false);
Weapon->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED);
AbilitySystemComponent = CreateDefaultSubobject<UAuraAbilitySystemComponent>("AbilitySystemComponent");
AbilitySystemComponent->SetIsReplicated(true);
AttributeSet = CreateDefaultSubobject<UAuraAttributeSet>("AttributeSet");
}
void AAuraEnemy::HighlightActor()

View File

@ -3,7 +3,21 @@
#include "Player/AuraPlayerState.h"
#include "AbilitySystem/AuraAbilitySystemComponent.h"
#include "AbilitySystem/AuraAttributeSet.h"
AAuraPlayerState::AAuraPlayerState()
{
AbilitySystemComponent = CreateDefaultSubobject<UAuraAbilitySystemComponent>("AbilitySystemComponent");
AbilitySystemComponent->SetIsReplicated(true);
AttributeSet = CreateDefaultSubobject<UAuraAttributeSet>("AttributeSet");
NetUpdateFrequency = 100.f;
}
UAbilitySystemComponent* AAuraPlayerState::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}

View File

@ -0,0 +1,16 @@
// Assets provided by DruidMechanics. Copyright Jonathan Rampersad 2024
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "AuraAbilitySystemComponent.generated.h"
/**
*
*/
UCLASS()
class AURA_API UAuraAbilitySystemComponent : public UAbilitySystemComponent
{
GENERATED_BODY()
};

View File

@ -0,0 +1,16 @@
// Assets provided by DruidMechanics. Copyright Jonathan Rampersad 2024
#pragma once
#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "AuraAttributeSet.generated.h"
/**
*
*/
UCLASS()
class AURA_API UAuraAttributeSet : public UAttributeSet
{
GENERATED_BODY()
};

View File

@ -3,11 +3,15 @@
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemInterface.h"
#include "GameFramework/Character.h"
#include "AuraCharacterBase.generated.h"
class UAbilitySystemComponent;
class UAttributeSet;
UCLASS(Abstract)
class AURA_API AAuraCharacterBase : public ACharacter
class AURA_API AAuraCharacterBase : public ACharacter, public IAbilitySystemInterface
{
GENERATED_BODY()
@ -15,6 +19,8 @@ public:
// Sets default values for this character's properties
AAuraCharacterBase();
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
UAttributeSet* GetAttributeSet() const { return AttributeSet; }
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
@ -22,4 +28,9 @@ protected:
UPROPERTY(EditAnywhere, Category="Combat")
TObjectPtr<USkeletalMeshComponent> Weapon;
UPROPERTY()
TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;
UPROPERTY()
TObjectPtr<UAttributeSet> AttributeSet;
};

View File

@ -3,17 +3,29 @@
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemInterface.h"
#include "GameFramework/PlayerState.h"
#include "AuraPlayerState.generated.h"
class UAbilitySystemComponent;
class UAttributeSet;
/**
*
*/
UCLASS()
class AURA_API AAuraPlayerState : public APlayerState
class AURA_API AAuraPlayerState : public APlayerState, public IAbilitySystemInterface
{
GENERATED_BODY()
public:
AAuraPlayerState();
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
UAttributeSet* GetAttributeSet() const { return AttributeSet; }
protected:
UPROPERTY()
TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;
UPROPERTY()
TObjectPtr<UAttributeSet> AttributeSet;
};