diff --git a/Core/include/Core/Tile.hpp b/Core/include/Core/Tile.hpp index 4b2dabd..8ddbecb 100644 --- a/Core/include/Core/Tile.hpp +++ b/Core/include/Core/Tile.hpp @@ -25,8 +25,8 @@ namespace CaveGame::Core { void SandGravTiccFunc(const Tile& data, ITileMap* world, int x, int y); void LiquidSettleTiccFunc(const Tile& data, ITileMap* world, int x, int y); - static std::map ticc_funcs; + static std::map ticc_funcs; struct Tile { std::string mnemonic_id; @@ -41,6 +41,8 @@ namespace CaveGame::Core { Color4 color; TileTiccFunc forced_ticc_func; TileTiccFunc random_ticc_func; + std::vector tags; + bool gravity; }; /* * diff --git a/Core/src/Core/Tile.cpp b/Core/src/Core/Tile.cpp index 2039417..2cc3aee 100644 --- a/Core/src/Core/Tile.cpp +++ b/Core/src/Core/Tile.cpp @@ -291,7 +291,6 @@ namespace CaveGame::Core { static TileID water = Tiles()["water"].numeric_id; static TileID sand = data.numeric_id; - TileID below = world->GetTile(x, y + 1); if (below == air || below == water) { world->SwapTile(x, y, x, y+1); diff --git a/Core/src/Core/World.cpp b/Core/src/Core/World.cpp index 3affef9..3f02c49 100644 --- a/Core/src/Core/World.cpp +++ b/Core/src/Core/World.cpp @@ -447,7 +447,7 @@ namespace CaveGame::Core { if (chunk->tiles_with_random_tick_count < 0) std::cout << "The number of tiles with random tick in the chunk is negative?" << std::endl; - Tile* tile = nullptr; + Tile tile; int max_tries = RandomTileTickCoefficient*5; int max_successes = RandomTileTickCoefficient; @@ -463,6 +463,15 @@ namespace CaveGame::Core { TileID at = chunk->GetTile(x, y); + if (at == 0) + continue; + + tile = Tiles().GetByNumericID(at); + + if (tile.does_random_ticc) + tile.random_ticc_func(tile, this, wx, wy); + + //if (at == TileID::AIR) // continue; @@ -494,16 +503,8 @@ namespace CaveGame::Core { tile = Tiles().GetByNumericID(at); - if (tile.does_forced_ticc) tile.forced_ticc_func(tile, this, wx, wy); - //if (at == TileID::AIR) - // continue; - - //tile = GetByNumeric(at); - //if (tile != nullptr) - // if (tile->DoesForcedTicc()) - // tile->ForcedTicc(this, 0, wx, wy); } } }