diff options
Diffstat (limited to 'scene/resources/tile_set.cpp')
-rw-r--r-- | scene/resources/tile_set.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index f852ecd7eb..88dbc67e01 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -129,6 +129,22 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { } p.pop_front(); } + } else if (what == "z_index_map") { + tile_map[id].autotile_data.z_index_map.clear(); + Array p = p_value; + Vector3 val; + Vector2 v; + int z_index; + while (p.size() > 0) { + val = p[0]; + if (val.z > 1) { + v.x = val.x; + v.y = val.y; + z_index = (int)val.z; + tile_map[id].autotile_data.z_index_map[v] = z_index; + } + p.pop_front(); + } } } else if (what == "shape") tile_set_shape(id, 0, p_value); @@ -228,6 +244,19 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { } } r_ret = p; + } else if (what == "z_index_map") { + Array p; + Vector3 v; + for (Map<Vector2, int>::Element *E = tile_map[id].autotile_data.z_index_map.front(); E; E = E->next()) { + if (E->value() != 0) { + //Don't save default value + v.x = E->key().x; + v.y = E->key().y; + v.z = E->value(); + p.push_back(v); + } + } + r_ret = p; } } else if (what == "shape") r_ret = tile_get_shape(id, 0); @@ -278,6 +307,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/occluder_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/navpoly_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/priority_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); + p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/z_index_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); } else if (tile_get_tile_mode(id) == ATLAS_TILE) { p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "autotile/icon_coordinate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "autotile/tile_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); @@ -476,6 +506,23 @@ int TileSet::autotile_get_subtile_priority(int p_id, const Vector2 &p_coord) { return 1; } +void TileSet::autotile_set_z_index(int p_id, const Vector2 &p_coord, int p_z_index) { + + ERR_FAIL_COND(!tile_map.has(p_id)); + tile_map[p_id].autotile_data.z_index_map[p_coord] = p_z_index; + emit_changed(); +} + +int TileSet::autotile_get_z_index(int p_id, const Vector2 &p_coord) { + + ERR_FAIL_COND_V(!tile_map.has(p_id), 1); + if (tile_map[p_id].autotile_data.z_index_map.has(p_coord)) { + return tile_map[p_id].autotile_data.z_index_map[p_coord]; + } + //When not custom z index set return the default value + return 0; +} + const Map<Vector2, int> &TileSet::autotile_get_priority_map(int p_id) const { static Map<Vector2, int> dummy; |