summaryrefslogtreecommitdiffstats
path: root/scene/2d/tile_map.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-11-22 15:31:46 +0100
committerGitHub <noreply@github.com>2017-11-22 15:31:46 +0100
commite38efe22c7626de34912cf2346f915ccca56f77b (patch)
treeb608f291065a4b485bec91e20245c78391cc0a5b /scene/2d/tile_map.h
parent012b39706364a8eb1ed576470a0d35c8ed498ad0 (diff)
parentbcfb0a09f89f6734e2404acd68505dc45b402ee6 (diff)
downloadredot-engine-e38efe22c7626de34912cf2346f915ccca56f77b.tar.gz
Merge pull request #12301 from MarianoGnu/master
Implement auto-tiling
Diffstat (limited to 'scene/2d/tile_map.h')
-rw-r--r--scene/2d/tile_map.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 9e14ec838a..a0ca2e6a35 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -60,6 +60,11 @@ public:
};
private:
+ enum DataFormat {
+ FORMAT_2_1_4 = 0,
+ FORMAT_2_1_5
+ };
+
Ref<TileSet> tile_set;
Size2i cell_size;
int quadrant_size;
@@ -81,6 +86,8 @@ private:
//using a more precise comparison so the regions can be sorted later
bool operator<(const PosKey &p_k) const { return (y == p_k.y) ? x < p_k.x : y < p_k.y; }
+ bool operator==(const PosKey &p_k) const { return (y == p_k.y && x == p_k.x); }
+
PosKey(int16_t p_x, int16_t p_y) {
x = p_x;
y = p_y;
@@ -98,13 +105,17 @@ private:
bool flip_h : 1;
bool flip_v : 1;
bool transpose : 1;
+ int16_t autotile_coord_x : 16;
+ int16_t autotile_coord_y : 16;
};
- uint32_t _u32t;
- Cell() { _u32t = 0; }
+ uint64_t _u64t;
+ Cell() { _u64t = 0; }
};
Map<PosKey, Cell> tile_map;
+ List<PosKey> dirty_bitmask;
+
struct Quadrant {
Vector2 pos;
@@ -167,6 +178,7 @@ private:
float bounce;
uint32_t collision_layer;
uint32_t collision_mask;
+ DataFormat format;
TileOrigin tile_origin;
@@ -198,6 +210,10 @@ private:
_FORCE_INLINE_ Vector2 _map_to_world(int p_x, int p_y, bool p_ignore_ofs = false) const;
protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
+
void _notification(int p_what);
static void _bind_methods();
@@ -220,17 +236,24 @@ public:
void set_center_y(bool p_enable);
bool get_center_y() const;
- void set_cell(int p_x, int p_y, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false);
+ void set_cell(int p_x, int p_y, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false, Vector2 p_autotile_coord = Vector2());
int get_cell(int p_x, int p_y) const;
bool is_cell_x_flipped(int p_x, int p_y) const;
bool is_cell_y_flipped(int p_x, int p_y) const;
bool is_cell_transposed(int p_x, int p_y) const;
+ int get_cell_autotile_coord_x(int p_x, int p_y) const;
+ int get_cell_autotile_coord_y(int p_x, int p_y) const;
void set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false);
int get_cellv(const Vector2 &p_pos) const;
Rect2 _edit_get_rect() const;
+ void make_bitmask_area_dirty(const Vector2 &p_pos);
+ void update_bitmask_area(const Vector2 &p_pos);
+ void update_cell_bitmask(int p_x, int p_y);
+ void update_dirty_bitmask();
+
void set_collision_layer(uint32_t p_layer);
uint32_t get_collision_layer() const;