Add Tile Functions

This commit is contained in:
2025-03-27 23:35:52 -04:00
parent 1a09845770
commit 6e9224ead6
3 changed files with 13 additions and 11 deletions

View File

@@ -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<std::string, TileTiccFunc> ticc_funcs;
static std::map<std::string, TileTiccFunc> 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<std::string> tags;
bool gravity;
};
/*
*

View File

@@ -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);

View File

@@ -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);
}
}
}