59 lines
1.8 KiB
GDScript
59 lines
1.8 KiB
GDScript
extends Node3D
|
|
|
|
|
|
var exits: Array = [false, false, false, false]
|
|
|
|
const STREET_WIDTH: float = 40
|
|
@onready var exit_area = $BuildingAreas/B_area_E/Collision
|
|
@onready var building_area = $BuildingAreas/B_area/Collision
|
|
var building_scn = preload("res://building.tscn")
|
|
|
|
func _ready() -> void:
|
|
$Mesh.mesh.size.x = Global.chunk_size
|
|
$Mesh.mesh.size.y = Global.chunk_size
|
|
|
|
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:
|
|
$BuildingAreas/B_area_N/Building.visible = true
|
|
$BuildingAreas/B_area_S/Building.visible = true
|
|
$BuildingAreas/B_area_E/Building.visible = true
|
|
$BuildingAreas/B_area_W/Building.visible = true
|
|
|
|
var i = 0
|
|
for exit in exits:
|
|
if not exit:
|
|
i += 1
|
|
continue
|
|
|
|
if i == 0: #n
|
|
$BuildingAreas/B_area_N/Collision.disabled = true
|
|
$BuildingAreas/B_area_N/Building.visible = false
|
|
if i == 1: #s
|
|
$BuildingAreas/B_area_S/Collision.disabled = true
|
|
$BuildingAreas/B_area_S/Building.visible = false
|
|
if i == 2: #w
|
|
$BuildingAreas/B_area_W/Collision.disabled = true
|
|
$BuildingAreas/B_area_W/Building.visible = false
|
|
if i == 3: #e
|
|
$BuildingAreas/B_area_E/Collision.disabled = true
|
|
$BuildingAreas/B_area_E/Building.visible = false
|
|
|
|
i += 1
|