diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index b65d9465..ec95d6a2 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -14,9 +14,20 @@ public: virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; EventRelay m_EPlayerDeath; - void OnPlayerDeath(const Events::PlayerDeath& e); + bool OnPlayerDeath(const Events::PlayerDeath& e); EventRelay m_EPlayerSpawned; - void OnPlayerSpawn(const Events::PlayerSpawned& e); + bool OnPlayerSpawn(const Events::PlayerSpawned& e); + +private: + struct PlayerData { + int ID = -1; + std::string Name = ""; + int Team = -1; + EntityWrapper Player = EntityWrapper::Invalid; + }; + + int m_PlayerCounter = 0; + std::unordered_map m_PlayerIdentities; }; #endif \ No newline at end of file diff --git a/resources/Schema/Components/ScoreIdentity.xml b/resources/Schema/Components/ScoreIdentity.xml index 95478277..a4aa0639 100644 --- a/resources/Schema/Components/ScoreIdentity.xml +++ b/resources/Schema/Components/ScoreIdentity.xml @@ -1,3 +1,10 @@ + + -1 + 0.0 + 0 + 0 + 0 + true \ No newline at end of file diff --git a/resources/Schema/Components/ScoreIdentity.xsd b/resources/Schema/Components/ScoreIdentity.xsd index 9ed69918..5ab80c22 100644 --- a/resources/Schema/Components/ScoreIdentity.xsd +++ b/resources/Schema/Components/ScoreIdentity.xsd @@ -4,6 +4,9 @@ A component tracking data for the score of a player. + + A unique id for tracking identities + The Kills per death score. @@ -16,5 +19,8 @@ Ping of a player. + + If the player is currently connected or not + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xml b/resources/Schema/Components/ScoreScreen.xml index 646002c4..65d84aa6 100644 --- a/resources/Schema/Components/ScoreScreen.xml +++ b/resources/Schema/Components/ScoreScreen.xml @@ -1,3 +1,5 @@ + 0 + 0 \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xsd b/resources/Schema/Components/ScoreScreen.xsd index 387140f2..d07b4a19 100644 --- a/resources/Schema/Components/ScoreScreen.xsd +++ b/resources/Schema/Components/ScoreScreen.xsd @@ -1,10 +1,13 @@ - - - The screen where player scores will be shown. - + The screen where player scores will be shown. + + The amount of score identities this scoreboard hold + + + Where the next scoreIdentity should be placed. + \ No newline at end of file diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 37dccb20..c66bdb2d 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -11,7 +11,30 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params) void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { - //Logic here + if(!entity.Valid() || !entity.HasComponent("ScoreScreen")){ + return; + } + + auto children = entity.ChildrenWithComponent("ScoreIdentity"); + + for (auto it = m_PlayerIdentities.begin(); it != m_PlayerIdentities.end(); ++it) { + bool found = false; + for (auto child : children) { + std::string name = (std::string)child["ScoreIdentity"]["Name"]; + if (it->first == name) { + found = true; + break; + } + } + if(found == false) { + //There is no entry for this player, create one. + + } + } + //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. } void ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) @@ -22,4 +45,26 @@ void ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e) { //When a player spawn, add a new entry to the score screen. + if(!e.Player.Valid()) { + return; + } + EntityWrapper entity = e.Player; + + std::unordered_map::const_iterator got; + got = m_PlayerIdentities.find(e.PlayerName); + if (got == m_PlayerIdentities.end()) { + PlayerData data; + data.ID = m_PlayerCounter; + data.Name = e.PlayerName; + data.Player = e.Player; + if(!entity.HasComponent("Team")) { + return; + } + data.Team = (int)entity["Team"]["Team"]; + + std::pair list (data.Name, data); + m_PlayerIdentities.insert(list); + m_PlayerCounter++; + } + }