From 7bc3c9f7b17a3a89e8a09dc8b27a1124b45a24b6 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Tue, 8 Mar 2016 18:26:17 +0100 Subject: [PATCH] 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. --- include/Game/Systems/PlayerDeathSystem.h | 2 ++ src/Game/Systems/PlayerDeathSystem.cpp | 12 ++++++++++++ src/Game/Systems/PlayerSpawnSystem.cpp | 12 ++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/Game/Systems/PlayerDeathSystem.h b/include/Game/Systems/PlayerDeathSystem.h index 5a82f999..91b9997b 100644 --- a/include/Game/Systems/PlayerDeathSystem.h +++ b/include/Game/Systems/PlayerDeathSystem.h @@ -24,6 +24,8 @@ private: bool OnPlayerDeath(Events::PlayerDeath& e); EventRelay m_EEntityDeleted; bool OnEntityDeleted(Events::EntityDeleted& e); + EventRelay m_EInputCommand; + bool OnInputCommand(Events::InputCommand& e); void setSpectatorCamera(); void createDeathEffect(EntityWrapper player); diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index c562e530..4b7606e7 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -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; +} \ No newline at end of file diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index e13f1bdc..0c0c60a1 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -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; } }