change WorldRenderer to class
This commit is contained in:
@@ -42,6 +42,9 @@ void Client::tick(std::uint64_t delta){
|
||||
}
|
||||
}
|
||||
|
||||
void Client::render(){
|
||||
m_Game.renderWorld();
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
} // namespace td
|
||||
|
||||
@@ -42,7 +42,6 @@ bool ClientConnexion::updateSocket(){
|
||||
void ClientConnexion::HandlePacket(protocol::DisconnectPacket* packet){
|
||||
m_DisconnectReason = packet->getReason();
|
||||
closeConnection();
|
||||
render::WorldRenderer::destroy();
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,7 +18,6 @@ void WorldClient::HandlePacket(protocol::WorldBeginDataPacket* packet){
|
||||
|
||||
void WorldClient::HandlePacket(protocol::WorldDataPacket* packet){
|
||||
loadMap(packet);
|
||||
render::WorldRenderer::init(this);
|
||||
}
|
||||
|
||||
void WorldClient::HandlePacket(protocol::SpawnMobPacket* packet){
|
||||
|
||||
@@ -14,6 +14,8 @@ void ServerGame::tick(std::uint64_t delta){
|
||||
}
|
||||
|
||||
void ServerGame::startGame(){
|
||||
balanceTeams();
|
||||
|
||||
protocol::WorldBeginDataPacket headerMapData(m_World);
|
||||
m_Server->broadcastPacket(&headerMapData);
|
||||
|
||||
@@ -22,8 +24,6 @@ void ServerGame::startGame(){
|
||||
|
||||
m_GameState = game::GameState::Game;
|
||||
|
||||
balanceTeams();
|
||||
|
||||
m_ServerWorld.spawnMobs(game::MobType::Zombie, 1, 0, 12);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user