Some new events and changes to ScoreSystem

This commit is contained in:
Tleety
2016-03-03 11:25:06 +01:00
parent 27d3ec4118
commit ff6e2167d4
10 changed files with 1251 additions and 1084 deletions
+33 -6
View File
@@ -7,11 +7,14 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params)
{
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &ScoreScreenSystem::OnPlayerDeath);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected);
}
void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt)
{
if(!entity.Valid() || !entity.HasComponent("ScoreScreen")){
//TODO: Check team al
if(!entity.HasComponent("ScoreScreen")){
return;
}
@@ -28,7 +31,20 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper&
}
if(found == false) {
//There is no entry for this player, create one.
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/ScoreIdentity.xml");
EntityWrapper scoreIdentity = entityFile->MergeInto(m_World);
auto cScoreIdentity = scoreIdentity["ScoreIdentity"];
auto data = it->second;
std::printf("\n\n");
std::printf(data.Name.c_str());
std::printf("\n\n");
(std::string&)cScoreIdentity["Name"] = data.Name;
(int&)cScoreIdentity["ID"] = data.ID;
(int&)cScoreIdentity["Ping"] = 1337;
m_World->SetName(scoreIdentity.ID, data.Name);
m_World->SetParent(scoreIdentity.ID, entity.ID);
}
}
//For each scoreboard, go through children and see if they have all of the ones needed.
@@ -37,16 +53,17 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper&
//Just add a new component to the scorescreen entity, the "ScoreIdentity" component.
}
void ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e)
bool ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e)
{
//When player die, add it to his score, and when possible the player who killed him.
return 0;
}
void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
bool ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
{
//When a player spawn, add a new entry to the score screen.
if(!e.Player.Valid()) {
return;
return 0;
}
EntityWrapper entity = e.Player;
@@ -58,7 +75,7 @@ void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
data.Name = e.PlayerName;
data.Player = e.Player;
if(!entity.HasComponent("Team")) {
return;
return 0;
}
data.Team = (int)entity["Team"]["Team"];
@@ -66,5 +83,15 @@ void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
m_PlayerIdentities.insert(list);
m_PlayerCounter++;
}
return 0;
}
bool ScoreScreenSystem::OnPlayerConnected(const Events::PlayerConnected& e)
{
return 0;
}
bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e)
{
return 0;
}