WIP
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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,9 +345,11 @@ 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
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -549,8 +549,7 @@ 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()
|
||||||
|
|||||||
@@ -6,11 +6,10 @@ 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) {
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user