Merge pull request #147 from teamfisk/CapturePointFixBranch

ECaptured: added NextCapturePoint entitywrapper. Changed CapturePoint…
This commit is contained in:
Tobias Dahl
2016-03-01 20:33:10 +01:00
4 changed files with 17 additions and 10 deletions
+2 -1
View File
@@ -12,7 +12,8 @@ namespace Events
struct Captured : Event
{
int TeamNumberThatCapturedCapturePoint;
EntityID CapturePointID;
EntityID CapturePointTakenID;
EntityWrapper NextCapturePoint;
};
}
+2 -2
View File
@@ -42,9 +42,9 @@ private:
int m_NumberOfCapturePoints = 0;
std::map<int, EntityWrapper> m_CapturePointNumberToEntityMap;
//std::vector<ComponentWrapper>
bool m_ResetTimers = false;
bool m_RecentlyCapturedNeedNextCapturePointNow = false;
Events::Captured m_CapturedEvent;
//vectors which will keep track of enter/leave changes
std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerTouchVector;
+12 -6
View File
@@ -6,7 +6,7 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
, PureSystem("CapturePoint")
{
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
if (!IsClient) {
if (IsServer) {
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
@@ -18,7 +18,7 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
{
if (IsClient) {
if (!IsServer) {
return;
}
if (m_WinnerWasFound) {
@@ -102,6 +102,13 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
nextPossibleCapturePoint["Blue"] = i - 1;
}
}
if (m_RecentlyCapturedNeedNextCapturePointNow) {
m_CapturedEvent.NextCapturePoint = m_CapturedEvent.TeamNumberThatCapturedCapturePoint == blueTeam ?
m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]] :
m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]];
m_EventBroker->Publish(m_CapturedEvent);
m_RecentlyCapturedNeedNextCapturePointNow = false;
}
//reset timers and reset the bool that triggers this
if (m_ResetTimers) {
@@ -188,10 +195,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
teamComponent["Team"] = currentTeam;
cCapturePoint["CaptureTimer"] = glm::sign((double)cCapturePoint["CaptureTimer"])*captureTimeToTakeOver;
//publish Captured event
Events::Captured e;
e.CapturePointID = cCapturePoint.EntityID;
e.TeamNumberThatCapturedCapturePoint = currentTeam;
m_EventBroker->Publish(e);
m_RecentlyCapturedNeedNextCapturePointNow = true;
m_CapturedEvent.CapturePointTakenID = cCapturePoint.EntityID;
m_CapturedEvent.TeamNumberThatCapturedCapturePoint = currentTeam;
//NextPossibleCapturePoint will be calculated in the next update...
}
}
+1 -1
View File
@@ -94,7 +94,7 @@ bool SoundSystem::OnCaptured(const Events::Captured & e)
if (!LocalPlayer.Valid()) {
return false;
}
int homeTeam = (int)m_World->GetComponent(e.CapturePointID, "Team")["Team"];
int homeTeam = (int)m_World->GetComponent(e.CapturePointTakenID, "Team")["Team"];
int team = (int)m_World->GetComponent(LocalPlayer.ID, "Team")["Team"];
Events::PlaySoundOnEntity ev;
if (team == homeTeam) {