Infinite respawning for now
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user