Infinite respawning for now

This commit is contained in:
2016-01-23 15:06:41 +01:00
parent 482689fd48
commit b83d773627
2 changed files with 10 additions and 0 deletions
+1
View File
@@ -22,6 +22,7 @@ private:
bool m_NetworkEnabled = false;
std::vector<SpawnRequest> m_SpawnRequests;
std::map<int, EntityWrapper> m_PlayerEntities;
EventRelay<PlayerSpawnSystem, Events::InputCommand> m_OnInputCommand;
bool OnInputCommand(const Events::InputCommand& e);
+9
View File
@@ -72,6 +72,12 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
{
// When a player is actually spawned (since the actual spawning is handled on the server)
// Check if a player already exists
if (m_PlayerEntities.count(e.PlayerID) != 0) {
// TODO: Disallow infinite respawning here
m_World->DeleteEntity(m_PlayerEntities[e.PlayerID].ID);
}
// Set the camera to the correct entity
EntityWrapper cameraEntity = e.Player.FirstChildByName("Camera");
if (cameraEntity.Valid()) {
@@ -80,5 +86,8 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
m_EventBroker->Publish(e);
}
// Store the player for future reference
m_PlayerEntities[e.PlayerID] = e.Player;
return true;
}