Added a get_layer() helper method to the LayeredTileMap.

This commit is contained in:
Relintai 2024-04-06 21:03:59 +02:00
parent fd5be3f26c
commit aa82d20e4b
2 changed files with 9 additions and 0 deletions

View File

@ -447,6 +447,12 @@ void LayeredTileMap::remove_layer(int p_layer) {
update_configuration_warning(); 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) { void LayeredTileMap::set_layer_name(int p_layer, String p_name) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_name, 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("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("move_layer", "layer", "to_position"), &LayeredTileMap::move_layer);
ClassDB::bind_method(D_METHOD("remove_layer", "layer"), &LayeredTileMap::remove_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("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("get_layer_name", "layer"), &LayeredTileMap::get_layer_name);
ClassDB::bind_method(D_METHOD("set_layer_enabled", "layer", "enabled"), &LayeredTileMap::set_layer_enabled); ClassDB::bind_method(D_METHOD("set_layer_enabled", "layer", "enabled"), &LayeredTileMap::set_layer_enabled);

View File

@ -142,6 +142,7 @@ public:
void add_layer(int p_to_pos); void add_layer(int p_to_pos);
void move_layer(int p_layer, int p_to_pos); void move_layer(int p_layer, int p_to_pos);
void remove_layer(int p_layer); void remove_layer(int p_layer);
LayeredTileMapLayer *get_layer(const int p_layer) const;
void set_layer_name(int p_layer, String p_name); void set_layer_name(int p_layer, String p_name);
String get_layer_name(int p_layer) const; String get_layer_name(int p_layer) const;