Don't force to spectator camera if player presses pickTeam/Class prematurely. Players team should be remembered after picked, spawn request is not erased anymore.

This commit is contained in:
William Moberg
2016-03-08 18:26:17 +01:00
parent d7f09b1a8f
commit 7bc3c9f7b1
3 changed files with 18 additions and 8 deletions
+2
View File
@@ -24,6 +24,8 @@ private:
bool OnPlayerDeath(Events::PlayerDeath& e);
EventRelay<PlayerDeathSystem, Events::EntityDeleted> m_EEntityDeleted;
bool OnEntityDeleted(Events::EntityDeleted& e);
EventRelay<PlayerDeathSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(Events::InputCommand& e);
void setSpectatorCamera();
void createDeathEffect(EntityWrapper player);
+12
View File
@@ -6,6 +6,7 @@ PlayerDeathSystem::PlayerDeathSystem(SystemParams params)
{
EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerDeathSystem::OnPlayerDeath);
EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &PlayerDeathSystem::OnEntityDeleted);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &PlayerDeathSystem::OnInputCommand);
}
void PlayerDeathSystem::Update(double dt)
@@ -90,3 +91,14 @@ void PlayerDeathSystem::setSpectatorCamera()
Events::UnlockMouse unlock;
m_EventBroker->Publish(unlock);
}
bool PlayerDeathSystem::OnInputCommand(Events::InputCommand& e)
{
if (e.Value == 0 || e.Command != "SwapToTeamPick" && e.Command != "SwapToClassPick") {
return false;
}
// Ensure that we don't set spectator camera if the player deliberately changes to class/team pick.
m_LocalPlayerDeathEffect = EntityWrapper::Invalid;
return true;
}
+4 -8
View File
@@ -134,16 +134,12 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
auto iter = m_SpawnRequests.begin();
for (; iter != m_SpawnRequests.end(); ++iter) {
if (iter->PlayerID == e.PlayerID) {
// If player wants to switch team, remove their spawn request.
if (e.Command == "SwapToTeamPick") {
m_SpawnRequests.erase(iter);
} else if (e.Command == "SwapToClassPick") {
// If player wants to switch class, remove their selected class so they don't spawn.
// If player wants to switch team or class , remove their selected class so they don't spawn.
if (e.Command == "SwapToTeamPick" || e.Command == "SwapToClassPick") {
iter->Class = -1;
} else {
break;
return true;
}
return true;
break;
}
}