diff --git a/chunk.gd b/chunk.gd index a016152..ef999aa 100644 --- a/chunk.gd +++ b/chunk.gd @@ -3,29 +3,31 @@ extends Node3D var exits: Array = [false, false, false, false] -const STREET_WIDTH: float = 40 - +const STREET_WIDTH: float = 80 +@onready var exit_area = $BuildingAreas/B_area_E/Collision +@onready var building_area = $BuildingAreas/B_area/Collision func _ready() -> void: $Mesh.mesh.size.x = Global.chunk_size $Mesh.mesh.size.y = Global.chunk_size - - #var building_area = Area3D.new() - #var building_collision = CollisionShape3D.new() - #var box_shape = BoxShape3D.new() - #var box_mesh = BoxMesh.new() - #var building_mesh = MeshInstance3D.new() - #var building_collision_center = Vector3((-STREET_WIDTH/2-Global.chunk_size/2)/2+Global.chunk_size, 0, (STREET_WIDTH/2-Global.chunk_size/2)/2+Global.chunk_size) - #building_collision.position = building_collision_center - #box_shape.size = Vector3(Global.chunk_size/2-STREET_WIDTH/2, 20, Global.chunk_size/2-STREET_WIDTH/2) - #box_mesh.size = Vector3(Global.chunk_size/2-STREET_WIDTH/2, 20, Global.chunk_size/2-STREET_WIDTH/2) - #building_collision.shape = box_shape - #building_mesh.mesh = box_mesh - #$BuildingAreas.add_child(building_area) - #building_area.add_child(building_collision) - #building_collision.add_child(building_mesh) - - + + var building_side = (Global.chunk_size - STREET_WIDTH) / 2 + var building_center = (building_side + STREET_WIDTH) / 2 + + building_area.shape.size.z = building_side + building_area.shape.size.x = building_side + building_area.position.x = building_center + building_area.position.z = building_center + + exit_area.shape.size.z = STREET_WIDTH + exit_area.shape.size.x = building_side + for st_body in $BuildingAreas.get_children(): + st_body.get_node("Collision").position.x = building_center + + for degree in range(1, 4): + var new_area = $BuildingAreas/B_area.duplicate() + new_area.rotation.y = deg_to_rad(90) * degree + $BuildingAreas.add_child(new_area) func update() -> void: var i = 0 diff --git a/chunk.tscn b/chunk.tscn index 57445d8..0cf90fc 100644 --- a/chunk.tscn +++ b/chunk.tscn @@ -66,59 +66,37 @@ surface_material_override/0 = SubResource("StandardMaterial3D_381vs") [node name="BuildingAreas" type="Node3D" parent="." unique_id=530802888] -[node name="B_area_1" type="StaticBody3D" parent="BuildingAreas" unique_id=1937669746] +[node name="B_area" type="StaticBody3D" parent="BuildingAreas" unique_id=34391878] collision_mask = 7 -[node name="CollisionShape3D" type="CollisionShape3D" parent="BuildingAreas/B_area_1" unique_id=1067780811] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -47.5, 0, 47.5) -shape = SubResource("BoxShape3D_kdh3y") -debug_color = Color(0.7365185, 0.46945518, 0, 0.41960785) - -[node name="B_area_2" type="StaticBody3D" parent="BuildingAreas" unique_id=34391878] -collision_mask = 7 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="BuildingAreas/B_area_2" unique_id=1293591314] +[node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area" unique_id=1293591314] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 47.5) shape = SubResource("BoxShape3D_kdh3y") debug_color = Color(0.7365185, 0.46945518, 0, 0.41960785) -[node name="B_area_3" type="StaticBody3D" parent="BuildingAreas" unique_id=1586518106] -collision_mask = 7 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="BuildingAreas/B_area_3" unique_id=2115157432] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -47.5, 0, -47.5) -shape = SubResource("BoxShape3D_kdh3y") -debug_color = Color(0.7365185, 0.46945518, 0, 0.41960785) - -[node name="B_area_4" type="StaticBody3D" parent="BuildingAreas" unique_id=898383723] -collision_mask = 7 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="BuildingAreas/B_area_4" unique_id=1612111692] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, -47.5) -shape = SubResource("BoxShape3D_kdh3y") -debug_color = Color(0.7365185, 0.46945518, 0, 0.41960785) - [node name="B_area_E" type="StaticBody3D" parent="BuildingAreas" unique_id=164651542] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) [node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_E" unique_id=2080946797] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) shape = SubResource("BoxShape3D_a0kup") [node name="B_area_W" type="StaticBody3D" parent="BuildingAreas" unique_id=1412614477] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -47.5, 0, 0) +transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0, 0) -[node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_W" unique_id=1045867626] +[node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_W" unique_id=1430613576] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) shape = SubResource("BoxShape3D_a0kup") [node name="B_area_S" type="StaticBody3D" parent="BuildingAreas" unique_id=1192841263] -transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 47.5) +transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0, 0) -[node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_S" unique_id=685649647] +[node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_S" unique_id=884611759] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) shape = SubResource("BoxShape3D_a0kup") [node name="B_area_N" type="StaticBody3D" parent="BuildingAreas" unique_id=1360962540] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -47.5) - -[node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_N" unique_id=2008861829] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0) + +[node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_N" unique_id=1952010205] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) shape = SubResource("BoxShape3D_a0kup")