Spawn players during warmup but disable their input until match starts
This commit is contained in:
parent
10a672dc8f
commit
a21e7e71c9
BIN
GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset
(Stored with Git LFS)
BIN
GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset
(Stored with Git LFS)
Binary file not shown.
@ -90,7 +90,7 @@ void AGSGameModeBase::RestartPlayer(AController* NewPlayer)
|
||||
|
||||
// inform player controller that game has started using client RPC
|
||||
AGSPlayerController* PC = Cast<AGSPlayerController>(NewPlayer);
|
||||
if(PC)
|
||||
if(PC && IsMatchInProgress())
|
||||
{
|
||||
PC->Client_GameStarted();
|
||||
}
|
||||
@ -113,37 +113,6 @@ bool AGSGameModeBase::CanDamagePlayer(AGSPlayerController* Damager, AGSPlayerCon
|
||||
|
||||
void AGSGameModeBase::PickTeam(AGSPlayerState* PlayerState)
|
||||
{
|
||||
/*
|
||||
// place player on the team with the fewest players, or on the first team if all teams have the same number of players
|
||||
TArray<int32> NumTeamPlayers;
|
||||
AGSGameState* GS = GetGameState<AGSGameState>();
|
||||
NumTeamPlayers.AddZeroed(GS->GetNumTeams());
|
||||
|
||||
check(NumTeamPlayers.Num() > 0);
|
||||
|
||||
for(int32 PlayerIdx = 0; PlayerIdx < GS->PlayerArray.Num(); ++PlayerIdx)
|
||||
{
|
||||
AGSPlayerState* CurrPS = Cast<AGSPlayerState>(GS->PlayerArray[PlayerIdx]);
|
||||
if(CurrPS && CurrPS->GetTeamNum() >= 0 && CurrPS->GetTeamNum() < NumTeamPlayers.Num())
|
||||
{
|
||||
NumTeamPlayers[CurrPS->GetTeamNum()]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Player %s is on team number %d but only %d teams exist"), *CurrPS->GetPlayerName(), CurrPS->GetTeamNum(), NumTeamPlayers.Num())
|
||||
}
|
||||
}
|
||||
|
||||
int32 LowestTeamIdx = 0;
|
||||
for(int32 TeamIdx = 0; TeamIdx < NumTeamPlayers.Num(); TeamIdx++)
|
||||
{
|
||||
if(NumTeamPlayers[TeamIdx] < NumTeamPlayers[LowestTeamIdx])
|
||||
{
|
||||
LowestTeamIdx = TeamIdx;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
PlayerState->SetTeamNum(PlayerState->GetPlayerController()->GetLocalPlayer()->GetControllerId());
|
||||
}
|
||||
|
||||
@ -245,6 +214,28 @@ void AGSGameModeBase::FinishMatch()
|
||||
}
|
||||
}
|
||||
|
||||
void AGSGameModeBase::HandleStartingNewPlayer_Implementation(APlayerController* NewPlayer)
|
||||
{
|
||||
// If players should start as spectators, leave them in the spectator state
|
||||
if (!bStartPlayersAsSpectators && !MustSpectate(NewPlayer))
|
||||
{
|
||||
// If match is in progress, start the player
|
||||
if ((GetMatchState() == MatchState::WaitingToStart || IsMatchInProgress()) && PlayerCanRestart(NewPlayer))
|
||||
{
|
||||
RestartPlayer(NewPlayer);
|
||||
}
|
||||
// Check to see if we should start right away, avoids a one frame lag in single player games
|
||||
else if (GetMatchState() == MatchState::WaitingToStart)
|
||||
{
|
||||
// Check to see if we should start the match
|
||||
if (ReadyToStartMatch())
|
||||
{
|
||||
StartMatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AGSGameModeBase::HandleMatchIsWaitingToStart()
|
||||
{
|
||||
@ -266,6 +257,7 @@ void AGSGameModeBase::HandleMatchIsWaitingToStart()
|
||||
AGSPlayerController* PC = Cast<AGSPlayerController>(*It);
|
||||
if(PC)
|
||||
{
|
||||
RestartPlayer(PC);
|
||||
PC->Client_WarmupStarted();
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,8 @@ public:
|
||||
*/
|
||||
void FinishMatch();
|
||||
|
||||
virtual void HandleStartingNewPlayer_Implementation(APlayerController* NewPlayer) override;
|
||||
|
||||
/**
|
||||
* Sets up match warmup timer
|
||||
*/
|
||||
|
@ -30,6 +30,9 @@ void AGSPlayerController::Client_OnDeath_Implementation(AGSPlayerState* KillerPl
|
||||
|
||||
void AGSPlayerController::Client_WarmupStarted_Implementation()
|
||||
{
|
||||
// wait for server to tell us we can move
|
||||
SetIgnoreMoveInput(true);
|
||||
|
||||
OnWarmupStarted();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user