Refactoring. Client and server has Update Loop that runs before any game logic each frame.
This commit is contained in:
+5
-2
@@ -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
@@ -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>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user