Merge pull request #147 from teamfisk/CapturePointFixBranch
ECaptured: added NextCapturePoint entitywrapper. Changed CapturePoint…
This commit is contained in:
@@ -12,7 +12,8 @@ namespace Events
|
|||||||
struct Captured : Event
|
struct Captured : Event
|
||||||
{
|
{
|
||||||
int TeamNumberThatCapturedCapturePoint;
|
int TeamNumberThatCapturedCapturePoint;
|
||||||
EntityID CapturePointID;
|
EntityID CapturePointTakenID;
|
||||||
|
EntityWrapper NextCapturePoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ private:
|
|||||||
int m_NumberOfCapturePoints = 0;
|
int m_NumberOfCapturePoints = 0;
|
||||||
std::map<int, EntityWrapper> m_CapturePointNumberToEntityMap;
|
std::map<int, EntityWrapper> m_CapturePointNumberToEntityMap;
|
||||||
|
|
||||||
//std::vector<ComponentWrapper>
|
|
||||||
|
|
||||||
bool m_ResetTimers = false;
|
bool m_ResetTimers = false;
|
||||||
|
bool m_RecentlyCapturedNeedNextCapturePointNow = false;
|
||||||
|
Events::Captured m_CapturedEvent;
|
||||||
|
|
||||||
//vectors which will keep track of enter/leave changes
|
//vectors which will keep track of enter/leave changes
|
||||||
std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerTouchVector;
|
std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerTouchVector;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
|||||||
, PureSystem("CapturePoint")
|
, PureSystem("CapturePoint")
|
||||||
{
|
{
|
||||||
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
||||||
if (!IsClient) {
|
if (IsServer) {
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
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
|
//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)
|
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
||||||
{
|
{
|
||||||
if (IsClient) {
|
if (!IsServer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_WinnerWasFound) {
|
if (m_WinnerWasFound) {
|
||||||
@@ -102,6 +102,13 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
nextPossibleCapturePoint["Blue"] = i - 1;
|
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
|
//reset timers and reset the bool that triggers this
|
||||||
if (m_ResetTimers) {
|
if (m_ResetTimers) {
|
||||||
@@ -188,10 +195,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
teamComponent["Team"] = currentTeam;
|
teamComponent["Team"] = currentTeam;
|
||||||
cCapturePoint["CaptureTimer"] = glm::sign((double)cCapturePoint["CaptureTimer"])*captureTimeToTakeOver;
|
cCapturePoint["CaptureTimer"] = glm::sign((double)cCapturePoint["CaptureTimer"])*captureTimeToTakeOver;
|
||||||
//publish Captured event
|
//publish Captured event
|
||||||
Events::Captured e;
|
m_RecentlyCapturedNeedNextCapturePointNow = true;
|
||||||
e.CapturePointID = cCapturePoint.EntityID;
|
m_CapturedEvent.CapturePointTakenID = cCapturePoint.EntityID;
|
||||||
e.TeamNumberThatCapturedCapturePoint = currentTeam;
|
m_CapturedEvent.TeamNumberThatCapturedCapturePoint = currentTeam;
|
||||||
m_EventBroker->Publish(e);
|
|
||||||
//NextPossibleCapturePoint will be calculated in the next update...
|
//NextPossibleCapturePoint will be calculated in the next update...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ bool SoundSystem::OnCaptured(const Events::Captured & e)
|
|||||||
if (!LocalPlayer.Valid()) {
|
if (!LocalPlayer.Valid()) {
|
||||||
return false;
|
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"];
|
int team = (int)m_World->GetComponent(LocalPlayer.ID, "Team")["Team"];
|
||||||
Events::PlaySoundOnEntity ev;
|
Events::PlaySoundOnEntity ev;
|
||||||
if (team == homeTeam) {
|
if (team == homeTeam) {
|
||||||
|
|||||||
Reference in New Issue
Block a user