refactor: format code
This commit is contained in:
@@ -7,15 +7,15 @@
|
||||
#include "Mobs.h"
|
||||
#include "Team.h"
|
||||
|
||||
namespace td{
|
||||
namespace game{
|
||||
typedef std::pair<std::int16_t, std::int16_t> ChunkCoord;
|
||||
namespace td {
|
||||
namespace game {
|
||||
typedef std::pair<std::int16_t, std::int16_t> ChunkCoord;
|
||||
}
|
||||
}
|
||||
namespace std{
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<td::game::ChunkCoord>{
|
||||
std::size_t operator()(const td::game::ChunkCoord& key) const{
|
||||
struct hash<td::game::ChunkCoord> {
|
||||
std::size_t operator()(const td::game::ChunkCoord& key) const {
|
||||
// Compute individual hash values for first,
|
||||
// second and third and combine them using XOR
|
||||
// and bit shifting:
|
||||
@@ -37,7 +37,7 @@ namespace game {
|
||||
|
||||
class Game;
|
||||
|
||||
enum class TileType : std::uint8_t{
|
||||
enum class TileType : std::uint8_t {
|
||||
None = 0,
|
||||
Tower,
|
||||
Walk,
|
||||
@@ -49,31 +49,31 @@ enum class TileType : std::uint8_t{
|
||||
Ice,*/
|
||||
};
|
||||
|
||||
struct Color{
|
||||
struct Color {
|
||||
std::uint8_t r, g, b;
|
||||
};
|
||||
|
||||
struct Tile{
|
||||
struct Tile {
|
||||
virtual TileType getType() const = 0;
|
||||
};
|
||||
|
||||
struct TowerTile : Tile{
|
||||
struct TowerTile : Tile {
|
||||
std::uint8_t color_palette_ref;
|
||||
TeamColor team_owner;
|
||||
|
||||
virtual TileType getType() const{ return TileType::Tower; }
|
||||
virtual TileType getType() const { return TileType::Tower; }
|
||||
};
|
||||
|
||||
struct WalkableTile : Tile{
|
||||
struct WalkableTile : Tile {
|
||||
Direction direction;
|
||||
|
||||
virtual TileType getType() const{ return TileType::Walk; }
|
||||
virtual TileType getType() const { return TileType::Walk; }
|
||||
};
|
||||
|
||||
struct DecorationTile : Tile{
|
||||
struct DecorationTile : Tile {
|
||||
std::uint16_t color_palette_ref;
|
||||
|
||||
virtual TileType getType() const{ return TileType::Decoration; }
|
||||
virtual TileType getType() const { return TileType::Decoration; }
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Tile> TilePtr;
|
||||
@@ -85,15 +85,15 @@ typedef std::array<std::uint16_t, 32 * 32> ChunkData;
|
||||
typedef std::uint32_t TileIndex;
|
||||
|
||||
//32 x 32 area
|
||||
struct Chunk{
|
||||
enum{ ChunkWidth = 32, ChunkHeight = 32, ChunkSize = ChunkWidth * ChunkHeight };
|
||||
struct Chunk {
|
||||
enum { ChunkWidth = 32, ChunkHeight = 32, ChunkSize = ChunkWidth * ChunkHeight };
|
||||
// stores index of tile palette
|
||||
ChunkData tiles{0};
|
||||
ChunkData tiles{ 0 };
|
||||
ChunkPalette palette;
|
||||
|
||||
TileIndex getTileIndex(std::uint16_t tileNumber) const{
|
||||
TileIndex getTileIndex(std::uint16_t tileNumber) const {
|
||||
TileIndex chunkPaletteIndex = tiles.at(tileNumber);
|
||||
if(chunkPaletteIndex == 0) // index 0 means empty tile index 1 = first tile
|
||||
if (chunkPaletteIndex == 0) // index 0 means empty tile index 1 = first tile
|
||||
return 0;
|
||||
return palette.at(chunkPaletteIndex);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ typedef std::vector<MobPtr> MobList;
|
||||
typedef std::array<Color, 2> SpawnColorPalette;
|
||||
|
||||
|
||||
class World{
|
||||
class World {
|
||||
protected:
|
||||
TowerTileColorPalette m_TowerPlacePalette;
|
||||
Color m_WalkablePalette;
|
||||
@@ -123,7 +123,7 @@ protected:
|
||||
TilePalette m_TilePalette;
|
||||
|
||||
MobList m_Mobs;
|
||||
|
||||
|
||||
Game* m_Game;
|
||||
public:
|
||||
World(Game* game);
|
||||
@@ -140,25 +140,25 @@ public:
|
||||
|
||||
TilePtr getTile(std::int32_t x, std::int32_t y);
|
||||
|
||||
const TowerTileColorPalette& getTowerTileColorPalette() const{ return m_TowerPlacePalette; }
|
||||
const Color& getWalkableTileColor() const{ return m_WalkablePalette; }
|
||||
const std::vector<Color>& getDecorationPalette() const{ return m_DecorationPalette; }
|
||||
const TowerTileColorPalette& getTowerTileColorPalette() const { return m_TowerPlacePalette; }
|
||||
const Color& getWalkableTileColor() const { return m_WalkablePalette; }
|
||||
const std::vector<Color>& getDecorationPalette() const { return m_DecorationPalette; }
|
||||
|
||||
const TilePalette& getTilePalette() const{ return m_TilePalette; }
|
||||
const TilePalette& getTilePalette() const { return m_TilePalette; }
|
||||
|
||||
TilePtr getTilePtr(TileIndex index) const{
|
||||
if(index == 0)
|
||||
TilePtr getTilePtr(TileIndex index) const {
|
||||
if (index == 0)
|
||||
return nullptr;
|
||||
return m_TilePalette.at(index - 1);
|
||||
}
|
||||
|
||||
const std::unordered_map<ChunkCoord, ChunkPtr>& getChunks() const{ return m_Chunks; }
|
||||
const std::unordered_map<ChunkCoord, ChunkPtr>& getChunks() const { return m_Chunks; }
|
||||
|
||||
const Color& getSpawnColor(TeamColor color) const{ return m_SpawnColorPalette[(std::size_t) color]; }
|
||||
const SpawnColorPalette& getSpawnColors() const{ return m_SpawnColorPalette; }
|
||||
const Color& getSpawnColor(TeamColor color) const { return m_SpawnColorPalette[(std::size_t)color]; }
|
||||
const SpawnColorPalette& getSpawnColors() const { return m_SpawnColorPalette; }
|
||||
|
||||
const MobList& getMobList() const{ return m_Mobs; }
|
||||
MobList& getMobList(){ return m_Mobs; }
|
||||
const MobList& getMobList() const { return m_Mobs; }
|
||||
MobList& getMobList() { return m_Mobs; }
|
||||
|
||||
const Color* getTileColor(TilePtr tile) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user