214 - Teams

This commit is contained in:
Kingsmedia 2022-05-30 15:48:46 +02:00
parent 3da023c406
commit 23f3840756
5 changed files with 50 additions and 1 deletions

View File

@ -11,6 +11,8 @@ void ABlasterGameState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Ou
Super::GetLifetimeReplicatedProps(OutLifetimeProps); Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ABlasterGameState, TopScoringPlayers); DOREPLIFETIME(ABlasterGameState, TopScoringPlayers);
DOREPLIFETIME(ABlasterGameState, RedTeamScore);
DOREPLIFETIME(ABlasterGameState, BlueTeamScore);
} }
void ABlasterGameState::UpdateTopScore(ABlasterPlayerState* ScoringPlayer) void ABlasterGameState::UpdateTopScore(ABlasterPlayerState* ScoringPlayer)
@ -31,3 +33,13 @@ void ABlasterGameState::UpdateTopScore(ABlasterPlayerState* ScoringPlayer)
TopScore = ScoringPlayer->GetScore(); TopScore = ScoringPlayer->GetScore();
} }
} }
void ABlasterGameState::OnRep_RedTeamScore()
{
}
void ABlasterGameState::OnRep_BlueTeamScore()
{
}

View File

@ -19,7 +19,23 @@ public:
void UpdateTopScore(class ABlasterPlayerState* ScoringPlayer); void UpdateTopScore(class ABlasterPlayerState* ScoringPlayer);
UPROPERTY(Replicated) UPROPERTY(Replicated)
TArray<class ABlasterPlayerState*> TopScoringPlayers; TArray<ABlasterPlayerState*> TopScoringPlayers;
// Teams
TArray<ABlasterPlayerState*> RedTeam;
TArray<ABlasterPlayerState*> BlueTeam;
UPROPERTY(ReplicatedUsing = OnRep_RedTeamScore)
float RedTeamScore = 0.f;
UPROPERTY(ReplicatedUsing = OnRep_BlueTeamScore)
float BlueTeamScore = 0.f;
UFUNCTION()
void OnRep_RedTeamScore();
UFUNCTION()
void OnRep_BlueTeamScore();
private: private:

View File

@ -12,6 +12,7 @@ void ABlasterPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>&
Super::GetLifetimeReplicatedProps(OutLifetimeProps); Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ABlasterPlayerState, Defeats); DOREPLIFETIME(ABlasterPlayerState, Defeats);
DOREPLIFETIME(ABlasterPlayerState, Team);
} }
void ABlasterPlayerState::IncreaseScore(float ScoreAmount) void ABlasterPlayerState::IncreaseScore(float ScoreAmount)

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Blaster/Types/Team.h"
#include "GameFramework/PlayerState.h" #include "GameFramework/PlayerState.h"
#include "BlasterPlayerState.generated.h" #include "BlasterPlayerState.generated.h"
@ -31,4 +32,12 @@ private:
UPROPERTY(ReplicatedUsing = OnRep_Defeats) UPROPERTY(ReplicatedUsing = OnRep_Defeats)
int32 Defeats; int32 Defeats;
UPROPERTY(Replicated)
ETeam Team = ET_NoTeam;
public:
FORCEINLINE ETeam GetTeam() const { return Team; }
FORCEINLINE void SetTeam(ETeam TeamToSet) { Team = TeamToSet; }
}; };

View File

@ -0,0 +1,11 @@
#pragma once
UENUM(BlueprintType)
enum Class ETeam : uint8
{
ET_RedTeam UMETA(DiaplayName = "RedTeam"),
ET_BlueTeam UMETA(DiaplayName = "BlueTeam"),
ET_NoTeam UMETA(DiaplayName = "No Team"),
ET_Max UMETA(DisplayName = "DefaultMax")
};