CapturePointTimers are now reset for "inactive" CapturePoints after a capture.

This commit is contained in:
verysecrethero
2016-01-20 17:32:20 +01:00
parent 35876f6425
commit a596b8746b
4 changed files with 32 additions and 10 deletions
@@ -45,6 +45,7 @@ private:
//std::vector<ComponentWrapper>
const double m_CaptureTimeToTakeOver = 15.0;
bool m_ResetTimers = false;
//vectors which will keep track of enter/leave changes
std::vector<std::tuple<EntityID, EntityID>> m_ETriggerTouchVector;
@@ -29,7 +29,7 @@
</c:Team>
<c:Transform>
<Position X="-2.38960934" Y="11.7122087" Z="11.4659815"/>
<Orientation X="-0.715584457" Y="0.122161396" Z="1.65143504e-07"/>
<Orientation X="-0.645771146" Y="-1.17512627e-05" Z="1.76718231e-07"/>
</c:Transform>
</Components>
<Children/>
@@ -39,6 +39,7 @@
<c:AABB/>
<c:CapturePoint>
<HomePointForTeam>3</HomePointForTeam>
<CaptureTimer>6.9158446328696002</CaptureTimer>
</c:CapturePoint>
<c:Model>
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
@@ -58,7 +59,7 @@
<Components>
<c:AABB/>
<c:CapturePoint>
<CaptureTimer>-3.9175623281664684</CaptureTimer>
<CaptureTimer>-13.234195338196177</CaptureTimer>
<CapturePointNumber>1</CapturePointNumber>
</c:CapturePoint>
<c:Model>
@@ -79,7 +80,6 @@
<Components>
<c:AABB/>
<c:CapturePoint>
<CaptureTimer>-1.8667072838033221</CaptureTimer>
<CapturePointNumber>2</CapturePointNumber>
</c:CapturePoint>
<c:Model>
@@ -130,7 +130,7 @@
<Team>2</Team>
</c:Team>
<c:Transform>
<Position X="-0.154032111" Y="2.23822045" Z="-0.0577065349"/>
<Position X="4.99647331" Y="2.23822045" Z="1.80651212"/>
</c:Transform>
</Components>
<Children/>
@@ -148,7 +148,7 @@
<Team>3</Team>
</c:Team>
<c:Transform>
<Position X="3.2779336" Y="2.02053547" Z="-0.0348547697"/>
<Position X="2.7091608" Y="2.02053547" Z="-0.0348547697"/>
</c:Transform>
</Components>
<Children/>
@@ -29,7 +29,7 @@
</c:Team>
<c:Transform>
<Position X="-0.151326105" Y="13.5594187" Z="12.5957394"/>
<Orientation X="-0.837757885" Y="0.279239833" Z="-4.65052423e-08"/>
<Orientation X="-0.62831825" Y="0.0872534811" Z="-7.47903606e-09"/>
</c:Transform>
</Components>
<Children/>
@@ -37,7 +37,9 @@
<Entity>
<Components>
<c:AABB/>
<c:CapturePoint/>
<c:CapturePoint>
<HomePointForTeam>3</HomePointForTeam>
</c:CapturePoint>
<c:Model>
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="1" G="0.200000003" R="0"/>
@@ -60,7 +62,7 @@
</c:CapturePoint>
<c:Model>
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="0.200000003" R="1"/>
<Color A="1" B="1" G="1" R="0"/>
</c:Model>
<c:Team/>
<c:Transform>
@@ -78,7 +80,6 @@
</c:CapturePoint>
<c:Model>
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="0.200000003" R="1"/>
</c:Model>
<c:Team/>
<c:Transform>
@@ -96,7 +97,7 @@
</c:CapturePoint>
<c:Model>
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="0.200000003" R="1"/>
<Color A="1" B="0" G="1" R="1"/>
</c:Model>
<c:Team/>
<c:Transform>
@@ -110,6 +111,7 @@
<Components>
<c:AABB/>
<c:CapturePoint>
<HomePointForTeam>2</HomePointForTeam>
<CapturePointNumber>4</CapturePointNumber>
</c:CapturePoint>
<c:Model>
+19
View File
@@ -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;
}