Spawner, SpawnPoint and PlayerSpawn components, and base work on their systems

This commit is contained in:
2016-01-15 18:32:47 +01:00
parent 97e12ff550
commit db1b972cd1
22 changed files with 288 additions and 4 deletions
+39
View File
@@ -0,0 +1,39 @@
#include "Systems/PlayerSpawnSystem.h"
PlayerSpawnSystem::PlayerSpawnSystem(EventBroker* eventBroker)
: System(eventBroker)
{
EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand);
}
void PlayerSpawnSystem::Update(World* world, double dt)
{
auto componentPools = world->GetComponentPools();
auto spawnerPool = componentPools.find("Spawner");
if (spawnerPool == componentPools.end()) {
return;
}
;
for (auto& team : m_SpawnRequests) {
for (auto& spawner : *spawnerPool->second) {
Events::SpawnerSpawn e;
e.Spawner = EntityWrapper(world, spawner.EntityID);
m_EventBroker->Publish(e);
}
}
m_SpawnRequests.clear();
}
bool PlayerSpawnSystem::OnInputCommand(const Events::InputCommand& e)
{
if (e.Command != "PickTeam") {
return false;
}
if (e.Value != 0) {
m_SpawnRequests.push_back((int)e.Value);
}
return true;
}