Removed debug logging. PlayerID in InputCommands from buttons is corrected.
This commit is contained in:
@@ -40,7 +40,7 @@ bool ButtonSystem::OnMousePress(const Events::MousePress& e)
|
|||||||
//You have clicked on a button entity, send pressed event.
|
//You have clicked on a button entity, send pressed event.
|
||||||
if (m_World->HasComponent(m_PickData.Entity, "InputCmdButton")) {
|
if (m_World->HasComponent(m_PickData.Entity, "InputCmdButton")) {
|
||||||
Events::InputCommand eInputCmd;
|
Events::InputCommand eInputCmd;
|
||||||
eInputCmd.PlayerID = LocalPlayer.ID;
|
eInputCmd.PlayerID = -1;
|
||||||
eInputCmd.Player = LocalPlayer;
|
eInputCmd.Player = LocalPlayer;
|
||||||
EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity);
|
EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity);
|
||||||
eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"];
|
eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"];
|
||||||
@@ -68,7 +68,7 @@ bool ButtonSystem::OnMouseRelease(const Events::MouseRelease& e)
|
|||||||
|
|
||||||
if (m_World->HasComponent(m_PickData.Entity, "InputCmdButton")) {
|
if (m_World->HasComponent(m_PickData.Entity, "InputCmdButton")) {
|
||||||
Events::InputCommand eInputCmd;
|
Events::InputCommand eInputCmd;
|
||||||
eInputCmd.PlayerID = LocalPlayer.ID;
|
eInputCmd.PlayerID = -1;
|
||||||
eInputCmd.Player = LocalPlayer;
|
eInputCmd.Player = LocalPlayer;
|
||||||
EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity);
|
EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity);
|
||||||
eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"];
|
eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"];
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("------ Player #%i died.", e.Player.ID);
|
|
||||||
|
|
||||||
createDeathEffect(e.Player);
|
createDeathEffect(e.Player);
|
||||||
|
|
||||||
// Delete player
|
// Delete player
|
||||||
@@ -38,7 +36,6 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
|||||||
auto playerModel = player.FirstChildByName("PlayerModel");
|
auto playerModel = player.FirstChildByName("PlayerModel");
|
||||||
if (!playerModel.Valid() || !playerModel.HasComponent("Model") || !playerModel.HasComponent("Animation")) {
|
if (!playerModel.Valid() || !playerModel.HasComponent("Model") || !playerModel.HasComponent("Animation")) {
|
||||||
if (player == LocalPlayer) {
|
if (player == LocalPlayer) {
|
||||||
LOG_DEBUG("------ LocalPlayer's death effect could not be spawned, setting to spectator instead of death cam.");
|
|
||||||
setSpectatorCamera();
|
setSpectatorCamera();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -58,7 +55,6 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
|||||||
|
|
||||||
//camera (with lifetime) behind the player
|
//camera (with lifetime) behind the player
|
||||||
if (player == LocalPlayer) {
|
if (player == LocalPlayer) {
|
||||||
LOG_DEBUG("------ LocalPlayer's death effect spawning, setting to death camera.");
|
|
||||||
m_LocalPlayerDeathEffect = deathEffectEW;
|
m_LocalPlayerDeathEffect = deathEffectEW;
|
||||||
auto cam = deathEffectEW.FirstChildByName("Camera");
|
auto cam = deathEffectEW.FirstChildByName("Camera");
|
||||||
Events::SetCamera eSetCamera;
|
Events::SetCamera eSetCamera;
|
||||||
@@ -76,10 +72,7 @@ bool PlayerDeathSystem::OnEntityDeleted(Events::EntityDeleted& e)
|
|||||||
|
|
||||||
// If the player hasn't spawned already, activate the spectator camera.
|
// If the player hasn't spawned already, activate the spectator camera.
|
||||||
if (!LocalPlayer.Valid()) {
|
if (!LocalPlayer.Valid()) {
|
||||||
LOG_DEBUG("------ LocalPlayer's death effect removed, setting to spectator.");
|
|
||||||
setSpectatorCamera();
|
setSpectatorCamera();
|
||||||
} else {
|
|
||||||
LOG_DEBUG("------ LocalPlayer's death effect removed, player is already spawned, not setting spectator.");
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,16 +59,16 @@ void PlayerSpawnSystem::Update(double dt)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numHandledRequests = 0;
|
int numSpawnedPlayers = 0;
|
||||||
int playersStillPickingClass = 0;
|
int playersSpectating = 0;
|
||||||
const int numRequestsToHandle = (int)m_SpawnRequests.size();
|
const int numRequestsToHandle = (int)m_SpawnRequests.size();
|
||||||
for (auto it = m_SpawnRequests.begin(); it != m_SpawnRequests.end(); ++it) {
|
for (auto it = m_SpawnRequests.begin(); it != m_SpawnRequests.end(); ++it) {
|
||||||
// TODO: -1 Signifies no class picked, enum here later?
|
// TODO: -1 Signifies no class picked, or they are a spectator, enum here later?
|
||||||
// It is valid if they didn't pick class yet
|
// It is valid if they didn't pick class yet
|
||||||
// but don't spawn anything, goto next spawnrequest.
|
// but don't spawn anything, goto next spawnrequest.
|
||||||
if (it->Class == -1) {
|
if (it->Class == -1) {
|
||||||
++playersStillPickingClass;
|
++playersSpectating;
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
for (auto& cPlayerSpawn : *playerSpawns) {
|
for (auto& cPlayerSpawn : *playerSpawns) {
|
||||||
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
|
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
|
||||||
@@ -80,13 +80,6 @@ void PlayerSpawnSystem::Update(double dt)
|
|||||||
if (spawner.HasComponent("Team")) {
|
if (spawner.HasComponent("Team")) {
|
||||||
auto cSpawnerTeam = spawner["Team"];
|
auto cSpawnerTeam = spawner["Team"];
|
||||||
if ((int)cSpawnerTeam["Team"] != it->Team) {
|
if ((int)cSpawnerTeam["Team"] != it->Team) {
|
||||||
// It is valid if someone picks spectator
|
|
||||||
// but don't spawn anything, goto next spawnrequest.
|
|
||||||
if (it->Team == (int)cSpawnerTeam["Team"].Enum("Spectator")) {
|
|
||||||
++numHandledRequests;
|
|
||||||
it = m_SpawnRequests.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,9 +97,7 @@ void PlayerSpawnSystem::Update(double dt)
|
|||||||
e.Player = player;
|
e.Player = player;
|
||||||
e.Spawner = spawner;
|
e.Spawner = spawner;
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
Events::LockMouse lock;
|
++numSpawnedPlayers;
|
||||||
m_EventBroker->Publish(lock);
|
|
||||||
++numHandledRequests;
|
|
||||||
it = m_SpawnRequests.erase(it);
|
it = m_SpawnRequests.erase(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -114,11 +105,11 @@ void PlayerSpawnSystem::Update(double dt)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (numHandledRequests != numRequestsToHandle - playersStillPickingClass) {
|
if (numSpawnedPlayers != numRequestsToHandle - playersSpectating) {
|
||||||
LOG_DEBUG("%i players were supposed to be spawned or set as spectator, but only %i was handled.", numRequestsToHandle, numHandledRequests);
|
LOG_DEBUG("%i players were supposed to be spawned, but only %i was successfully.", numRequestsToHandle - playersSpectating, numSpawnedPlayers);
|
||||||
} else {
|
} else {
|
||||||
std::string dbg = numHandledRequests != 0 ? std::to_string(numHandledRequests) + " players were spawned or set as spectator. " : "";
|
std::string dbg = numSpawnedPlayers != 0 ? std::to_string(numSpawnedPlayers) + " players were spawned. " : "";
|
||||||
dbg += playersStillPickingClass != 0 ? std::to_string(playersStillPickingClass) + " players are still picking class and will be spawned later." : "";
|
dbg += playersSpectating != 0 ? std::to_string(playersSpectating) + " players are spectating/picking class. " : "";
|
||||||
LOG_DEBUG(dbg.c_str());
|
LOG_DEBUG(dbg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,10 +153,8 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
|
|||||||
// If player is in queue to spawn, then change their team affiliation or class in the request.
|
// If player is in queue to spawn, then change their team affiliation or class in the request.
|
||||||
if (e.Command == "PickTeam") {
|
if (e.Command == "PickTeam") {
|
||||||
iter->Team = (ComponentInfo::EnumType)e.Value;
|
iter->Team = (ComponentInfo::EnumType)e.Value;
|
||||||
LOG_DEBUG("old spawn request setting Team");
|
|
||||||
} else {
|
} else {
|
||||||
iter->Class = (ComponentInfo::EnumType)e.Value;
|
iter->Class = (ComponentInfo::EnumType)e.Value;
|
||||||
LOG_DEBUG("old spawn request setting Class");
|
|
||||||
}
|
}
|
||||||
} else if (m_PlayerEntities.count(e.PlayerID) == 0 || !m_PlayerEntities[e.PlayerID].Valid()) {
|
} else if (m_PlayerEntities.count(e.PlayerID) == 0 || !m_PlayerEntities[e.PlayerID].Valid()) {
|
||||||
// If player is not in queue to spawn, then create a spawn request,
|
// If player is not in queue to spawn, then create a spawn request,
|
||||||
@@ -175,13 +164,11 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
|
|||||||
if (e.Command == "PickTeam") {
|
if (e.Command == "PickTeam") {
|
||||||
req.Team = (ComponentInfo::EnumType)e.Value;
|
req.Team = (ComponentInfo::EnumType)e.Value;
|
||||||
req.Class = -1; // TODO: -1 Signifies no class picked, enum here later?
|
req.Class = -1; // TODO: -1 Signifies no class picked, enum here later?
|
||||||
LOG_DEBUG("new spawn request setting Team");
|
|
||||||
} else {
|
} else {
|
||||||
// Should never get here, since you should have picked a team before you ever get a chance to pick class.
|
// Should never get here, since you should have picked a team before you ever get a chance to pick class.
|
||||||
LOG_WARNING("Sequence error: Should not be able to pick class before team");
|
LOG_WARNING("Sequence error: Should not be able to pick class before team");
|
||||||
req.Team = 1; // TODO: 1 Signifies spectator, should probably have real enum here later.
|
req.Team = 1; // TODO: 1 Signifies spectator, should probably have real enum here later.
|
||||||
req.Class = (ComponentInfo::EnumType)e.Value;
|
req.Class = (ComponentInfo::EnumType)e.Value;
|
||||||
LOG_DEBUG("new spawn request setting Class");
|
|
||||||
}
|
}
|
||||||
m_SpawnRequests.push_back(req);
|
m_SpawnRequests.push_back(req);
|
||||||
} else {
|
} else {
|
||||||
@@ -217,6 +204,8 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
|||||||
Events::SetCamera e;
|
Events::SetCamera e;
|
||||||
e.CameraEntity = cameraEntity;
|
e.CameraEntity = cameraEntity;
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
|
Events::LockMouse lock;
|
||||||
|
m_EventBroker->Publish(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: Set the player model color to team color
|
// HACK: Set the player model color to team color
|
||||||
|
|||||||
Reference in New Issue
Block a user