Added some fields in score components to track more data. Added some logic to the ScoreSystem class

This commit is contained in:
Tleety
2016-03-03 09:49:20 +01:00
parent 40c66f76ae
commit 27d3ec4118
6 changed files with 81 additions and 7 deletions
+46 -1
View File
@@ -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<std::string, PlayerData>::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<std::string, PlayerData> list (data.Name, data);
m_PlayerIdentities.insert(list);
m_PlayerCounter++;
}
}