From 22f528a56a626d1e44a818b4f7fb7e66c647b6db Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 11 Dec 2021 19:13:51 +0100 Subject: [PATCH] Fix more errors. --- rtile_map.cpp | 18 +++++++++++++++--- rtile_map.h | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/rtile_map.cpp b/rtile_map.cpp index 243b6ae..6026408 100644 --- a/rtile_map.cpp +++ b/rtile_map.cpp @@ -727,8 +727,14 @@ RTileMap::VisibilityMode RTileMap::get_navigation_visibility_mode() { return navigation_visibility_mode; } +bool RTileMap::is_y_sort_enabled() const { + return _y_sort_enabled; +} + void RTileMap::set_y_sort_enabled(bool p_enable) { - Node2D::set_y_sort_enabled(p_enable); + _y_sort_enabled = p_enable; + + //Node2D::set_y_sort_enabled(p_enable); _clear_internals(); _recreate_internals(); emit_signal("changed"); @@ -1360,10 +1366,10 @@ void RTileMap::draw_tile(RID p_canvas_item, Vector2i p_position, const Ref= 0) { Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, p_frame); - tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, p_tile_set->is_uv_clipping()); + tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, Ref(), p_tile_set->is_uv_clipping()); } else if (atlas_source->get_tile_animation_frames_count(p_atlas_coords) == 1) { Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, 0); - tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, p_tile_set->is_uv_clipping()); + tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, Ref(), p_tile_set->is_uv_clipping()); } else { real_t speed = atlas_source->get_tile_animation_speed(p_atlas_coords); real_t animation_duration = atlas_source->get_tile_animation_total_duration(p_atlas_coords) / speed; @@ -3646,6 +3652,10 @@ void RTileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_layer_z_index", "layer", "z_index"), &RTileMap::set_layer_z_index); ClassDB::bind_method(D_METHOD("get_layer_z_index", "layer"), &RTileMap::get_layer_z_index); + ClassDB::bind_method(D_METHOD("is_y_sort_enabled"), &RTileMap::is_y_sort_enabled); + ClassDB::bind_method(D_METHOD("set_y_sort_enabled", "p_enable"), &RTileMap::set_y_sort_enabled); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "y_sort_enabled"), "set_y_sort_enabled", "is_y_sort_enabled"); + ClassDB::bind_method(D_METHOD("set_collision_animatable", "enabled"), &RTileMap::set_collision_animatable); ClassDB::bind_method(D_METHOD("is_collision_animatable"), &RTileMap::is_collision_animatable); ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "collision_visibility_mode"), &RTileMap::set_collision_visibility_mode); @@ -3732,6 +3742,8 @@ void RTileMap::_tile_set_changed_deferred_update() { } RTileMap::RTileMap() { + _y_sort_enabled = false; + set_notify_transform(true); set_notify_local_transform(false); diff --git a/rtile_map.h b/rtile_map.h index 276e067..d98e9a9 100644 --- a/rtile_map.h +++ b/rtile_map.h @@ -184,6 +184,8 @@ private: Rect2i used_rect_cache; bool used_rect_cache_dirty = true; + bool _y_sort_enabled; + // TileMap layers. struct TileMapLayer { String name; @@ -343,6 +345,7 @@ public: int get_effective_quadrant_size(int p_layer) const; //--- + virtual bool is_y_sort_enabled() const; virtual void set_y_sort_enabled(bool p_enable); Vector2 map_to_world(const Vector2i &p_pos) const;