This commit is contained in:
stiffly
2016-02-22 17:00:25 +01:00
parent 4c1a284636
commit 833006744a
5 changed files with 34 additions and 31 deletions
+1
View File
@@ -103,6 +103,7 @@ public:
void parseComponentDeletion(Packet& packet); void parseComponentDeletion(Packet& packet);
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType); void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
void parseSnapshot(Packet& packet); void parseSnapshot(Packet& packet);
void UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD);
void identifyPacketLoss(); void identifyPacketLoss();
void hasServerTimedOut(); void hasServerTimedOut();
EntityID createPlayer(); EntityID createPlayer();
+1 -2
View File
@@ -291,8 +291,7 @@
</Children> </Children>
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity> <Entity name="KillFeed">
<Entity name="KillFeed">
<Components> <Components>
<c:KillFeed/> <c:KillFeed/>
<c:Transform> <c:Transform>
+17 -3
View File
@@ -91,7 +91,7 @@ void Client::Update()
m_TimeSinceSentInputs = std::clock(); m_TimeSinceSentInputs = std::clock();
} }
// HACK: Send absolute player positions for now to avoid desync until we have reliable messages // HACK: Send absolute player positions for now to avoid desync until we have reliable messages
//sendLocalPlayerTransform(); sendLocalPlayerTransform();
hasServerTimedOut(); hasServerTimedOut();
} }
@@ -345,16 +345,18 @@ void Client::parseSnapshot(Packet& packet)
if (serverClientMapsHasEntity(serverEntityID)) { if (serverClientMapsHasEntity(serverEntityID)) {
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID); EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
EntityWrapper localEntity(m_World, localEntityID); EntityWrapper localEntity(m_World, localEntityID);
// Update entity // Update entity
if (m_World->HasComponent(localEntityID, componentType)) { if (m_World->HasComponent(localEntityID, componentType)) {
if (localEntity.Name() == "CapturePointHUD") {
UpdateLocalCapturePointHUD(localEntity);
}
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo); SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
bool shouldApply = true; bool shouldApply = true;
// Apply potential filter function // Apply potential filter function
if (m_SnapshotFilter != nullptr) { if (m_SnapshotFilter != nullptr) {
shouldApply = m_SnapshotFilter->FilterComponent(localEntity, newComponent); shouldApply = m_SnapshotFilter->FilterComponent(localEntity, newComponent);
} }
if (shouldApply) { if (shouldApply) {
ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType); ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType);
memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride); memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride);
} }
@@ -392,6 +394,18 @@ void Client::parseSnapshot(Packet& packet)
parseSpawnEvents(); parseSpawnEvents();
} }
void Client::UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD)
{
//auto children = m_World->GetChildren(capturePointHUD.ID);
//for (auto it = children.first; it != children.second; it++) {
// it->first
//}
//
//EntityWrapper& localHUD = m_LocalPlayer.FirstChildByName("HUD").FirstChildByName("CapturePointHUD");
//m_World->GetComponentPools()
}
void Client::disconnect() void Client::disconnect()
{ {
m_IsConnected = false; m_IsConnected = false;
+2 -3
View File
@@ -548,9 +548,8 @@ void Server::parsePlayerTransform(Packet& packet)
bool Server::shouldSendToClient(EntityWrapper childEntity) bool Server::shouldSendToClient(EntityWrapper childEntity)
{ {
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|| childEntity.HasComponent("CapturePointHUD") || childEntity.FirstParentWithComponent("CapturePointHUD").Valid(); || childEntity.HasComponent("CapturePoint") || childEntity.FirstParentWithComponent("CapturePoint").Valid();
} }
PlayerID Server::GetPlayerIDFromEndpoint() PlayerID Server::GetPlayerIDFromEndpoint()
+13 -23
View File
@@ -1,16 +1,15 @@
#include "Systems/CapturePointSystem.h" #include "Systems/CapturePointSystem.h"
#include <algorithm> #include <algorithm>
CapturePointSystem::CapturePointSystem(SystemParams params) CapturePointSystem::CapturePointSystem(SystemParams params)
: System(params) : System(params)
, PureSystem("CapturePoint") , PureSystem("CapturePoint")
{ {
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
//if (IsClient) { 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);
//}
} }
//here all capturepoints will update their component //here all capturepoints will update their component
@@ -20,7 +19,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
//if (!IsClient) { //if (!IsClient) {
// return; // return;
//} //}
if (m_WinnerWasFound) { if (m_WinnerWasFound) {
return; return;
} }
@@ -71,8 +69,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
std::map<std::string, int> nextPossibleCapturePoint; std::map<std::string, int> nextPossibleCapturePoint;
nextPossibleCapturePoint["Red"] = -1; nextPossibleCapturePoint["Red"] = -1;
nextPossibleCapturePoint["Blue"] = -1; nextPossibleCapturePoint["Blue"] = -1;
for (int i = 0; i < m_NumberOfCapturePoints; i++) for (int i = 0; i < m_NumberOfCapturePoints; i++) {
{
if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
continue; continue;
} }
@@ -84,8 +81,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
nextPossibleCapturePoint["Blue"] = i + 1; nextPossibleCapturePoint["Blue"] = i + 1;
} }
} }
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) {
{
if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
continue; continue;
} }
@@ -100,8 +96,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
//reset timers and reset the bool that triggers this //reset timers and reset the bool that triggers this
if (m_ResetTimers) { if (m_ResetTimers) {
for (int i = 0; i < m_NumberOfCapturePoints; i++) for (int i = 0; i < m_NumberOfCapturePoints; i++) {
{
ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"]; ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"];
if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] && if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] &&
(int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) { (int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) {
@@ -116,8 +111,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
} }
//check how many players are standing inside and are healthy //check how many players are standing inside and are healthy
for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--) for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--) {
{
auto triggerTouched = m_ETriggerTouchVector[i - 1]; auto triggerTouched = m_ETriggerTouchVector[i - 1];
if (std::get<1>(triggerTouched) == capturePointEntity) { if (std::get<1>(triggerTouched) == capturePointEntity) {
//some player has touched this - lets figure out: what team, health //some player has touched this - lets figure out: what team, health
@@ -195,17 +189,14 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
//check for possible winCondition = check if the homebase is owned by the other team //check for possible winCondition = check if the homebase is owned by the other team
bool checkForWinner = false; bool checkForWinner = false;
if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) {
{
checkForWinner = true; checkForWinner = true;
} }
if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) {
{
checkForWinner = true; checkForWinner = true;
} }
if (checkForWinner && !m_WinnerWasFound) if (checkForWinner && !m_WinnerWasFound) {
{
//publish Win event //publish Win event
Events::Win e; Events::Win e;
e.TeamThatWon = ownedBy; e.TeamThatWon = ownedBy;
@@ -224,8 +215,7 @@ bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e)
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e) bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e)
{ {
for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++) for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++) {
{
auto triggerTouched = m_ETriggerTouchVector[i]; auto triggerTouched = m_ETriggerTouchVector[i];
if (std::get<0>(triggerTouched) == e.Entity && std::get<1>(triggerTouched) == e.Trigger) { if (std::get<0>(triggerTouched) == e.Entity && std::get<1>(triggerTouched) == e.Trigger) {
m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i); m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i);