mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Restore support for minimal 3x3 autotile sets
This commit is contained in:
parent
ba134d44b8
commit
e4f0ac558d
@ -667,7 +667,7 @@ void TileSetEditor::_on_workspace_draw() {
|
||||
if (mask & TileSet::BIND_BOTTOMRIGHT) {
|
||||
workspace->draw_rect(Rect2(anchor + size / 2, size / 2), c);
|
||||
}
|
||||
} else if (tileset->autotile_get_bitmask_mode(get_current_tile()) == TileSet::BITMASK_3X3) {
|
||||
} else {
|
||||
if (mask & TileSet::BIND_TOPLEFT) {
|
||||
workspace->draw_rect(Rect2(anchor, size / 3), c);
|
||||
}
|
||||
@ -821,7 +821,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
|
||||
bit = TileSet::BIND_BOTTOMRIGHT;
|
||||
}
|
||||
}
|
||||
} else if (tileset->autotile_get_bitmask_mode(get_current_tile()) == TileSet::BITMASK_3X3) {
|
||||
} else {
|
||||
if (pos.x < size.x / 3) {
|
||||
if (pos.y < size.y / 3) {
|
||||
bit = TileSet::BIND_TOPLEFT;
|
||||
@ -884,7 +884,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
|
||||
bit = TileSet::BIND_BOTTOMRIGHT;
|
||||
}
|
||||
}
|
||||
} else if (tileset->autotile_get_bitmask_mode(get_current_tile()) == TileSet::BITMASK_3X3) {
|
||||
} else {
|
||||
if (pos.x < size.x / 3) {
|
||||
if (pos.y < size.y / 3) {
|
||||
bit = TileSet::BIND_TOPLEFT;
|
||||
@ -1849,7 +1849,7 @@ void TileSetEditorHelper::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
if (selected_tile < 0 || tileset.is_null())
|
||||
return;
|
||||
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "bitmask_mode", PROPERTY_HINT_ENUM, "2x2,3x3"));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "bitmask_mode", PROPERTY_HINT_ENUM, "2x2,3x3 (minimal),3x3"));
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR2, "layout/tile_size"));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "layout/spacing", PROPERTY_HINT_RANGE, "0,256,1"));
|
||||
}
|
||||
|
@ -845,16 +845,37 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y + 1)) && tile_set->is_tile_bound(id, get_cell(p_x, p_y + 1)) && tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y))) {
|
||||
mask |= TileSet::BIND_BOTTOMRIGHT;
|
||||
}
|
||||
} else if (tile_set->autotile_get_bitmask_mode(id) == TileSet::BITMASK_3X3) {
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y - 1))) {
|
||||
mask |= TileSet::BIND_TOPLEFT;
|
||||
} else {
|
||||
if (tile_set->autotile_get_bitmask_mode(id) == TileSet::BITMASK_3X3_MINIMAL) {
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y - 1)) && tile_set->is_tile_bound(id, get_cell(p_x, p_y - 1)) && tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y))) {
|
||||
mask |= TileSet::BIND_TOPLEFT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y - 1)) && tile_set->is_tile_bound(id, get_cell(p_x, p_y - 1)) && tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y))) {
|
||||
mask |= TileSet::BIND_TOPRIGHT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y + 1)) && tile_set->is_tile_bound(id, get_cell(p_x, p_y + 1)) && tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y))) {
|
||||
mask |= TileSet::BIND_BOTTOMLEFT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y + 1)) && tile_set->is_tile_bound(id, get_cell(p_x, p_y + 1)) && tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y))) {
|
||||
mask |= TileSet::BIND_BOTTOMRIGHT;
|
||||
}
|
||||
} else {
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y - 1))) {
|
||||
mask |= TileSet::BIND_TOPLEFT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y - 1))) {
|
||||
mask |= TileSet::BIND_TOPRIGHT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y + 1))) {
|
||||
mask |= TileSet::BIND_BOTTOMLEFT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y + 1))) {
|
||||
mask |= TileSet::BIND_BOTTOMRIGHT;
|
||||
}
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x, p_y - 1))) {
|
||||
mask |= TileSet::BIND_TOP;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y - 1))) {
|
||||
mask |= TileSet::BIND_TOPRIGHT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y))) {
|
||||
mask |= TileSet::BIND_LEFT;
|
||||
}
|
||||
@ -862,15 +883,9 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y))) {
|
||||
mask |= TileSet::BIND_RIGHT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y + 1))) {
|
||||
mask |= TileSet::BIND_BOTTOMLEFT;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x, p_y + 1))) {
|
||||
mask |= TileSet::BIND_BOTTOM;
|
||||
}
|
||||
if (tile_set->is_tile_bound(id, get_cell(p_x + 1, p_y + 1))) {
|
||||
mask |= TileSet::BIND_BOTTOMRIGHT;
|
||||
}
|
||||
}
|
||||
Vector2 coord = tile_set->autotile_get_subtile_for_bitmask(id, mask, this, Vector2(p_x, p_y));
|
||||
E->get().autotile_coord_x = (int)coord.x;
|
||||
|
@ -264,7 +264,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::RECT2, pre + "region"));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, pre + "tile_mode", PROPERTY_HINT_ENUM, "SINGLE_TILE,AUTO_TILE"));
|
||||
if (tile_get_tile_mode(id) == AUTO_TILE) {
|
||||
p_list->push_back(PropertyInfo(Variant::INT, pre + "autotile/bitmask_mode", PROPERTY_HINT_ENUM, "2X2,3X3", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, pre + "autotile/bitmask_mode", PROPERTY_HINT_ENUM, "2X2,3X3 (minimal),3X3", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "autotile/bitmask_flags", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
|
||||
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));
|
||||
@ -960,6 +960,7 @@ void TileSet::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "_forward_subtile_selection", PropertyInfo(Variant::INT, "autotile_id"), PropertyInfo(Variant::INT, "bitmask"), PropertyInfo(Variant::OBJECT, "tilemap", PROPERTY_HINT_NONE, "TileMap"), PropertyInfo(Variant::VECTOR2, "tile_location")));
|
||||
|
||||
BIND_ENUM_CONSTANT(BITMASK_2X2);
|
||||
BIND_ENUM_CONSTANT(BITMASK_3X3_MINIMAL);
|
||||
BIND_ENUM_CONSTANT(BITMASK_3X3);
|
||||
|
||||
BIND_ENUM_CONSTANT(BIND_TOPLEFT);
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
|
||||
enum BitmaskMode {
|
||||
BITMASK_2X2,
|
||||
BITMASK_3X3_MINIMAL,
|
||||
BITMASK_3X3
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user