20. Constructing the ASC and AS

This commit is contained in:
Edward R. Gonzalez 2024-04-13 11:09:22 -04:00
parent 70d51d869c
commit f43daaed61
10 changed files with 99 additions and 2 deletions

Binary file not shown.

View File

@ -0,0 +1,4 @@
#pragma once
#include "GasaCommon.h"

View File

@ -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<UAbilitySystemInterface>())
{
return Cast<UGasaAbilitySystemComp>( Cast<IAbilitySystemInterface>(Object)->GetAbilitySystemComponent() );
}
return nullptr;
}
}

View File

@ -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<USkeletalMeshComponent>("Weapon");
Weapon->SetupAttachment(mesh, FName("WeaponAttach"));
Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision);
if (bAutoAbilitySystem)
{
AbilitySystem = CreateDefaultSubobject<UGasaAbilitySystemComp>("Ability System");
AbilitySystem->SetIsReplicated(true);
Attributes = CreateDefaultSubobject<UAttributeSet>("Attributes");
}
}
void AGasaCharacter::BeginPlay()

View File

@ -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<UAbilitySystemComponent> AbilitySystem;
UPROPERTY(EditAnywhere, Category="Ability System")
TObjectPtr<UAttributeSet> Attributes;
#pragma endregion Ability System
#pragma region Combat
UPROPERTY(EditAnywhere, Category="Combat")
TObjectPtr<USkeletalMeshComponent> Weapon;
@ -43,9 +57,22 @@ public:
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;
void Tick(float DeltaSeconds) override;
#pragma endregion Actor
};
namespace Gasa
{
// UGasaAbilitySystemComp* GetAbilitySystem(AGasaCharacter* Object)
// {
//
// }
}

View File

@ -3,4 +3,6 @@
APlayerCharacter::APlayerCharacter()
{
PrimaryActorTick.bCanEverTick = true;
bAutoAbilitySystem = false;
}

View File

@ -1,7 +1,14 @@
#include "GasaPlayerState.h"
#include "AbilitySystem/GasaAbilitySystemComponent.h"
AGasaPlayerState::AGasaPlayerState()
{
AbilitySystem = CreateDefaultSubobject<UGasaAbilitySystemComp>("Ability System");
AbilitySystem->SetIsReplicated(true);
Attributes = CreateDefaultSubobject<UAttributeSet>("Attributes");
// Replication
NetUpdateFrequency = 100.f;
}

View File

@ -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<UAbilitySystemComponent> AbilitySystem;
UPROPERTY(EditAnywhere, Category="Ability System")
TObjectPtr<UAttributeSet> Attributes;
#pragma endregion Ability System
AGasaPlayerState();
#pragma region IAbilitySystem
FORCEINLINE UAttributeSet* GetAttributes() { return Attributes; }
FORCEINLINE UAbilitySystemComponent* GetAbilitySystemComponent() const override { return AbilitySystem; }
#pragma endregion IAbilitySystem
};

View File

@ -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