SpectatorCamera shows capturepoint HUD and respawntimer. It no longer requires CapturePointGameMode component to work.
This commit is contained in:
@@ -27,8 +27,7 @@ void PlayerSpawnSystem::Update(double dt)
|
||||
double& timer = (double&)modeComponent["RespawnTime"];
|
||||
timer += dt;
|
||||
double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"];
|
||||
EntityWrapper theLevel = EntityWrapper(m_World, modeComponent.EntityID);
|
||||
EntityWrapper spectatorCam = theLevel.FirstChildByName("SpectatorCamera");
|
||||
EntityWrapper spectatorCam = m_World->GetFirstEntityByName("SpectatorCamera");
|
||||
if (spectatorCam.Valid()) {
|
||||
EntityWrapper HUD = spectatorCam.FirstChildByName("SpectatorHUD");
|
||||
if (HUD.Valid()) {
|
||||
@@ -66,7 +65,14 @@ void PlayerSpawnSystem::Update(double dt)
|
||||
|
||||
// If the spawner has a team affiliation, check it
|
||||
if (spawner.HasComponent("Team")) {
|
||||
if ((int)spawner["Team"]["Team"] != req.Team) {
|
||||
auto cSpawnerTeam = spawner["Team"];
|
||||
if ((int)cSpawnerTeam["Team"] != req.Team) {
|
||||
// Increase num spawned players if someone picks spectator, since it is valid to pick spectator
|
||||
// but don't spawn anything, goto next spawnrequest.
|
||||
if (req.Team == (int)cSpawnerTeam["Team"].Enum("Spectator")) {
|
||||
++numSpawnedPlayers;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -87,9 +93,9 @@ void PlayerSpawnSystem::Update(double dt)
|
||||
}
|
||||
}
|
||||
if (numSpawnedPlayers != (int)m_SpawnRequests.size()) {
|
||||
LOG_DEBUG("%i players were supposed to be spawned, but %i was spawned.", (int)m_SpawnRequests.size(), numSpawnedPlayers);
|
||||
LOG_DEBUG("%i players were supposed to be spawned or set as spectator, but only %i was handled.", (int)m_SpawnRequests.size(), numSpawnedPlayers);
|
||||
} else {
|
||||
LOG_DEBUG("%i players were spawned.", numSpawnedPlayers);
|
||||
LOG_DEBUG("%i players were spawned or set as spectator.", numSpawnedPlayers);
|
||||
}
|
||||
m_SpawnRequests.clear();
|
||||
}
|
||||
@@ -100,24 +106,29 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.Value == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// A dead client should be able to swap to the spectator camera.
|
||||
if (IsClient && !LocalPlayer.Valid()) {
|
||||
// Set the spectator camera as active, if it exists.
|
||||
// Find the camera.
|
||||
EntityWrapper spectatorCam = m_World->GetFirstEntityByName("SpectatorCamera");
|
||||
if (spectatorCam.Valid() && spectatorCam.HasComponent("Camera")) {
|
||||
Events::SetCamera eSetCamera;
|
||||
eSetCamera.CameraEntity = spectatorCam;
|
||||
m_EventBroker->Publish(eSetCamera);
|
||||
}
|
||||
}
|
||||
|
||||
// Team picks should be processed ONLY server-side!
|
||||
// Don't make a spawn request if we're the client.
|
||||
if (!IsServer && m_NetworkEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.Value == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO: Spectating?
|
||||
//Right now, return if someone picks spectator.
|
||||
//1 signifies spectator here, could not get Playerteam component since it may be invalid or without team comp.
|
||||
if ((ComponentInfo::EnumType)e.Value == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if the player already requested spawn.
|
||||
// Check if the player already requested spawn.
|
||||
auto iter = m_SpawnRequests.begin();
|
||||
for (; iter != m_SpawnRequests.end(); ++iter) {
|
||||
if (iter->PlayerID == e.PlayerID) {
|
||||
@@ -126,11 +137,11 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
|
||||
}
|
||||
|
||||
if (iter != m_SpawnRequests.end()) {
|
||||
//If player is in queue to spawn, then change their team affiliation in the request.
|
||||
// If player is in queue to spawn, then change their team affiliation in the request.
|
||||
iter->Team = (ComponentInfo::EnumType)e.Value;
|
||||
} else if (m_PlayerEntities.count(e.PlayerID) == 0 || !m_PlayerEntities[e.PlayerID].Valid()) {
|
||||
//If player is not in queue to spawn, then create a spawn request,
|
||||
//but only if they are spectating and/or just connected.
|
||||
// If player is not in queue to spawn, then create a spawn request,
|
||||
// but only if they are spectating and/or just connected.
|
||||
SpawnRequest req;
|
||||
req.PlayerID = e.PlayerID;
|
||||
req.Team = (ComponentInfo::EnumType)e.Value;
|
||||
|
||||
Reference in New Issue
Block a user