Merge remote-tracking branch 'origin/Networking' into Networking
# Conflicts: # include/Engine/Network/NetworkDefinitions.h # include/Game/Game.h # src/Engine/Network/Client.cpp # src/Game/Game.cpp
This commit is contained in:
+43
-3
@@ -1,11 +1,11 @@
|
||||
#include "Game.h"
|
||||
#include "HardcodedTestWorld.h"
|
||||
|
||||
Game::Game(int argc, char* argv[])
|
||||
{
|
||||
ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
ResourceManager::RegisterType<Model>("Model");
|
||||
ResourceManager::RegisterType<Texture>("Texture");
|
||||
ResourceManager::RegisterType<EntityXMLFile>("EntityXMLFile");
|
||||
|
||||
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1));
|
||||
@@ -35,14 +35,24 @@ Game::Game(int argc, char* argv[])
|
||||
m_FrameStack->Width = m_Renderer->Resolution().Width;
|
||||
m_FrameStack->Height = m_Renderer->Resolution().Height;
|
||||
|
||||
// Create a TEST WORLD
|
||||
m_World = new HardcodedTestWorld();
|
||||
// Create a world
|
||||
m_World = new World();
|
||||
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
|
||||
if (!mapToLoad.empty()) {
|
||||
ResourceManager::Load<EntityXMLFile>(mapToLoad)->PopulateWorld(m_World);
|
||||
}
|
||||
|
||||
// Create system pipeline
|
||||
m_SystemPipeline = new SystemPipeline(m_EventBroker);
|
||||
m_SystemPipeline->AddSystem<RaptorCopterSystem>();
|
||||
|
||||
|
||||
// Invoke network
|
||||
if(m_Config->Get<bool>("Networking.StartNetwork", false) == true)
|
||||
boost::thread workerThread(&Game::NetworkFunction, this);
|
||||
m_LastTime = glfwGetTime();
|
||||
|
||||
testIntialize();
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
@@ -65,9 +75,13 @@ void Game::Tick()
|
||||
m_InputManager->Update(dt);
|
||||
m_EventBroker->Swap();
|
||||
|
||||
// Iterate through systems and update world!
|
||||
m_SystemPipeline->Update(m_World, dt);
|
||||
// DO SYSTEM SHIT HERE
|
||||
m_EventBroker->Process<Client>();
|
||||
testTick(dt);
|
||||
|
||||
m_RenderQueueFactory->Update(m_World);
|
||||
m_Renderer->Update(dt);
|
||||
m_RenderQueueFactory->Update(m_World);
|
||||
m_Renderer->Draw(m_RenderQueueFactory->RenderQueues());
|
||||
@@ -78,6 +92,32 @@ void Game::Tick()
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
|
||||
bool Game::testOnKeyUp(const Events::KeyUp& e)
|
||||
{
|
||||
if (e.KeyCode == GLFW_KEY_R) {
|
||||
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
|
||||
if (!mapToLoad.empty()) {
|
||||
delete m_World;
|
||||
m_World = new World();
|
||||
ResourceManager::Release("EntityXMLFile", mapToLoad);
|
||||
ResourceManager::Load<EntityXMLFile>(mapToLoad)->PopulateWorld(m_World);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Game::testIntialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Game::testOnKeyUp);
|
||||
}
|
||||
|
||||
void Game::testTick(double dt)
|
||||
{
|
||||
m_EventBroker->Process<Game>();
|
||||
}
|
||||
|
||||
void Game::NetworkFunction()
|
||||
{
|
||||
std::string inputMessage;
|
||||
|
||||
Reference in New Issue
Block a user