diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.dll b/Project/Binaries/Win64/UnrealEditor-Gasa.dll index df66050..a0926e6 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 new file mode 100644 index 0000000..b319266 Binary files /dev/null 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 new file mode 100644 index 0000000..27b40cd --- /dev/null +++ b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystem.h @@ -0,0 +1,4 @@ +#pragma once + +#include "GasaCommon.h" + diff --git a/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent.h b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent.h index b2d5482..bca2a46 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent.h +++ b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent.h @@ -1,12 +1,29 @@ #pragma once #include "AbilitySystemComponent.h" +#include "AbilitySystemInterface.h" + +#include "GasaCommon.h" #include "GasaAbilitySystemComponent.generated.h" + UCLASS() class GASA_API UGasaAbilitySystemComp : public UAbilitySystemComponent { GENERATED_BODY() public: }; + +namespace Gasa +{ + inline + UGasaAbilitySystemComp* GetAbilitySystem(UObject* Object) + { + if (Object->Implements()) + { + return Cast( Cast(Object)->GetAbilitySystemComponent() ); + } + return nullptr; + } +} diff --git a/Project/Source/Gasa/Characters/GasaCharacter.cpp b/Project/Source/Gasa/Characters/GasaCharacter.cpp index b97078d..8cd2c98 100644 --- a/Project/Source/Gasa/Characters/GasaCharacter.cpp +++ b/Project/Source/Gasa/Characters/GasaCharacter.cpp @@ -1,12 +1,15 @@ #include "GasaCharacter.h" -#include "Game/GasaLevelScriptActor.h" +#include "AbilitySystemComponent.h" #include "Camera/CameraComponent.h" #include "Components/CapsuleComponent.h" #include "GameFramework/CharacterMovementComponent.h" #include "GameFramework/SpringArmComponent.h" #include "Kismet/KismetSystemLibrary.h" +#include "AbilitySystem/GasaAbilitySystemComponent.h" +#include "Game/GasaLevelScriptActor.h" + void AGasaCharacter::SetHighlight(EHighlight Desired) { HighlightState = Desired; @@ -35,6 +38,14 @@ AGasaCharacter::AGasaCharacter() Weapon = CreateDefaultSubobject("Weapon"); Weapon->SetupAttachment(mesh, FName("WeaponAttach")); Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision); + + if (bAutoAbilitySystem) + { + AbilitySystem = CreateDefaultSubobject("Ability System"); + AbilitySystem->SetIsReplicated(true); + + Attributes = CreateDefaultSubobject("Attributes"); + } } void AGasaCharacter::BeginPlay() diff --git a/Project/Source/Gasa/Characters/GasaCharacter.h b/Project/Source/Gasa/Characters/GasaCharacter.h index 2ba125f..7e8a345 100644 --- a/Project/Source/Gasa/Characters/GasaCharacter.h +++ b/Project/Source/Gasa/Characters/GasaCharacter.h @@ -1,8 +1,10 @@ #pragma once -#include "GasaCommon.h" +#include "AbilitySystemInterface.h" #include "GameFramework/Character.h" +#include "GasaCommon.h" + #include "GasaCharacter.generated.h" UENUM(BlueprintType) @@ -14,9 +16,21 @@ enum class EHighlight : uint8 UCLASS(Abstract) class GASA_API AGasaCharacter : public ACharacter + , public IAbilitySystemInterface { GENERATED_BODY() public: +#pragma region Ability System + UPROPERTY(EditAnywhere, Category="Ability System") + bool bAutoAbilitySystem = true; + + UPROPERTY(EditAnywhere, Category="Ability System") + TObjectPtr AbilitySystem; + + UPROPERTY(EditAnywhere, Category="Ability System") + TObjectPtr Attributes; +#pragma endregion Ability System + #pragma region Combat UPROPERTY(EditAnywhere, Category="Combat") TObjectPtr Weapon; @@ -42,6 +56,11 @@ public: #pragma endregion Highlighting AGasaCharacter(); + +#pragma region IAbilitySystem + FORCEINLINE UAttributeSet* GetAttributes() { return Attributes; } + FORCEINLINE UAbilitySystemComponent* GetAbilitySystemComponent() const override { return AbilitySystem; } +#pragma endregion IAbilitySystem #pragma region Actor void BeginPlay() override; @@ -49,3 +68,11 @@ public: void Tick(float DeltaSeconds) override; #pragma endregion Actor }; + +namespace Gasa +{ + // UGasaAbilitySystemComp* GetAbilitySystem(AGasaCharacter* Object) + // { + // + // } +} diff --git a/Project/Source/Gasa/Characters/PlayerCharacter.cpp b/Project/Source/Gasa/Characters/PlayerCharacter.cpp index dd0c3bb..afe9dbe 100644 --- a/Project/Source/Gasa/Characters/PlayerCharacter.cpp +++ b/Project/Source/Gasa/Characters/PlayerCharacter.cpp @@ -3,4 +3,6 @@ APlayerCharacter::APlayerCharacter() { PrimaryActorTick.bCanEverTick = true; + + bAutoAbilitySystem = false; } diff --git a/Project/Source/Gasa/Game/GasaPlayerState.cpp b/Project/Source/Gasa/Game/GasaPlayerState.cpp index 336c4d4..d131754 100644 --- a/Project/Source/Gasa/Game/GasaPlayerState.cpp +++ b/Project/Source/Gasa/Game/GasaPlayerState.cpp @@ -1,7 +1,14 @@ #include "GasaPlayerState.h" +#include "AbilitySystem/GasaAbilitySystemComponent.h" + AGasaPlayerState::AGasaPlayerState() { + AbilitySystem = CreateDefaultSubobject("Ability System"); + AbilitySystem->SetIsReplicated(true); + + Attributes = CreateDefaultSubobject("Attributes"); + // Replication NetUpdateFrequency = 100.f; } diff --git a/Project/Source/Gasa/Game/GasaPlayerState.h b/Project/Source/Gasa/Game/GasaPlayerState.h index c08c66e..a6553de 100644 --- a/Project/Source/Gasa/Game/GasaPlayerState.h +++ b/Project/Source/Gasa/Game/GasaPlayerState.h @@ -1,13 +1,34 @@ #pragma once + +#include "AbilitySystemInterface.h" #include "GameFramework/PlayerState.h" +#include "GasaCommon.h" + #include "GasaPlayerState.generated.h" UCLASS(Blueprintable) class GASA_API AGasaPlayerState : public APlayerState + , public IAbilitySystemInterface { GENERATED_BODY() public: +#pragma region Ability System + UPROPERTY(EditAnywhere, Category="Ability System") + bool bAutoAbilitySystem = true; + + UPROPERTY(EditAnywhere, Category="Ability System") + TObjectPtr AbilitySystem; + + UPROPERTY(EditAnywhere, Category="Ability System") + TObjectPtr Attributes; +#pragma endregion Ability System + AGasaPlayerState(); + +#pragma region IAbilitySystem + FORCEINLINE UAttributeSet* GetAttributes() { return Attributes; } + FORCEINLINE UAbilitySystemComponent* GetAbilitySystemComponent() const override { return AbilitySystem; } +#pragma endregion IAbilitySystem }; diff --git a/Project/Source/Gasa/GasaCommon.h b/Project/Source/Gasa/GasaCommon.h index 4662c44..9433325 100644 --- a/Project/Source/Gasa/GasaCommon.h +++ b/Project/Source/Gasa/GasaCommon.h @@ -11,6 +11,11 @@ #pragma region Engine Forwards struct FInputActionValue; +class IAbilitySystemInterface; + +class UAbilitySystemComponent; +class UAbilitySystemInterface; +class UAttributeSet; class UCameraComponent; class UInputAction; class UInputMappingContext; @@ -31,9 +36,11 @@ class AGasaGameState; class AGasaLevelScriptActor; class AGasaPlayerController; +class UGasaAbilitySystemComp; class UGasaDevOptions; #pragma endregion Forwards +#pragma region Logging // Straight from the Engine UENUM(BlueprintType) enum class EGasaVerbosity : uint8 @@ -122,3 +129,4 @@ namespace Gasa #define GASA_Log(Message) UE_LOG( Gasa, Log, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() ); #define GASA_Verbose(Message) UE_LOG( Gasa, Verbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() ); #define GASA_VeryVerbose(Message) UE_LOG( Gasa, VeryVerbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() ); +#pragma endregion Logging