diff --git a/Source/Blaster/GameState/BlasterGameState.cpp b/Source/Blaster/GameState/BlasterGameState.cpp index 9c676b7..d571088 100644 --- a/Source/Blaster/GameState/BlasterGameState.cpp +++ b/Source/Blaster/GameState/BlasterGameState.cpp @@ -11,6 +11,8 @@ void ABlasterGameState::GetLifetimeReplicatedProps(TArray& Ou Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME(ABlasterGameState, TopScoringPlayers); + DOREPLIFETIME(ABlasterGameState, RedTeamScore); + DOREPLIFETIME(ABlasterGameState, BlueTeamScore); } void ABlasterGameState::UpdateTopScore(ABlasterPlayerState* ScoringPlayer) @@ -31,3 +33,13 @@ void ABlasterGameState::UpdateTopScore(ABlasterPlayerState* ScoringPlayer) TopScore = ScoringPlayer->GetScore(); } } + +void ABlasterGameState::OnRep_RedTeamScore() +{ + +} + +void ABlasterGameState::OnRep_BlueTeamScore() +{ + +} diff --git a/Source/Blaster/GameState/BlasterGameState.h b/Source/Blaster/GameState/BlasterGameState.h index 87cbf98..fd5e861 100644 --- a/Source/Blaster/GameState/BlasterGameState.h +++ b/Source/Blaster/GameState/BlasterGameState.h @@ -19,7 +19,23 @@ public: void UpdateTopScore(class ABlasterPlayerState* ScoringPlayer); UPROPERTY(Replicated) - TArray TopScoringPlayers; + TArray TopScoringPlayers; + + // Teams + TArray RedTeam; + TArray 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: diff --git a/Source/Blaster/PlayerState/BlasterPlayerState.cpp b/Source/Blaster/PlayerState/BlasterPlayerState.cpp index c2b710e..b3e0d24 100644 --- a/Source/Blaster/PlayerState/BlasterPlayerState.cpp +++ b/Source/Blaster/PlayerState/BlasterPlayerState.cpp @@ -12,6 +12,7 @@ void ABlasterPlayerState::GetLifetimeReplicatedProps(TArray& Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME(ABlasterPlayerState, Defeats); + DOREPLIFETIME(ABlasterPlayerState, Team); } void ABlasterPlayerState::IncreaseScore(float ScoreAmount) diff --git a/Source/Blaster/PlayerState/BlasterPlayerState.h b/Source/Blaster/PlayerState/BlasterPlayerState.h index 10b74e0..7f4d8fb 100644 --- a/Source/Blaster/PlayerState/BlasterPlayerState.h +++ b/Source/Blaster/PlayerState/BlasterPlayerState.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "Blaster/Types/Team.h" #include "GameFramework/PlayerState.h" #include "BlasterPlayerState.generated.h" @@ -31,4 +32,12 @@ private: UPROPERTY(ReplicatedUsing = OnRep_Defeats) int32 Defeats; + + UPROPERTY(Replicated) + ETeam Team = ET_NoTeam; + +public: + FORCEINLINE ETeam GetTeam() const { return Team; } + FORCEINLINE void SetTeam(ETeam TeamToSet) { Team = TeamToSet; } + }; diff --git a/Source/Blaster/Types/Team.h b/Source/Blaster/Types/Team.h new file mode 100644 index 0000000..cf5ee43 --- /dev/null +++ b/Source/Blaster/Types/Team.h @@ -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") +};