diff --git a/src/saland/GameRegion.cpp b/src/saland/GameRegion.cpp index 6fec626..a9e32b7 100644 --- a/src/saland/GameRegion.cpp +++ b/src/saland/GameRegion.cpp @@ -240,28 +240,37 @@ static std::vector> generateLakePattern() { return pattern; } + void GameRegion::ProcessRegionFirstTimeEnter(World& world) { if (world.tm.properties["type"].value == "forrest") { { - // Add a small lake - int x = (rand()%(world.tm.width-LAKE_WIDTH)); - int y = (rand()%(world.tm.height-LAKE_HEIGHT)); - const auto& pattern = generateLakePattern(); - for (size_t i=0; i < LAKE_WIDTH; ++i) { - for (size_t j=0; j < LAKE_HEIGHT; ++j) { - if (pattern[i][j] == 0) { - continue; - } - int layer_number = world.blockingLayer; - uint32_t tile = 28; - sago::tiled::setTileOnLayerNumber(world.tm, layer_number, x+i, y+j, tile); - liqudHandler["water"].updateFirstTile(world.tm, x+i, y+j); - } - } - } + CreateLake(world); + } } } +void GameRegion::CreateLake(World& world) +{ + // Add a small lake + int x = (rand() % (world.tm.width - LAKE_WIDTH)); + int y = (rand() % (world.tm.height - LAKE_HEIGHT)); + const auto &pattern = generateLakePattern(); + for (size_t i = 0; i < LAKE_WIDTH; ++i) + { + for (size_t j = 0; j < LAKE_HEIGHT; ++j) + { + if (pattern[i][j] == 0) + { + continue; + } + int layer_number = world.blockingLayer; + uint32_t tile = 28; + sago::tiled::setTileOnLayerNumber(world.tm, layer_number, x + i, y + j, tile); + liqudHandler["water"].updateFirstTile(world.tm, x + i, y + j); + } + } +} + void GameRegion::ProcessRegionEnter(World& world) { if (world.tm.properties["type"].value == "forrest") { std::cout << "Forrest (or start) region\n"; diff --git a/src/saland/GameRegion.hpp b/src/saland/GameRegion.hpp index 0919617..b215dcb 100644 --- a/src/saland/GameRegion.hpp +++ b/src/saland/GameRegion.hpp @@ -66,6 +66,7 @@ public: void SpawnItem(const ItemDef& def, float destX, float destY) ; void SpawnPrefab(const Prefab& prefab, int destX, int destY); void ProcessRegionFirstTimeEnter(World& world); + void CreateLake(World& world); void ProcessRegionEnter(World& world); private: int region_x = 0;