change WorldRenderer to class
This commit is contained in:
@@ -16,6 +16,8 @@ ClientGame::ClientGame(protocol::PacketDispatcher* dispatcher): protocol::Packet
|
||||
GetDispatcher()->RegisterHandler(protocol::PacketType::UpdateLobbyTime, this);
|
||||
GetDispatcher()->RegisterHandler(protocol::PacketType::UpdateGameState, this);
|
||||
GetDispatcher()->RegisterHandler(protocol::PacketType::UpdateMoney, this);
|
||||
GetDispatcher()->RegisterHandler(protocol::PacketType::Disconnect, this);
|
||||
GetDispatcher()->RegisterHandler(protocol::PacketType::WorldData, this);
|
||||
}
|
||||
|
||||
ClientGame::~ClientGame(){
|
||||
@@ -24,6 +26,7 @@ ClientGame::~ClientGame(){
|
||||
|
||||
void ClientGame::tick(std::uint64_t delta){
|
||||
game::Game::tick(delta);
|
||||
m_WorldRenderer.update();
|
||||
if (m_GameState == game::GameState::Lobby && m_Players.size() >= 2){
|
||||
m_LobbyTime -= delta;
|
||||
}
|
||||
@@ -90,5 +93,22 @@ void ClientGame::HandlePacket(protocol::UpdateMoneyPacket* packet){
|
||||
m_Player->setGold(packet->getGold());
|
||||
}
|
||||
|
||||
void ClientGame::HandlePacket(protocol::DisconnectPacket* packet){
|
||||
m_GameState = game::GameState::Disconnected;
|
||||
}
|
||||
|
||||
void ClientGame::HandlePacket(protocol::WorldDataPacket* packet){
|
||||
m_WorldRenderer.loadModels();
|
||||
// set cam pos to player spawn
|
||||
const game::Spawn& spawn = m_World->getTeam(m_Player->getTeamColor()).getSpawn();
|
||||
m_WorldRenderer.setCamPos(spawn.x, spawn.y);
|
||||
}
|
||||
|
||||
void ClientGame::renderWorld(){
|
||||
if(m_GameState == game::GameState::Game || m_GameState == game::GameState::EndGame){
|
||||
m_WorldRenderer.render();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
} // namespace td
|
||||
|
||||
Reference in New Issue
Block a user