diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp index f6cd1db..1ebc756 100644 --- a/src/saland/Game.cpp +++ b/src/saland/Game.cpp @@ -440,8 +440,8 @@ void Game::ProcessInput(const SDL_Event& event, bool& processed) { int layer_number = 2; // Do not hardcode uint32_t tile = data->drawTile; sago::tiled::setTileOnLayerNumber(data->gameRegion.world.tm, layer_number, tile_x, tile_y, tile); - data->gameRegion.waterHandler.updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); - data->gameRegion.lavaHandler.updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); + data->gameRegion.liqudHandler["water"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); + data->gameRegion.liqudHandler["lava"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); data->gameRegion.world.init_physics(data->gameRegion.physicsBox); } if (event.key.keysym.sym == globalData.playerControls.block_delete @@ -450,8 +450,8 @@ void Game::ProcessInput(const SDL_Event& event, bool& processed) { int layer_number = 2; // Do not hardcode uint32_t tile = 0; sago::tiled::setTileOnLayerNumber(data->gameRegion.world.tm, layer_number, tile_x, tile_y, tile); - data->gameRegion.waterHandler.updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); - data->gameRegion.lavaHandler.updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); + data->gameRegion.liqudHandler["water"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); + data->gameRegion.liqudHandler["lava"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); data->gameRegion.world.init_physics(data->gameRegion.physicsBox); } if (event.key.keysym.sym == SDLK_1 || event.key.keysym.sym == SDLK_KP_1) { @@ -681,8 +681,8 @@ void Game::Update() { && !(data->gameRegion.world.tile_protected(tile_x, tile_y)) ) { int layer_number = 2; // Do not hardcode sago::tiled::setTileOnLayerNumber(data->gameRegion.world.tm, layer_number, tile_x, tile_y, tile); - data->gameRegion.waterHandler.updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); - data->gameRegion.lavaHandler.updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); + data->gameRegion.liqudHandler["water"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); + data->gameRegion.liqudHandler["lava"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); data->gameRegion.world.init_physics(data->gameRegion.physicsBox); } } @@ -697,8 +697,8 @@ void Game::Update() { int layer_number = 2; // Do not hardcode uint32_t tile = 0; sago::tiled::setTileOnLayerNumber(data->gameRegion.world.tm, layer_number, tile_x, tile_y, tile); - data->gameRegion.waterHandler.updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); - data->gameRegion.lavaHandler.updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); + data->gameRegion.liqudHandler["water"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); + data->gameRegion.liqudHandler["lava"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y); data->gameRegion.world.init_physics(data->gameRegion.physicsBox); } } diff --git a/src/saland/GameRegion.cpp b/src/saland/GameRegion.cpp index 87782bb..2c3f646 100644 --- a/src/saland/GameRegion.cpp +++ b/src/saland/GameRegion.cpp @@ -156,11 +156,12 @@ void GameRegion::Init(int x, int y, const std::string& worldName, bool forceRese physicsBox.reset(new b2World(gravity)); world.managed_bodies.clear(); world.init(physicsBox, loadMap); - waterHandler.blockingLayer = world.blockingLayer; - waterHandler.blockingLayer_overlay_1 = world.blockingLayer_overlay_1; - lavaHandler.blockingLayer = world.blockingLayer; - lavaHandler.blockingLayer_overlay_1 = world.blockingLayer_overlay_1; - lavaHandler.setupTiles(16); + + liqudHandler["water"].blockingLayer = world.blockingLayer; + liqudHandler["water"].blockingLayer_overlay_1 = world.blockingLayer_overlay_1; + liqudHandler["lava"].blockingLayer = world.blockingLayer; + liqudHandler["lava"].blockingLayer_overlay_1 = world.blockingLayer_overlay_1; + liqudHandler["lava"].setupTiles(16); diff --git a/src/saland/GameRegion.hpp b/src/saland/GameRegion.hpp index 6909f3d..efed9a4 100644 --- a/src/saland/GameRegion.hpp +++ b/src/saland/GameRegion.hpp @@ -46,8 +46,7 @@ public: std::shared_ptr physicsBox; void SaveRegion(); World world; - WaterHandler waterHandler; - WaterHandler lavaHandler; + std::map liqudHandler; uint32_t outerTile = 485; int GetRegionX() const { return region_x;