feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -37,7 +37,10 @@
|
|||
#include "core/templates/rb_set.h"
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/resources/image_texture.h"
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
#include "servers/navigation_server_2d.h"
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
/////////////////////////////// TileMapPattern //////////////////////////////////////
|
||||
|
||||
|
|
@ -305,8 +308,7 @@ void TileSet::TerrainsPattern::from_array(Array p_terrains) {
|
|||
}
|
||||
|
||||
Array TileSet::TerrainsPattern::as_array() const {
|
||||
Array output;
|
||||
output.push_back(get_terrain());
|
||||
Array output = { get_terrain() };
|
||||
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
if (is_valid_bit[i]) {
|
||||
output.push_back(bits[i]);
|
||||
|
|
@ -636,6 +638,7 @@ bool TileSet::get_occlusion_layer_sdf_collision(int p_layer_index) const {
|
|||
return occlusion_layers[p_layer_index].sdf_collision;
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
int TileSet::get_physics_layers_count() const {
|
||||
return physics_layers.size();
|
||||
}
|
||||
|
|
@ -719,6 +722,7 @@ Ref<PhysicsMaterial> TileSet::get_physics_layer_physics_material(int p_layer_ind
|
|||
ERR_FAIL_INDEX_V(p_layer_index, physics_layers.size(), Ref<PhysicsMaterial>());
|
||||
return physics_layers[p_layer_index].physics_material;
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains
|
||||
int TileSet::get_terrain_sets_count() const {
|
||||
|
|
@ -964,6 +968,7 @@ bool TileSet::is_valid_terrain_peering_bit(int p_terrain_set, TileSet::CellNeigh
|
|||
return is_valid_terrain_peering_bit_for_mode(terrain_mode, p_peering_bit);
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
int TileSet::get_navigation_layers_count() const {
|
||||
return navigation_layers.size();
|
||||
|
|
@ -1038,6 +1043,7 @@ bool TileSet::get_navigation_layer_layer_value(int p_layer_index, int p_layer_nu
|
|||
|
||||
return get_navigation_layer_layers(p_layer_index) & (1 << (p_layer_number - 1));
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Custom data.
|
||||
int TileSet::get_custom_data_layers_count() const {
|
||||
|
|
@ -1177,42 +1183,26 @@ void TileSet::set_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_f
|
|||
ERR_FAIL_COND(p_source_from == TileSet::INVALID_SOURCE || p_source_to == TileSet::INVALID_SOURCE);
|
||||
ERR_FAIL_COND(p_coords_from == TileSetSource::INVALID_ATLAS_COORDS || p_coords_to == TileSetSource::INVALID_ATLAS_COORDS);
|
||||
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
|
||||
Array to;
|
||||
to.push_back(p_source_to);
|
||||
to.push_back(p_coords_to);
|
||||
|
||||
Array from = { p_source_from, p_coords_from };
|
||||
Array to = { p_source_to, p_coords_to };
|
||||
coords_level_proxies[from] = to;
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Array TileSet::get_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from };
|
||||
ERR_FAIL_COND_V(!coords_level_proxies.has(from), Array());
|
||||
|
||||
return coords_level_proxies[from];
|
||||
}
|
||||
|
||||
bool TileSet::has_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from };
|
||||
return coords_level_proxies.has(from);
|
||||
}
|
||||
|
||||
void TileSet::remove_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from };
|
||||
ERR_FAIL_COND(!coords_level_proxies.has(from));
|
||||
|
||||
coords_level_proxies.erase(from);
|
||||
|
|
@ -1224,47 +1214,27 @@ void TileSet::set_alternative_level_tile_proxy(int p_source_from, Vector2i p_coo
|
|||
ERR_FAIL_COND(p_source_from == TileSet::INVALID_SOURCE || p_source_to == TileSet::INVALID_SOURCE);
|
||||
ERR_FAIL_COND(p_coords_from == TileSetSource::INVALID_ATLAS_COORDS || p_coords_to == TileSetSource::INVALID_ATLAS_COORDS);
|
||||
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
|
||||
Array to;
|
||||
to.push_back(p_source_to);
|
||||
to.push_back(p_coords_to);
|
||||
to.push_back(p_alternative_to);
|
||||
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
Array to = { p_source_to, p_coords_to, p_alternative_to };
|
||||
alternative_level_proxies[from] = to;
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Array TileSet::get_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
ERR_FAIL_COND_V(!alternative_level_proxies.has(from), Array());
|
||||
|
||||
return alternative_level_proxies[from];
|
||||
}
|
||||
|
||||
bool TileSet::has_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
return alternative_level_proxies.has(from);
|
||||
}
|
||||
|
||||
void TileSet::remove_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
ERR_FAIL_COND(!alternative_level_proxies.has(from));
|
||||
|
||||
alternative_level_proxies.erase(from);
|
||||
|
|
@ -1306,10 +1276,7 @@ Array TileSet::get_alternative_level_tile_proxies() const {
|
|||
}
|
||||
|
||||
Array TileSet::map_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) const {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
|
||||
// Check if the tile is valid, and if so, don't map the tile and return the input.
|
||||
if (has_source(p_source_from)) {
|
||||
|
|
@ -1334,17 +1301,11 @@ Array TileSet::map_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_a
|
|||
|
||||
// Source matches.
|
||||
if (source_level_proxies.has(p_source_from)) {
|
||||
Array output;
|
||||
output.push_back(source_level_proxies[p_source_from]);
|
||||
output.push_back(p_coords_from);
|
||||
output.push_back(p_alternative_from);
|
||||
Array output = { source_level_proxies[p_source_from], p_coords_from, p_alternative_from };
|
||||
return output;
|
||||
}
|
||||
|
||||
Array output;
|
||||
output.push_back(p_source_from);
|
||||
output.push_back(p_coords_from);
|
||||
output.push_back(p_alternative_from);
|
||||
Array output = { p_source_from, p_coords_from, p_alternative_from };
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
@ -3238,8 +3199,10 @@ void TileSet::reset_state() {
|
|||
tile_filled_mesh.instantiate();
|
||||
tile_meshes_dirty = true;
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
physics_layers.clear();
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains
|
||||
terrain_sets.clear();
|
||||
|
|
@ -3423,15 +3386,8 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
|
||||
// Add to the mapping.
|
||||
Array key_array;
|
||||
key_array.push_back(flip_h);
|
||||
key_array.push_back(flip_v);
|
||||
key_array.push_back(transpose);
|
||||
|
||||
Array value_array;
|
||||
value_array.push_back(source_id);
|
||||
value_array.push_back(coords);
|
||||
value_array.push_back(alternative_tile);
|
||||
Array key_array = { flip_h, flip_v, transpose };
|
||||
Array value_array = { source_id, coords, alternative_tile };
|
||||
|
||||
if (!compatibility_tilemap_mapping.has(E.key)) {
|
||||
compatibility_tilemap_mapping[E.key] = RBMap<Array, Array>();
|
||||
|
|
@ -3462,6 +3418,7 @@ void TileSet::_compatibility_conversion() {
|
|||
tile_data->add_occluder_polygon(0);
|
||||
tile_data->set_occluder_polygon(0, 0, occluder);
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
if (ctd->navigation.is_valid()) {
|
||||
if (get_navigation_layers_count() < 1) {
|
||||
add_navigation_layer();
|
||||
|
|
@ -3474,9 +3431,11 @@ void TileSet::_compatibility_conversion() {
|
|||
navigation->set_vertices(vertices);
|
||||
tile_data->set_navigation_polygon(0, navigation);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
tile_data->set_z_index(ctd->z_index);
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Add the shapes.
|
||||
if (ctd->shapes.size() > 0) {
|
||||
if (get_physics_layers_count() < 1) {
|
||||
|
|
@ -3500,6 +3459,7 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
}
|
||||
// Update the size count.
|
||||
if (!compatibility_size_count.has(ctd->region.get_size())) {
|
||||
|
|
@ -3539,16 +3499,8 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
|
||||
// Add to the mapping.
|
||||
Array key_array;
|
||||
key_array.push_back(coords);
|
||||
key_array.push_back(flip_h);
|
||||
key_array.push_back(flip_v);
|
||||
key_array.push_back(transpose);
|
||||
|
||||
Array value_array;
|
||||
value_array.push_back(source_id);
|
||||
value_array.push_back(coords);
|
||||
value_array.push_back(alternative_tile);
|
||||
Array key_array = { coords, flip_h, flip_v, transpose };
|
||||
Array value_array = { source_id, coords, alternative_tile };
|
||||
|
||||
if (!compatibility_tilemap_mapping.has(E.key)) {
|
||||
compatibility_tilemap_mapping[E.key] = RBMap<Array, Array>();
|
||||
|
|
@ -3577,6 +3529,7 @@ void TileSet::_compatibility_conversion() {
|
|||
tile_data->add_occluder_polygon(0);
|
||||
tile_data->set_occluder_polygon(0, 0, occluder);
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
if (ctd->autotile_navpoly_map.has(coords)) {
|
||||
if (get_navigation_layers_count() < 1) {
|
||||
add_navigation_layer();
|
||||
|
|
@ -3589,6 +3542,7 @@ void TileSet::_compatibility_conversion() {
|
|||
navigation->set_vertices(vertices);
|
||||
tile_data->set_navigation_polygon(0, navigation);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
if (ctd->autotile_priority_map.has(coords)) {
|
||||
tile_data->set_probability(ctd->autotile_priority_map[coords]);
|
||||
}
|
||||
|
|
@ -3596,6 +3550,7 @@ void TileSet::_compatibility_conversion() {
|
|||
tile_data->set_z_index(ctd->autotile_z_index_map[coords]);
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Add the shapes.
|
||||
if (ctd->shapes.size() > 0) {
|
||||
if (get_physics_layers_count() < 1) {
|
||||
|
|
@ -3619,6 +3574,7 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// -- TODO: handle --
|
||||
// Those are offset for the whole atlas, they are likely useless for the atlases, but might make sense for single tiles.
|
||||
|
|
@ -3641,6 +3597,7 @@ void TileSet::_compatibility_conversion() {
|
|||
} break;
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Offset all shapes
|
||||
for (int k = 0; k < ctd->shapes.size(); k++) {
|
||||
Ref<ConvexPolygonShape2D> convex = ctd->shapes[k].shape;
|
||||
|
|
@ -3652,6 +3609,7 @@ void TileSet::_compatibility_conversion() {
|
|||
convex->set_points(points);
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
}
|
||||
|
||||
// Update the TileSet tile_size according to the most common size found.
|
||||
|
|
@ -3673,10 +3631,11 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
|
||||
Array TileSet::compatibility_tilemap_map(int p_tile_id, Vector2i p_coords, bool p_flip_h, bool p_flip_v, bool p_transpose) {
|
||||
Array cannot_convert_array;
|
||||
cannot_convert_array.push_back(TileSet::INVALID_SOURCE);
|
||||
cannot_convert_array.push_back(TileSetAtlasSource::INVALID_ATLAS_COORDS);
|
||||
cannot_convert_array.push_back(TileSetAtlasSource::INVALID_TILE_ALTERNATIVE);
|
||||
Array cannot_convert_array = {
|
||||
TileSet::INVALID_SOURCE,
|
||||
TileSetAtlasSource::INVALID_ATLAS_COORDS,
|
||||
TileSetAtlasSource::INVALID_TILE_ALTERNATIVE
|
||||
};
|
||||
|
||||
if (!compatibility_tilemap_mapping.has(p_tile_id)) {
|
||||
return cannot_convert_array;
|
||||
|
|
@ -3685,21 +3644,14 @@ Array TileSet::compatibility_tilemap_map(int p_tile_id, Vector2i p_coords, bool
|
|||
int tile_mode = compatibility_tilemap_mapping_tile_modes[p_tile_id];
|
||||
switch (tile_mode) {
|
||||
case COMPATIBILITY_TILE_MODE_SINGLE_TILE: {
|
||||
Array a;
|
||||
a.push_back(p_flip_h);
|
||||
a.push_back(p_flip_v);
|
||||
a.push_back(p_transpose);
|
||||
Array a = { p_flip_h, p_flip_v, p_transpose };
|
||||
return compatibility_tilemap_mapping[p_tile_id][a];
|
||||
}
|
||||
case COMPATIBILITY_TILE_MODE_AUTO_TILE:
|
||||
return cannot_convert_array;
|
||||
break;
|
||||
case COMPATIBILITY_TILE_MODE_ATLAS_TILE: {
|
||||
Array a;
|
||||
a.push_back(p_coords);
|
||||
a.push_back(p_flip_h);
|
||||
a.push_back(p_flip_v);
|
||||
a.push_back(p_transpose);
|
||||
Array a = { p_coords, p_flip_h, p_flip_v, p_transpose };
|
||||
return compatibility_tilemap_mapping[p_tile_id][a];
|
||||
}
|
||||
default:
|
||||
|
|
@ -3789,7 +3741,9 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
if (p[0].get_type() == Variant::VECTOR2) {
|
||||
last_coord = p[0];
|
||||
} else if (p[0].get_type() == Variant::OBJECT) {
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
ctd->autotile_navpoly_map.insert(last_coord, p[0]);
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
}
|
||||
p.pop_front();
|
||||
}
|
||||
|
|
@ -3830,18 +3784,20 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
for (int i = 0; i < p.size(); i++) {
|
||||
CompatibilityShapeData csd;
|
||||
Dictionary d = p[i];
|
||||
for (int j = 0; j < d.size(); j++) {
|
||||
String key = d.get_key_at_index(j);
|
||||
for (const KeyValue<Variant, Variant> &kv : d) {
|
||||
String key = kv.key;
|
||||
if (key == "autotile_coord") {
|
||||
csd.autotile_coords = d[key];
|
||||
csd.autotile_coords = kv.value;
|
||||
} else if (key == "one_way") {
|
||||
csd.one_way = d[key];
|
||||
csd.one_way = kv.value;
|
||||
} else if (key == "one_way_margin") {
|
||||
csd.one_way_margin = d[key];
|
||||
csd.one_way_margin = kv.value;
|
||||
} else if (key == "shape") {
|
||||
csd.shape = d[key];
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
csd.shape = kv.value;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
} else if (key == "shape_transform") {
|
||||
csd.transform = d[key];
|
||||
csd.transform = kv.value;
|
||||
}
|
||||
}
|
||||
ctd->shapes.push_back(csd);
|
||||
|
|
@ -3849,7 +3805,9 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
} else if (what == "occluder") {
|
||||
ctd->occluder = p_value;
|
||||
} else if (what == "navigation") {
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
ctd->navigation = p_value;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
/*
|
||||
// IGNORED FOR NOW, they seem duplicated data compared to the shapes array
|
||||
|
|
@ -3897,6 +3855,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
set_occlusion_layer_sdf_collision(index, p_value);
|
||||
return true;
|
||||
}
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
} else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
// Physics layers.
|
||||
int index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
|
|
@ -3930,6 +3889,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
set_physics_layer_physics_material(index, physics_material);
|
||||
return true;
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int()) {
|
||||
// Terrains.
|
||||
int terrain_set_index = components[0].trim_prefix("terrain_set_").to_int();
|
||||
|
|
@ -3966,6 +3926,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
}
|
||||
}
|
||||
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation layers.
|
||||
int index = components[0].trim_prefix("navigation_layer_").to_int();
|
||||
ERR_FAIL_COND_V(index < 0, false);
|
||||
|
|
@ -3977,6 +3938,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
set_navigation_layer_layers(index, p_value);
|
||||
return true;
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) {
|
||||
// Custom data layers.
|
||||
int index = components[0].trim_prefix("custom_data_layer_").to_int();
|
||||
|
|
@ -4061,6 +4023,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
r_ret = get_occlusion_layer_sdf_collision(index);
|
||||
return true;
|
||||
}
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
} else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
// Physics layers.
|
||||
int index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
|
|
@ -4080,6 +4043,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
r_ret = get_physics_layer_physics_material(index);
|
||||
return true;
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int()) {
|
||||
// Terrains.
|
||||
int terrain_set_index = components[0].trim_prefix("terrain_set_").to_int();
|
||||
|
|
@ -4108,10 +4072,12 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
if (index < 0 || index >= navigation_layers.size()) {
|
||||
return false;
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
if (components[1] == "layers") {
|
||||
r_ret = get_navigation_layer_layers(index);
|
||||
return true;
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) {
|
||||
// Custom data layers.
|
||||
int index = components[0].trim_prefix("custom_data_layer_").to_int();
|
||||
|
|
@ -4189,6 +4155,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
p_list->push_back(property_info);
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Physics", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
|
||||
for (int i = 0; i < physics_layers.size(); i++) {
|
||||
|
|
@ -4215,6 +4182,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
p_list->push_back(property_info);
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Terrains", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
|
||||
|
|
@ -4310,6 +4278,7 @@ void TileSet::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_occlusion_layer_sdf_collision", "layer_index", "sdf_collision"), &TileSet::set_occlusion_layer_sdf_collision);
|
||||
ClassDB::bind_method(D_METHOD("get_occlusion_layer_sdf_collision", "layer_index"), &TileSet::get_occlusion_layer_sdf_collision);
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
ClassDB::bind_method(D_METHOD("get_physics_layers_count"), &TileSet::get_physics_layers_count);
|
||||
ClassDB::bind_method(D_METHOD("add_physics_layer", "to_position"), &TileSet::add_physics_layer, DEFVAL(-1));
|
||||
|
|
@ -4323,6 +4292,7 @@ void TileSet::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_physics_layer_collision_priority", "layer_index"), &TileSet::get_physics_layer_collision_priority);
|
||||
ClassDB::bind_method(D_METHOD("set_physics_layer_physics_material", "layer_index", "physics_material"), &TileSet::set_physics_layer_physics_material);
|
||||
ClassDB::bind_method(D_METHOD("get_physics_layer_physics_material", "layer_index"), &TileSet::get_physics_layer_physics_material);
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains
|
||||
ClassDB::bind_method(D_METHOD("get_terrain_sets_count"), &TileSet::get_terrain_sets_count);
|
||||
|
|
@ -4341,6 +4311,7 @@ void TileSet::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_terrain_color", "terrain_set", "terrain_index", "color"), &TileSet::set_terrain_color);
|
||||
ClassDB::bind_method(D_METHOD("get_terrain_color", "terrain_set", "terrain_index"), &TileSet::get_terrain_color);
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers_count"), &TileSet::get_navigation_layers_count);
|
||||
ClassDB::bind_method(D_METHOD("add_navigation_layer", "to_position"), &TileSet::add_navigation_layer, DEFVAL(-1));
|
||||
|
|
@ -4350,6 +4321,7 @@ void TileSet::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_navigation_layer_layers", "layer_index"), &TileSet::get_navigation_layer_layers);
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_layer_value", "layer_index", "layer_number", "value"), &TileSet::set_navigation_layer_layer_value);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_layer_value", "layer_index", "layer_number"), &TileSet::get_navigation_layer_layer_value);
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Custom data
|
||||
ClassDB::bind_method(D_METHOD("get_custom_data_layers_count"), &TileSet::get_custom_data_layers_count);
|
||||
|
|
@ -4397,7 +4369,9 @@ void TileSet::_bind_methods() {
|
|||
ADD_GROUP("", "");
|
||||
ADD_ARRAY("physics_layers", "physics_layer_");
|
||||
ADD_ARRAY("terrain_sets", "terrain_set_");
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
ADD_ARRAY("navigation_layers", "navigation_layer_");
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
ADD_ARRAY("custom_data_layers", "custom_data_layer_");
|
||||
|
||||
// -- Enum binding --
|
||||
|
|
@ -4531,6 +4505,7 @@ void TileSetAtlasSource::remove_occlusion_layer(int p_index) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
void TileSetAtlasSource::add_physics_layer(int p_to_pos) {
|
||||
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
|
||||
for (KeyValue<int, TileData *> E_alternative : E_tile.value.alternatives) {
|
||||
|
|
@ -4554,6 +4529,7 @@ void TileSetAtlasSource::remove_physics_layer(int p_index) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
void TileSetAtlasSource::add_terrain_set(int p_to_pos) {
|
||||
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
|
||||
|
|
@ -4603,6 +4579,7 @@ void TileSetAtlasSource::remove_terrain(int p_terrain_set, int p_index) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
void TileSetAtlasSource::add_navigation_layer(int p_to_pos) {
|
||||
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
|
||||
for (KeyValue<int, TileData *> E_alternative : E_tile.value.alternatives) {
|
||||
|
|
@ -4626,6 +4603,7 @@ void TileSetAtlasSource::remove_navigation_layer(int p_index) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
void TileSetAtlasSource::add_custom_data_layer(int p_to_pos) {
|
||||
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
|
||||
|
|
@ -5969,13 +5947,17 @@ void TileData::notify_tile_data_properties_should_change() {
|
|||
}
|
||||
|
||||
occluders.resize(tile_set->get_occlusion_layers_count());
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
physics.resize(tile_set->get_physics_layers_count());
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
for (int bit_index = 0; bit_index < 16; bit_index++) {
|
||||
if (terrain_set < 0 || terrain_peering_bits[bit_index] >= tile_set->get_terrains_count(terrain_set)) {
|
||||
terrain_peering_bits[bit_index] = -1;
|
||||
}
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
navigation.resize(tile_set->get_navigation_layers_count());
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Convert custom data to the new type.
|
||||
custom_data.resize(tile_set->get_custom_data_layers_count());
|
||||
|
|
@ -6017,6 +5999,7 @@ void TileData::remove_occlusion_layer(int p_index) {
|
|||
occluders.remove_at(p_index);
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
void TileData::add_physics_layer(int p_to_pos) {
|
||||
if (p_to_pos < 0) {
|
||||
p_to_pos = physics.size();
|
||||
|
|
@ -6036,6 +6019,7 @@ void TileData::remove_physics_layer(int p_index) {
|
|||
ERR_FAIL_INDEX(p_index, physics.size());
|
||||
physics.remove_at(p_index);
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
void TileData::add_terrain_set(int p_to_pos) {
|
||||
if (p_to_pos >= 0 && p_to_pos <= terrain_set) {
|
||||
|
|
@ -6112,6 +6096,7 @@ void TileData::remove_terrain(int p_terrain_set, int p_index) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
void TileData::add_navigation_layer(int p_to_pos) {
|
||||
if (p_to_pos < 0) {
|
||||
p_to_pos = navigation.size();
|
||||
|
|
@ -6131,6 +6116,7 @@ void TileData::remove_navigation_layer(int p_index) {
|
|||
ERR_FAIL_INDEX(p_index, navigation.size());
|
||||
navigation.remove_at(p_index);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
void TileData::add_custom_data_layer(int p_to_pos) {
|
||||
if (p_to_pos < 0) {
|
||||
|
|
@ -6176,13 +6162,17 @@ TileData *TileData::duplicate() {
|
|||
output->z_index = z_index;
|
||||
output->y_sort_origin = y_sort_origin;
|
||||
output->occluders = occluders;
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
output->physics = physics;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
// Terrain
|
||||
output->terrain_set = -1;
|
||||
memcpy(output->terrain_peering_bits, terrain_peering_bits, 16 * sizeof(int));
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
output->navigation = navigation;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
// Misc
|
||||
output->probability = probability;
|
||||
// Custom data
|
||||
|
|
@ -6347,6 +6337,7 @@ Ref<OccluderPolygon2D> TileData::get_occluder_polygon(int p_layer_id, int p_poly
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
void TileData::set_constant_linear_velocity(int p_layer_id, const Vector2 &p_velocity) {
|
||||
ERR_FAIL_INDEX(p_layer_id, physics.size());
|
||||
|
|
@ -6495,6 +6486,7 @@ Ref<ConvexPolygonShape2D> TileData::get_collision_polygon_shape(int p_layer_id,
|
|||
return I->value[shape_index];
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain
|
||||
void TileData::set_terrain_set(int p_terrain_set) {
|
||||
|
|
@ -6568,6 +6560,7 @@ TileSet::TerrainsPattern TileData::get_terrains_pattern() const {
|
|||
return output;
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
void TileData::set_navigation_polygon(int p_layer_id, Ref<NavigationPolygon> p_navigation_polygon) {
|
||||
ERR_FAIL_INDEX(p_layer_id, navigation.size());
|
||||
|
|
@ -6615,6 +6608,7 @@ Ref<NavigationPolygon> TileData::get_navigation_polygon(int p_layer_id, bool p_f
|
|||
return I->value;
|
||||
}
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Misc
|
||||
void TileData::set_probability(float p_probability) {
|
||||
|
|
@ -6743,7 +6737,9 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
}
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
// Physics layers.
|
||||
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6798,7 +6794,10 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
// Navigation layers.
|
||||
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6815,7 +6814,9 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
|
|||
set_navigation_polygon(layer_index, polygon);
|
||||
return true;
|
||||
}
|
||||
} else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
|
||||
// Terrains.
|
||||
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
|
||||
|
|
@ -6887,7 +6888,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
}
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
// Physics layers.
|
||||
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6923,7 +6926,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
|
||||
// Terrains.
|
||||
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
if (components[1] == TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]) {
|
||||
|
|
@ -6932,7 +6937,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
}
|
||||
}
|
||||
return false;
|
||||
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
// Occlusion layers.
|
||||
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6943,7 +6950,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
r_ret = get_navigation_polygon(layer_index);
|
||||
return true;
|
||||
}
|
||||
} else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
|
||||
// Custom data layers.
|
||||
int layer_index = components[0].trim_prefix("custom_data_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6976,6 +6985,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics layers.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Physics", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
|
||||
for (int i = 0; i < physics.size(); i++) {
|
||||
|
|
@ -7018,6 +7028,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
p_list->push_back(property_info);
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain data
|
||||
if (terrain_set >= 0) {
|
||||
|
|
@ -7034,6 +7045,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation layers.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Navigation", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
|
||||
for (int i = 0; i < navigation.size(); i++) {
|
||||
|
|
@ -7043,6 +7055,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
p_list->push_back(property_info);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Custom data layers.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Custom Data", "custom_data_"), PROPERTY_HINT_NONE, "custom_data_", PROPERTY_USAGE_GROUP));
|
||||
|
|
@ -7090,6 +7103,7 @@ void TileData::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_occluder", "layer_id", "flip_h", "flip_v", "transpose"), &TileData::get_occluder, DEFVAL(false), DEFVAL(false), DEFVAL(false));
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics.
|
||||
ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "layer_id", "velocity"), &TileData::set_constant_linear_velocity);
|
||||
ClassDB::bind_method(D_METHOD("get_constant_linear_velocity", "layer_id"), &TileData::get_constant_linear_velocity);
|
||||
|
|
@ -7105,6 +7119,7 @@ void TileData::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("is_collision_polygon_one_way", "layer_id", "polygon_index"), &TileData::is_collision_polygon_one_way);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_polygon_one_way_margin", "layer_id", "polygon_index", "one_way_margin"), &TileData::set_collision_polygon_one_way_margin);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_polygon_one_way_margin", "layer_id", "polygon_index"), &TileData::get_collision_polygon_one_way_margin);
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain
|
||||
ClassDB::bind_method(D_METHOD("set_terrain_set", "terrain_set"), &TileData::set_terrain_set);
|
||||
|
|
@ -7115,9 +7130,11 @@ void TileData::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_terrain_peering_bit", "peering_bit"), &TileData::get_terrain_peering_bit);
|
||||
ClassDB::bind_method(D_METHOD("is_valid_terrain_peering_bit", "peering_bit"), &TileData::is_valid_terrain_peering_bit);
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "layer_id", "navigation_polygon"), &TileData::set_navigation_polygon);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_polygon", "layer_id", "flip_h", "flip_v", "transpose"), &TileData::get_navigation_polygon, DEFVAL(false), DEFVAL(false), DEFVAL(false));
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Misc.
|
||||
ClassDB::bind_method(D_METHOD("set_probability", "probability"), &TileData::set_probability);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue