This commit is contained in:
2025-07-16 00:32:40 +02:00
parent d1690192db
commit aaf76a3ff0
41 changed files with 2963 additions and 599 deletions

59
src/td/game/World.cpp Normal file
View File

@@ -0,0 +1,59 @@
#include <td/game/World.h>
namespace td {
namespace game {
World::World() : m_Teams{Team{TeamColor::Red}, Team{TeamColor::Blue}} {
}
const Color* World::GetTileColor(TilePtr tile) const {
switch (tile->GetType()) {
case TileType::Tower: {
TowerTile* towerTile = dynamic_cast<TowerTile*>(tile.get());
return &m_TowerPlacePalette[towerTile->color_palette_ref];
}
case TileType::Walk: {
return &m_WalkablePalette;
}
case TileType::Decoration: {
DecorationTile* towerTile = dynamic_cast<DecorationTile*>(tile.get());
return &m_DecorationPalette[towerTile->color_palette_ref];
break;
}
default: {
return nullptr;
}
}
return nullptr;
}
bool World::LoadMap(const protocol::pdata::WorldHeader& a_WorldHeader) {
m_TowerPlacePalette = a_WorldHeader.m_TowerPlacePalette;
m_WalkablePalette = a_WorldHeader.m_WalkablePalette;
m_DecorationPalette = a_WorldHeader.m_DecorationPalette;
m_Background = a_WorldHeader.m_Background;
GetRedTeam().GetSpawn() = a_WorldHeader.m_RedSpawn;
GetBlueTeam().GetSpawn() = a_WorldHeader.m_BlueSpawn;
m_SpawnColorPalette = a_WorldHeader.m_SpawnColorPalette;
GetRedTeam().GetCastle() = a_WorldHeader.m_RedCastle;
GetRedTeam().GetCastle().SetTeam(&GetRedTeam());
GetBlueTeam().GetCastle() = a_WorldHeader.m_BlueCastle;
GetBlueTeam().GetCastle().SetTeam(&GetBlueTeam());
m_TilePalette = a_WorldHeader.m_TilePalette;
return true;
}
bool World::LoadMap(const protocol::pdata::WorldData& a_WorldData) {
m_Chunks = a_WorldData.m_Chunks;
return true;
}
} // namespace game
} // namespace td