diff --git a/include/Game/Systems/CapturePointSystem.h b/include/Game/Systems/CapturePointSystem.h index 2d28c003..3fac1326 100644 --- a/include/Game/Systems/CapturePointSystem.h +++ b/include/Game/Systems/CapturePointSystem.h @@ -45,6 +45,7 @@ private: //std::vector const double m_CaptureTimeToTakeOver = 15.0; + bool m_ResetTimers = false; //vectors which will keep track of enter/leave changes std::vector> m_ETriggerTouchVector; diff --git a/resources/Schema/Entities/CaptureTestState1.xml b/resources/Schema/Entities/CaptureTestState1.xml index 03b93e81..75b14858 100644 --- a/resources/Schema/Entities/CaptureTestState1.xml +++ b/resources/Schema/Entities/CaptureTestState1.xml @@ -29,7 +29,7 @@ - + @@ -39,6 +39,7 @@ 3 + 6.9158446328696002 ../assets/Models/Core/UnitSphere.obj @@ -58,7 +59,7 @@ - -3.9175623281664684 + -13.234195338196177 1 @@ -79,7 +80,6 @@ - -1.8667072838033221 2 @@ -130,7 +130,7 @@ 2 - + @@ -148,7 +148,7 @@ 3 - + diff --git a/resources/Schema/Entities/CaptureTestState4.xml b/resources/Schema/Entities/CaptureTestState4.xml index fe30aab9..695df52e 100644 --- a/resources/Schema/Entities/CaptureTestState4.xml +++ b/resources/Schema/Entities/CaptureTestState4.xml @@ -29,7 +29,7 @@ - + @@ -37,7 +37,9 @@ - + + 3 + ../assets/Models/Core/UnitSphere.obj @@ -60,7 +62,7 @@ ../assets/Models/Core/UnitSphere.obj - + @@ -78,7 +80,6 @@ ../assets/Models/Core/UnitSphere.obj - @@ -96,7 +97,7 @@ ../assets/Models/Core/UnitSphere.obj - + @@ -110,6 +111,7 @@ + 2 4 diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index ef68ccdd..94ec8d62 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -8,12 +8,16 @@ CapturePointSystem::CapturePointSystem(EventBroker* eventBroker) //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); + EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); } //here all capturepoints will update their component //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { + if (m_WinnerWasFound) { + return; + } const int capturePointNumber = capturePoint["CapturePointNumber"]; const bool hasTeamComponent = world->HasComponent(capturePoint.EntityID, "Team"); @@ -81,6 +85,19 @@ void CapturePointSystem::UpdateComponent(World* world, EntityWrapper& entity, Co } } + //reset timers and reset the bool that triggers this + if (m_ResetTimers) { + for (size_t i = 0; i < m_NumberOfCapturePoints; i++) + { + ComponentWrapper& capturePoint = world->GetComponent(m_CapturePointNumberToEntityIDMap[i], "CapturePoint"); + if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] && + (int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) { + capturePoint["CaptureTimer"] = 0.0; + } + } + m_ResetTimers = false; + } + //colorize next possible capturepoint if (nextPossibleCapturePoint["Red"] == capturePointNumber) { entity["Model"]["Color"] = glm::vec4(1, 1, 0, 1); @@ -213,5 +230,7 @@ bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e) } bool CapturePointSystem::OnCaptured(const Events::Captured& e) { + //reset the timers in the next update since a capture has changed the "nextCapturePoint" for 1-2 teams + m_ResetTimers = true; return true; }