From 5b7f1a5ee469007e39160473df53a2fb9b5b6f9b Mon Sep 17 00:00:00 2001 From: DIvan2000 Date: Sat, 7 Dec 2024 21:22:24 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D0=B5=D1=80=D0=B5=D1=81=D0=B5?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BE=D1=80=D0=B8=D0=B4?= =?UTF-8?q?=D0=BE=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tile_map.gd | 14 ++++++++++++-- world.tscn | 12 ++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tile_map.gd b/tile_map.gd index 55ddae6..7b2db08 100644 --- a/tile_map.gd +++ b/tile_map.gd @@ -123,15 +123,25 @@ func place_way(pos1: Vector2i, pos2: Vector2i) -> bool: if not (tiledata1.get_custom_data("is_center") and tiledata1.get_custom_data("struct_name")=="EMPTY_ROOM"): return false if not (tiledata2.get_custom_data("is_center") and tiledata2.get_custom_data("struct_name")=="EMPTY_ROOM"): return false - + #Check place is free if pos1.x != pos2.x: if abs(pos1.x-pos2.x)<=5: return false + for x in range(min(pos1.x,pos2.x)+2, max(pos1.x,pos2.x)-1): + if get_maxZ(Vector2i(x, pos1.y)) >= structs[StructType.H_WAY][struct_fields.LAYER].z_index: + return false + if pos1.y != pos2.y: + if abs(pos1.y-pos2.y)<=5: return false + for y in range(min(pos1.y,pos2.y)+2, max(pos1.y,pos2.y)-1): + if get_maxZ(Vector2i(pos1.x, y)) >= structs[StructType.V_WAY][struct_fields.LAYER].z_index: + return false + + + if pos1.x != pos2.x: place_struct(Vector2i(min(pos1.x,pos2.x)+2, pos1.y), StructType.WAY_LEFT) place_struct(Vector2i(max(pos1.x,pos2.x)-2, pos1.y), StructType.WAY_RIGHT) for x in range(min(pos1.x,pos2.x)+3, max(pos1.x,pos2.x)-2): place_struct(Vector2i(x, pos1.y), StructType.H_WAY) if pos1.y != pos2.y: - if abs(pos1.y-pos2.y)<=5: return false place_struct(Vector2i(pos1.x, min(pos1.y,pos2.y)+2), StructType.WAY_UP) place_struct(Vector2i(pos1.x, max(pos1.y,pos2.y)-2), StructType.WAY_DOWN) for y in range(min(pos1.y,pos2.y)+3, max(pos1.y,pos2.y)-2): diff --git a/world.tscn b/world.tscn index 0b67953..f484b28 100644 --- a/world.tscn +++ b/world.tscn @@ -737,8 +737,11 @@ texture = ExtResource("3_hky6b") 1:5/0 = 0 1:5/0/custom_data_0 = true 1:5/0/custom_data_1 = Vector2i(3, 1) +1:5/0/custom_data_3 = Vector2i(0, 1) 2:5/0 = 0 +2:5/0/custom_data_3 = Vector2i(-1, 1) 3:5/0 = 0 +3:5/0/custom_data_3 = Vector2i(1, 1) 1:6/0 = 0 1:6/0/custom_data_0 = true 1:6/0/custom_data_1 = Vector2i(3, 1) @@ -748,15 +751,21 @@ texture = ExtResource("3_hky6b") 3:6/0 = 0 3:6/0/custom_data_0 = true 3:6/0/custom_data_1 = Vector2i(1, 3) +3:6/0/custom_data_3 = Vector2i(1, 0) 1:7/0 = 0 1:7/0/custom_data_0 = true 1:7/0/custom_data_1 = Vector2i(3, 1) +1:7/0/custom_data_3 = Vector2i(0, -1) 2:7/0 = 0 +2:7/0/custom_data_3 = Vector2i(-1, -1) 3:7/0 = 0 +3:7/0/custom_data_3 = Vector2i(1, -1) 0:5/0 = 0 +0:5/0/custom_data_3 = Vector2i(1, 1) 0:6/0 = 0 0:6/0/custom_data_3 = Vector2i(1, 0) 0:7/0 = 0 +0:7/0/custom_data_3 = Vector2i(1, -1) 4:7/0 = 0 4:7/0/custom_data_3 = Vector2i(0, -1) 4:6/0 = 0 @@ -766,10 +775,13 @@ texture = ExtResource("3_hky6b") 4:5/0 = 0 4:5/0/custom_data_3 = Vector2i(0, 1) 5:5/0 = 0 +5:5/0/custom_data_3 = Vector2i(-1, 1) 5:6/0 = 0 5:6/0/custom_data_0 = true 5:6/0/custom_data_1 = Vector2i(1, 3) +5:6/0/custom_data_3 = Vector2i(-1, 0) 5:7/0 = 0 +5:7/0/custom_data_3 = Vector2i(-1, -1) [sub_resource type="TileSet" id="TileSet_twrk0"] terrain_set_0/mode = 0