diff --git a/Project/Source/Gasa/Characters/EnemyCharacter.cpp b/Project/Source/Gasa/Characters/EnemyCharacter.cpp index a50b33d..a51598c 100644 --- a/Project/Source/Gasa/Characters/EnemyCharacter.cpp +++ b/Project/Source/Gasa/Characters/EnemyCharacter.cpp @@ -6,4 +6,13 @@ AEnemyCharacter::AEnemyCharacter() PrimaryActorTick.bCanEverTick = true; bAutoAbilitySystem = true; + + PlayerLevel = 1; } + +#pragma region ICombat +int32 AEnemyCharacter::GetPlayerLevel() +{ + return PlayerLevel; +} +#pragma endregion ICombat diff --git a/Project/Source/Gasa/Characters/EnemyCharacter.h b/Project/Source/Gasa/Characters/EnemyCharacter.h index ee449f8..be9b754 100644 --- a/Project/Source/Gasa/Characters/EnemyCharacter.h +++ b/Project/Source/Gasa/Characters/EnemyCharacter.h @@ -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 }; diff --git a/Project/Source/Gasa/Characters/GasaCharacter.h b/Project/Source/Gasa/Characters/GasaCharacter.h index 5a1e74e..c032b93 100644 --- a/Project/Source/Gasa/Characters/GasaCharacter.h +++ b/Project/Source/Gasa/Characters/GasaCharacter.h @@ -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: diff --git a/Project/Source/Gasa/Characters/PlayerCharacter.cpp b/Project/Source/Gasa/Characters/PlayerCharacter.cpp index 12896f9..4ec8319 100644 --- a/Project/Source/Gasa/Characters/PlayerCharacter.cpp +++ b/Project/Source/Gasa/Characters/PlayerCharacter.cpp @@ -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()->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 diff --git a/Project/Source/Gasa/Characters/PlayerCharacter.h b/Project/Source/Gasa/Characters/PlayerCharacter.h index 984a79d..ba47fb4 100644 --- a/Project/Source/Gasa/Characters/PlayerCharacter.h +++ b/Project/Source/Gasa/Characters/PlayerCharacter.h @@ -12,6 +12,10 @@ public: APlayerCharacter(); +#pragma region ICombat + int32 GetLevel() override; +#pragma endregion ICombat + #pragma region Pawn void PossessedBy(AController* NewController) override; diff --git a/Project/Source/Gasa/Game/GasaPlayerState.cpp b/Project/Source/Gasa/Game/GasaPlayerState.cpp index c39b0e5..0b3cca6 100644 --- a/Project/Source/Gasa/Game/GasaPlayerState.cpp +++ b/Project/Source/Gasa/Game/GasaPlayerState.cpp @@ -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("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& Out { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - + DOREPLIFETIME(AGasaPlayerState, Level); } #pragma endregion UObject diff --git a/Project/Source/Gasa/Game/GasaPlayerState.h b/Project/Source/Gasa/Game/GasaPlayerState.h index b08363f..a3f5501 100644 --- a/Project/Source/Gasa/Game/GasaPlayerState.h +++ b/Project/Source/Gasa/Game/GasaPlayerState.h @@ -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; diff --git a/Project/Source/Gasa/Interfaces/CombatInterface.cpp b/Project/Source/Gasa/Interfaces/CombatInterface.cpp new file mode 100644 index 0000000..9098b6b --- /dev/null +++ b/Project/Source/Gasa/Interfaces/CombatInterface.cpp @@ -0,0 +1,6 @@ +#include "CombatInterface.h" + +int32 ICombat::GetPlayerLevel() +{ + return 0; +} diff --git a/Project/Source/Gasa/Interfaces/CombatInterface.h b/Project/Source/Gasa/Interfaces/CombatInterface.h new file mode 100644 index 0000000..b25a288 --- /dev/null +++ b/Project/Source/Gasa/Interfaces/CombatInterface.h @@ -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(); +};