From aa82d20e4bcf04df125b520b1b951dfd302981b2 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 6 Apr 2024 21:03:59 +0200 Subject: [PATCH] Added a get_layer() helper method to the LayeredTileMap. --- modules/layered_tile_map/layered_tile_map.cpp | 8 ++++++++ modules/layered_tile_map/layered_tile_map.h | 1 + 2 files changed, 9 insertions(+) diff --git a/modules/layered_tile_map/layered_tile_map.cpp b/modules/layered_tile_map/layered_tile_map.cpp index 77bdf48bb..bffda6a8a 100644 --- a/modules/layered_tile_map/layered_tile_map.cpp +++ b/modules/layered_tile_map/layered_tile_map.cpp @@ -447,6 +447,12 @@ void LayeredTileMap::remove_layer(int p_layer) { update_configuration_warning(); } +LayeredTileMapLayer *LayeredTileMap::get_layer(const int p_layer) const { + ERR_FAIL_INDEX_V(p_layer, (int)layers.size(), NULL); + + return layers[p_layer]; +} + void LayeredTileMap::set_layer_name(int p_layer, String p_name) { TILEMAP_CALL_FOR_LAYER(p_layer, set_name, p_name); } @@ -1277,6 +1283,8 @@ void LayeredTileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("add_layer", "to_position"), &LayeredTileMap::add_layer); ClassDB::bind_method(D_METHOD("move_layer", "layer", "to_position"), &LayeredTileMap::move_layer); ClassDB::bind_method(D_METHOD("remove_layer", "layer"), &LayeredTileMap::remove_layer); + ClassDB::bind_method(D_METHOD("get_layer", "layer"), &LayeredTileMap::get_layer); + ClassDB::bind_method(D_METHOD("set_layer_name", "layer", "name"), &LayeredTileMap::set_layer_name); ClassDB::bind_method(D_METHOD("get_layer_name", "layer"), &LayeredTileMap::get_layer_name); ClassDB::bind_method(D_METHOD("set_layer_enabled", "layer", "enabled"), &LayeredTileMap::set_layer_enabled); diff --git a/modules/layered_tile_map/layered_tile_map.h b/modules/layered_tile_map/layered_tile_map.h index fe79e5637..73cefad75 100644 --- a/modules/layered_tile_map/layered_tile_map.h +++ b/modules/layered_tile_map/layered_tile_map.h @@ -142,6 +142,7 @@ public: void add_layer(int p_to_pos); void move_layer(int p_layer, int p_to_pos); void remove_layer(int p_layer); + LayeredTileMapLayer *get_layer(const int p_layer) const; void set_layer_name(int p_layer, String p_name); String get_layer_name(int p_layer) const;