Add Tile Functions
This commit is contained in:
@@ -25,8 +25,8 @@ namespace CaveGame::Core {
|
|||||||
void SandGravTiccFunc(const Tile& data, ITileMap* world, int x, int y);
|
void SandGravTiccFunc(const Tile& data, ITileMap* world, int x, int y);
|
||||||
void LiquidSettleTiccFunc(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 {
|
struct Tile {
|
||||||
std::string mnemonic_id;
|
std::string mnemonic_id;
|
||||||
@@ -41,6 +41,8 @@ namespace CaveGame::Core {
|
|||||||
Color4 color;
|
Color4 color;
|
||||||
TileTiccFunc forced_ticc_func;
|
TileTiccFunc forced_ticc_func;
|
||||||
TileTiccFunc random_ticc_func;
|
TileTiccFunc random_ticc_func;
|
||||||
|
std::vector<std::string> tags;
|
||||||
|
bool gravity;
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@@ -291,7 +291,6 @@ namespace CaveGame::Core {
|
|||||||
static TileID water = Tiles()["water"].numeric_id;
|
static TileID water = Tiles()["water"].numeric_id;
|
||||||
static TileID sand = data.numeric_id;
|
static TileID sand = data.numeric_id;
|
||||||
|
|
||||||
|
|
||||||
TileID below = world->GetTile(x, y + 1);
|
TileID below = world->GetTile(x, y + 1);
|
||||||
if (below == air || below == water) {
|
if (below == air || below == water) {
|
||||||
world->SwapTile(x, y, x, y+1);
|
world->SwapTile(x, y, x, y+1);
|
||||||
|
@@ -447,7 +447,7 @@ namespace CaveGame::Core {
|
|||||||
if (chunk->tiles_with_random_tick_count < 0)
|
if (chunk->tiles_with_random_tick_count < 0)
|
||||||
std::cout << "The number of tiles with random tick in the chunk is negative?" << std::endl;
|
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_tries = RandomTileTickCoefficient*5;
|
||||||
int max_successes = RandomTileTickCoefficient;
|
int max_successes = RandomTileTickCoefficient;
|
||||||
@@ -463,6 +463,15 @@ namespace CaveGame::Core {
|
|||||||
|
|
||||||
TileID at = chunk->GetTile(x, y);
|
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)
|
//if (at == TileID::AIR)
|
||||||
// continue;
|
// continue;
|
||||||
|
|
||||||
@@ -494,16 +503,8 @@ namespace CaveGame::Core {
|
|||||||
|
|
||||||
tile = Tiles().GetByNumericID(at);
|
tile = Tiles().GetByNumericID(at);
|
||||||
|
|
||||||
|
|
||||||
if (tile.does_forced_ticc)
|
if (tile.does_forced_ticc)
|
||||||
tile.forced_ticc_func(tile, this, wx, wy);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user