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 InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
void parseSnapshot(Packet& packet);
void UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD);
void identifyPacketLoss();
void hasServerTimedOut();
EntityID createPlayer();
+1 -2
View File
@@ -291,8 +291,7 @@
</Children>
</Entity>
</Children>
</Entity>
<Entity name="KillFeed">
</Entity> <Entity name="KillFeed">
<Components>
<c:KillFeed/>
<c:Transform>
+17 -3
View File
@@ -91,7 +91,7 @@ void Client::Update()
m_TimeSinceSentInputs = std::clock();
}
// HACK: Send absolute player positions for now to avoid desync until we have reliable messages
//sendLocalPlayerTransform();
sendLocalPlayerTransform();
hasServerTimedOut();
}
@@ -345,16 +345,18 @@ void Client::parseSnapshot(Packet& packet)
if (serverClientMapsHasEntity(serverEntityID)) {
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
EntityWrapper localEntity(m_World, localEntityID);
// Update entity
if (m_World->HasComponent(localEntityID, componentType)) {
if (localEntity.Name() == "CapturePointHUD") {
UpdateLocalCapturePointHUD(localEntity);
}
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
bool shouldApply = true;
// Apply potential filter function
if (m_SnapshotFilter != nullptr) {
shouldApply = m_SnapshotFilter->FilterComponent(localEntity, newComponent);
}
if (shouldApply) {
if (shouldApply) {
ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType);
memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride);
}
@@ -392,6 +394,18 @@ void Client::parseSnapshot(Packet& packet)
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()
{
m_IsConnected = false;
+2 -3
View File
@@ -548,9 +548,8 @@ void Server::parsePlayerTransform(Packet& packet)
bool Server::shouldSendToClient(EntityWrapper childEntity)
{
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|| childEntity.HasComponent("CapturePointHUD") || childEntity.FirstParentWithComponent("CapturePointHUD").Valid();
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|| childEntity.HasComponent("CapturePoint") || childEntity.FirstParentWithComponent("CapturePoint").Valid();
}
PlayerID Server::GetPlayerIDFromEndpoint()
+13 -23
View File
@@ -1,16 +1,15 @@
#include "Systems/CapturePointSystem.h"
#include <algorithm>
CapturePointSystem::CapturePointSystem(SystemParams params)
CapturePointSystem::CapturePointSystem(SystemParams params)
: System(params)
, PureSystem("CapturePoint")
{
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
//if (IsClient) {
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
//}
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
@@ -20,7 +19,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
//if (!IsClient) {
// return;
//}
if (m_WinnerWasFound) {
return;
}
@@ -71,8 +69,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
std::map<std::string, int> nextPossibleCapturePoint;
nextPossibleCapturePoint["Red"] = -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")) {
continue;
}
@@ -84,8 +81,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
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")) {
continue;
}
@@ -100,8 +96,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
//reset timers and reset the bool that triggers this
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"];
if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] &&
(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
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];
if (std::get<1>(triggerTouched) == capturePointEntity) {
//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
bool checkForWinner = false;
if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam)
{
if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) {
checkForWinner = true;
}
if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam)
{
if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) {
checkForWinner = true;
}
if (checkForWinner && !m_WinnerWasFound)
{
if (checkForWinner && !m_WinnerWasFound) {
//publish Win event
Events::Win e;
e.TeamThatWon = ownedBy;
@@ -224,8 +215,7 @@ bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& 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];
if (std::get<0>(triggerTouched) == e.Entity && std::get<1>(triggerTouched) == e.Trigger) {
m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i);