73. Player Level and Combat Interface
This commit is contained in:
		@@ -6,4 +6,13 @@ AEnemyCharacter::AEnemyCharacter()
 | 
			
		||||
	PrimaryActorTick.bCanEverTick = true;
 | 
			
		||||
 | 
			
		||||
	bAutoAbilitySystem = true;
 | 
			
		||||
	
 | 
			
		||||
	PlayerLevel = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#pragma region ICombat
 | 
			
		||||
int32 AEnemyCharacter::GetPlayerLevel()
 | 
			
		||||
{
 | 
			
		||||
	return PlayerLevel;
 | 
			
		||||
}
 | 
			
		||||
#pragma endregion ICombat
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,10 @@ public:
 | 
			
		||||
 | 
			
		||||
	APlayerCharacter();
 | 
			
		||||
 | 
			
		||||
#pragma region ICombat
 | 
			
		||||
	int32 GetLevel() override;
 | 
			
		||||
#pragma endregion ICombat
 | 
			
		||||
 | 
			
		||||
#pragma region Pawn
 | 
			
		||||
	void PossessedBy(AController* NewController) override;
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								Project/Source/Gasa/Interfaces/CombatInterface.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								Project/Source/Gasa/Interfaces/CombatInterface.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
#include "CombatInterface.h"
 | 
			
		||||
 | 
			
		||||
int32 ICombat::GetPlayerLevel()
 | 
			
		||||
{
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								Project/Source/Gasa/Interfaces/CombatInterface.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								Project/Source/Gasa/Interfaces/CombatInterface.h
									
									
									
									
									
										Normal 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();
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user