From 00c585de3cb762aa1e8e92ed26e555631feb226b Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 20:45:16 +0100 Subject: [PATCH] Score should now track to all clients --- include/Game/Systems/ScoreScreenSystem.h | 1 + resources/Schema/Components/ScoreScreen.xml | 1 + resources/Schema/Components/ScoreScreen.xsd | 3 + resources/Schema/Entities/CP_Rocky.xml | 2278 ++++++++++--------- resources/Schema/Entities/ScoreBoard.xml | 107 + src/Engine/Network/Server.cpp | 10 +- src/Game/Systems/ScoreScreenSystem.cpp | 32 +- 7 files changed, 1309 insertions(+), 1123 deletions(-) create mode 100644 resources/Schema/Entities/ScoreBoard.xml diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index a33d4684..7a1d0cae 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -34,6 +34,7 @@ private: EntityWrapper Player = EntityWrapper::Invalid; }; + std::vector m_DisconnectedIdentities; int m_PlayerCounter = 0; std::unordered_map m_PlayerIdentities; }; diff --git a/resources/Schema/Components/ScoreScreen.xml b/resources/Schema/Components/ScoreScreen.xml index 65d84aa6..d3571d07 100644 --- a/resources/Schema/Components/ScoreScreen.xml +++ b/resources/Schema/Components/ScoreScreen.xml @@ -2,4 +2,5 @@ 0 0 + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xsd b/resources/Schema/Components/ScoreScreen.xsd index c8d3fa59..fb285813 100644 --- a/resources/Schema/Components/ScoreScreen.xsd +++ b/resources/Schema/Components/ScoreScreen.xsd @@ -11,6 +11,9 @@ Where the next scoreIdentity should be placed. + + How much offset should be applied per position + diff --git a/resources/Schema/Entities/CP_Rocky.xml b/resources/Schema/Entities/CP_Rocky.xml index a6f6302d..a0ae548f 100644 --- a/resources/Schema/Entities/CP_Rocky.xml +++ b/resources/Schema/Entities/CP_Rocky.xml @@ -112,61 +112,111 @@ - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -629,6 +679,49 @@ + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + @@ -673,17 +766,6 @@ - - - - - - - - - - - @@ -707,23 +789,19 @@ + + + + + + + + + + + - - - - - 5 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - @@ -739,34 +817,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - 2 - - - - - - - - - @@ -858,11 +908,11 @@ 2 - + - + @@ -879,7 +929,7 @@ - + @@ -905,11 +955,11 @@ 2 - + - + @@ -926,7 +976,7 @@ - + @@ -952,11 +1002,11 @@ 2 - + - + @@ -973,7 +1023,7 @@ - + @@ -999,11 +1049,11 @@ 2 - + - + @@ -1020,7 +1070,7 @@ - + @@ -1046,11 +1096,11 @@ 2 - + - + @@ -1067,7 +1117,7 @@ - + @@ -1093,11 +1143,11 @@ 2 - + - + @@ -1114,7 +1164,7 @@ - + @@ -1140,11 +1190,11 @@ 2 - + - + @@ -1161,7 +1211,7 @@ - + @@ -2409,11 +2459,11 @@ 2 - + - + @@ -2430,7 +2480,7 @@ - + @@ -2456,11 +2506,11 @@ 2 - + - + @@ -2477,7 +2527,7 @@ - + @@ -2739,559 +2789,6 @@ - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - @@ -3311,47 +2808,6 @@ - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - @@ -3470,6 +2926,135 @@ + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + @@ -3484,8 +3069,8 @@ Models/Props/SciFiHolder1.mesh - - + + @@ -3497,8 +3082,8 @@ Models/Props/SciFiHolder1.mesh - - + + @@ -3514,11 +3099,23 @@ - Models/Props/Walls/BigWallRed.mesh + Models/Props/Walls/MediumWall1.mesh - - + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + @@ -3540,11 +3137,10 @@ - Models/Props/Walls/MediumWall2.mesh + Models/Props/Walls/MediumWall1.mesh - - + @@ -3556,12 +3152,65 @@ Models/Props/Walls/SmallWall3.mesh - + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + @@ -3627,20 +3276,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -3654,18 +3289,6 @@ - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - @@ -3679,15 +3302,70 @@ + + + + + + + - Models/Props/Walls/MediumWall2.mesh + Models/Props/Flora/SpecialRoot.mesh - - + + + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + @@ -3696,10 +3374,11 @@ - Models/Props/Walls/MediumWall1.mesh + Models/Props/Stones/MediumStone2.mesh - + + @@ -3708,11 +3387,382 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + @@ -3724,6 +3774,21 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -3739,6 +3804,85 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -3771,13 +3915,14 @@ - 6 + 4 Models/Props/Stones/ShinyStoneCrystalBlue.mesh + - - - + + + @@ -3785,20 +3930,10 @@ + 3 - - - - - - - - - - - - + @@ -3810,7 +3945,20 @@ 2 - + + + + + + + + + + 2 + 1 + + + @@ -3832,104 +3980,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 4 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 2 - 1 - - - - - - - - - - - - 2 - - - - - - - - - - - - 3 - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -3943,9 +3993,9 @@ Models/Props/PickUps/PickUpHolder.mesh - - - + + + @@ -3953,11 +4003,11 @@ 2 - + - + @@ -3972,56 +4022,9 @@ Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - + @@ -4047,11 +4050,11 @@ 2 - + - + @@ -4068,7 +4071,7 @@ - + @@ -4084,9 +4087,9 @@ Models/Props/PickUps/PickUpHolder.mesh - - - + + + @@ -4094,11 +4097,11 @@ 2 - + - + @@ -4114,55 +4117,8 @@ Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - + + @@ -4188,11 +4144,11 @@ 2 - + - + @@ -4209,7 +4165,54 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + @@ -4235,11 +4238,11 @@ 2 - + - + @@ -4256,7 +4259,54 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -4273,6 +4323,20 @@ + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + @@ -4302,20 +4366,6 @@ - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - @@ -4516,76 +4566,6 @@ - - - - - Schema/Entities/PlayerRed.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - @@ -4610,7 +4590,7 @@ false - + @@ -4623,7 +4603,7 @@ false - + @@ -4656,18 +4636,97 @@ + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + - + - - 0.40000000596046448 - + + 1 + + + + + + + + + 10 + - + @@ -4675,11 +4734,10 @@ - 10 - + @@ -4707,22 +4765,13 @@ - + - - 1 - - - - - - - - - 10 - + + 0.40000000596046448 + - + @@ -4730,10 +4779,11 @@ + 10 - + diff --git a/resources/Schema/Entities/ScoreBoard.xml b/resources/Schema/Entities/ScoreBoard.xml new file mode 100644 index 00000000..ce612800 --- /dev/null +++ b/resources/Schema/Entities/ScoreBoard.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 71889379..6d6c4f92 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -635,9 +635,13 @@ bool Server::shouldSendToClient(EntityWrapper childEntity) return true; } } - return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() - || childEntity.HasComponent("CapturePoint") || childEntity.HasComponent("HealthPickup") - || childEntity.HasComponent("AmmoPickup"); + return childEntity.HasComponent("Player") + || childEntity.FirstParentWithComponent("Player").Valid() + || childEntity.HasComponent("CapturePoint") + || childEntity.HasComponent("HealthPickup") + || childEntity.HasComponent("AmmoPickup") + || childEntity.HasComponent("ScoreScreen") + || childEntity.FirstParentWithComponent("ScoreScreen").Valid(); } PlayerID Server::GetPlayerIDFromEndpoint() diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 0713e13b..e23fba1d 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -13,7 +13,6 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params) void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { - //TODO: Check team al if (!IsServer) { return; } @@ -37,6 +36,8 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& auto children = entity.ChildrenWithComponent("ScoreIdentity"); + float position = 0.f; + for (auto it = m_PlayerIdentities.begin(); it != m_PlayerIdentities.end(); ++it) { bool found = false; @@ -45,20 +46,38 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& if (it->first == ID) { if (it->second.Team != currentTeam) { m_World->DeleteEntity(child.ID); + (int&)entity["ScoreScreen"]["TotalIdentities"] -= 1; break; } + for (auto it = m_DisconnectedIdentities.begin(); it != m_DisconnectedIdentities.end(); ++it) { + if (ID = *it) { + + m_World->DeleteEntity(child.ID); + (int&)entity["ScoreScreen"]["TotalIdentities"] -= 1; + it = m_DisconnectedIdentities.erase(it); + break; + } + } found = true; + //Update position for childs + glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"]; + (glm::vec3&) child["Transform"]["Position"] = offset * position; + position += 1.f; + break; } } if(found == false) { if(it->second.Team != currentTeam) { //This player is not the same team as this scoreboard should show. - break; + continue; } //There is no entry for this player, create one. auto entityFile = ResourceManager::Load("Schema/Entities/ScoreIdentity.xml"); EntityWrapper scoreIdentity = entityFile->MergeInto(m_World); + glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"]; + int newPosition = (int)entity["ScoreScreen"]["TotalIdentities"]; + (glm::vec3&) scoreIdentity["Transform"]["Position"] = offset * (float)newPosition; auto cScoreIdentity = scoreIdentity["ScoreIdentity"]; auto data = it->second; @@ -67,12 +86,12 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& (int&)cScoreIdentity["Ping"] = 1337; m_World->SetParent(scoreIdentity.ID, entity.ID); + + (int&)entity["ScoreScreen"]["TotalIdentities"] += 1; + } } - //For each scoreboard, go through children and see if they have all of the ones needed. - //Also need to take into account the order so they dont flicker. - //If they do not have all children we need to add them. - //Just add a new component to the scorescreen entity, the "ScoreIdentity" component. + //Local player should have an icon, compare with LocalPlayer somthing } bool ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) @@ -113,6 +132,7 @@ bool ScoreScreenSystem::OnPlayerConnected(const Events::PlayerConnected& e) bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e) { //player has disconnected, remove him from list of ScoreIdentities + m_DisconnectedIdentities.push_back(e.PlayerID); m_PlayerIdentities.erase(e.PlayerID); return 0; }