73. Player Level and Combat Interface

This commit is contained in:
Edward R. Gonzalez 2024-10-22 17:32:37 -04:00
parent d34201e8a1
commit 7e27f708cf
9 changed files with 75 additions and 3 deletions

View File

@ -6,4 +6,13 @@ AEnemyCharacter::AEnemyCharacter()
PrimaryActorTick.bCanEverTick = true;
bAutoAbilitySystem = true;
PlayerLevel = 1;
}
#pragma region ICombat
int32 AEnemyCharacter::GetPlayerLevel()
{
return PlayerLevel;
}
#pragma endregion ICombat

View File

@ -10,4 +10,11 @@ class GASA_API AEnemyCharacter : public AGasaCharacter
GENERATED_BODY()
public:
AEnemyCharacter();
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Gameplay")
int32 PlayerLevel;
#pragma region ICombat
int32 GetPlayerLevel() override;
#pragma endregion ICombat
};

View File

@ -5,6 +5,7 @@
#include "GasaCommon.h"
#include "Game/GasaGameState.h"
#include "Interfaces/CombatInterface.h"
#include "Networking/GasaNetLibrary.h"
#include "GasaCharacter.generated.h"
@ -19,6 +20,7 @@ enum class EHighlight : uint8
UCLASS(Abstract)
class GASA_API AGasaCharacter : public ACharacter
, public IAbilitySystemInterface
, public ICombat
{
GENERATED_BODY()
public:

View File

@ -1,4 +1,4 @@
#include "PlayerCharacter.h"
#include "PlayerCharacter.h"
#include "Networking/GasaNetLibrary_Inlines.h"
#include "AbilitySystemComponent.h"
@ -13,6 +13,14 @@ APlayerCharacter::APlayerCharacter()
bAutoAbilitySystem = false;
}
#pragma region ICombat
int32 APlayerCharacter::GetLevel()
{
return GetPlayerState<AGasaPlayerState>()->Level;
}
#pragma endregion ICombat
#pragma region Pawn
void APlayerCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
@ -22,3 +30,4 @@ void APlayerCharacter::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
}
#pragma endregion Pawn

View File

@ -12,6 +12,10 @@ public:
APlayerCharacter();
#pragma region ICombat
int32 GetLevel() override;
#pragma endregion ICombat
#pragma region Pawn
void PossessedBy(AController* NewController) override;

View File

@ -1,5 +1,7 @@
#include "GasaPlayerState.h"
#include "Net/UnrealNetwork.h"
#include "Networking/GasaNetLibrary_Inlines.h"
#include "GasaGameInstance.h"
#include "GasaPlayerController.h"
@ -10,6 +12,8 @@ AGasaPlayerState::AGasaPlayerState()
{
bAutoAbilitySystem = true;
Level = 1;
AbilitySystem = CreateDefaultSubobject<UGasaAbilitySystemComp>("Ability System");
AbilitySystem->SetIsReplicated(true);
AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);
@ -20,6 +24,11 @@ AGasaPlayerState::AGasaPlayerState()
NetUpdateFrequency = 100.f;
}
void AGasaPlayerState::Client_OnRep_Level(int32 OldPlayerLevel)
{
}
#pragma region GameFramework
void AGasaPlayerState::OnGameFrameworkInitialized()
{
@ -87,6 +96,6 @@ void AGasaPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Out
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AGasaPlayerState, Level);
}
#pragma endregion UObject

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "AbilitySystemInterface.h"
@ -17,6 +17,12 @@ class GASA_API AGasaPlayerState : public APlayerState
public:
AGasaPlayerState();
UPROPERTY(EditAnywhere, ReplicatedUsing="Client_OnRep_Level", Category="Gameplay")
int32 PlayerLevel;
UFUNCTION()
void Client_OnRep_Level(int32 OldLevel);
#pragma region Ability System
UPROPERTY(EditAnywhere, Category="Ability System")
bool bAutoAbilitySystem;

View File

@ -0,0 +1,6 @@
#include "CombatInterface.h"
int32 ICombat::GetPlayerLevel()
{
return 0;
}

View File

@ -0,0 +1,20 @@
#pragma once
#include "UObject/Interface.h"
#include "CombatInterface.generated.h"
UINTERFACE(MinimalAPI)
class UCombat : public UInterface
{
GENERATED_BODY()
};
class GASA_API ICombat
{
GENERATED_BODY()
public:
virtual int32 GetPlayerLevel();
};