diff options
author | Gilles Roudière <gilles.roudiere@gmail.com> | 2021-07-06 14:43:03 +0200 |
---|---|---|
committer | Gilles Roudière <gilles.roudiere@gmail.com> | 2021-07-21 12:36:37 +0200 |
commit | 5d34a81e52877034295fc79e4f4b01d0cfa7dfb1 (patch) | |
tree | fd6ae48af033bd91e1ed74e9abcd68ea8db39844 /scene/resources/tile_set.h | |
parent | b2187797dfe5fd35b50506abf5502449e3f990ee (diff) |
Implement atlas merging and tile proxies
Diffstat (limited to 'scene/resources/tile_set.h')
-rw-r--r-- | scene/resources/tile_set.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 4dcde52098..0a07981171 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -120,6 +120,8 @@ public: #endif // DISABLE_DEPRECATED public: + static const int INVALID_SOURCE; // -1; + enum CellNeighbor { CELL_NEIGHBOR_RIGHT_SIDE = 0, CELL_NEIGHBOR_RIGHT_CORNER, @@ -169,7 +171,6 @@ public: TILE_OFFSET_AXIS_VERTICAL, }; -public: struct PackedSceneSource { Ref<PackedScene> scene; Vector2 offset; @@ -250,6 +251,11 @@ private: void _compute_next_source_id(); void _source_changed(); + // Tile proxies + Map<int, int> source_level_proxies; + Map<Array, Array> coords_level_proxies; + Map<Array, Array> alternative_level_proxies; + // Helpers Vector<Point2> _get_square_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit); Vector<Point2> _get_square_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit); @@ -345,6 +351,31 @@ public: void set_custom_data_type(int p_layer_id, Variant::Type p_value); Variant::Type get_custom_data_type(int p_layer_id) const; + // Tiles proxies. + void set_source_level_tile_proxy(int p_source_from, int p_source_to); + int get_source_level_tile_proxy(int p_source_from); + bool has_source_level_tile_proxy(int p_source_from); + void remove_source_level_tile_proxy(int p_source_from); + + void set_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_source_to, Vector2i p_coords_to); + Array get_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from); + bool has_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from); + void remove_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from); + + void set_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from, int p_source_to, Vector2i p_coords_to, int p_alternative_to); + Array get_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from); + bool has_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from); + void remove_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from); + + Array get_source_level_tile_proxies() const; + Array get_coords_level_tile_proxies() const; + Array get_alternative_level_tile_proxies() const; + + Array map_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) const; + + void cleanup_invalid_tile_proxies(); + void clear_tile_proxies(); + // Helpers Vector<Vector2> get_tile_shape_polygon(); void draw_tile_shape(CanvasItem *p_canvas_item, Rect2 p_region, Color p_color, bool p_filled = false, Ref<Texture2D> p_texture = Ref<Texture2D>()); |