Refactoring. Client and server has Update Loop that runs before any game logic each frame.

This commit is contained in:
stiffly
2015-12-15 14:53:56 +01:00
parent 0a8a9e5099
commit 478c692315
8 changed files with 88 additions and 57 deletions
+5 -2
View File
@@ -89,6 +89,9 @@ void Game::Tick()
m_InputProxy->Process();
m_EventBroker->Swap();
// Update network
m_IsClient ? m_Client.Update() : m_Server.Update();
// Iterate through systems and update world!
m_SystemPipeline->Update(m_World, dt);
debugTick(dt);
@@ -135,11 +138,11 @@ void Game::NetworkFunction()
std::cout << "Start client or server? (c/s)" << std::endl;
std::cin >> inputMessage;
if (inputMessage == "c" || inputMessage == "C") {
Client m_Client;
m_IsClient = true;
m_Client.Start(m_World, m_EventBroker);
}
if (inputMessage == "s" || inputMessage == "S") {
Server m_Server;
m_IsClient = false;
m_Server.Start(m_World, m_EventBroker);
}
}
+14 -14
View File
@@ -2,20 +2,20 @@
void PlayerSystem::UpdateComponent(World * world, ComponentWrapper & player, double dt)
{
//if (player["Forward"]) {
// ((glm::vec3&)player["Velocity"]).z = m_Speed * float(dt) * -1;
//}
//if (player["Left"]) {
// ((glm::vec3&)player["Velocity"]).x = m_Speed * float(dt) * -1;
//}
//if (player["Back"]) {
// ((glm::vec3&)player["Velocity"]).z = m_Speed * float(dt);
//}
//if (player["Right"]) {
// ((glm::vec3&)player["Velocity"]).x = m_Speed * float(dt);
//}
//ComponentWrapper& transform = world->GetComponent(player.EntityID, "Transform");
//(glm::vec3&)transform["Position"] += (glm::vec3)player["Velocity"];
if (player["Forward"]) {
((glm::vec3&)player["Velocity"]).z = m_Speed * float(dt) * -1;
}
if (player["Left"]) {
((glm::vec3&)player["Velocity"]).x = m_Speed * float(dt) * -1;
}
if (player["Back"]) {
((glm::vec3&)player["Velocity"]).z = m_Speed * float(dt);
}
if (player["Right"]) {
((glm::vec3&)player["Velocity"]).x = m_Speed * float(dt);
}
ComponentWrapper& transform = world->GetComponent(player.EntityID, "Transform");
(glm::vec3&)transform["Position"] += (glm::vec3)player["Velocity"];
//m_EventBroker->Process<PlayerSystem>();