extends Node3D var load_place = preload("res://places/base_place/base_place.tscn") var place = load_place.instantiate() enum ROOM_BUILD_STATE {NONE, ALLOWED, IS_BUILDING, IS_PLACING_DOOR} #Tracks the current build state. var room_build_state = 0 var last_room = null #Tracks the position that was first clicked to start a build drag var build_drag_start_pos = null signal room_built func _ready(): #TEMP loads in a workplace. add_child(place) func _on_build_toggle(toggled_on): #Responds to the 'Build A Room' toggle if toggled_on: room_build_state = ROOM_BUILD_STATE.ALLOWED if not toggled_on: place.clear_selection() room_build_state = ROOM_BUILD_STATE.NONE func _on_area_3d_input_event(_camera, event, event_position, _normal, _shade_id): #Checks input events from the mouse plane if Input.is_action_pressed("select") && room_build_state == ROOM_BUILD_STATE.ALLOWED: room_build_state = ROOM_BUILD_STATE.IS_BUILDING build_drag_start_pos = event_position place.draw_tile_click(build_drag_start_pos) elif room_build_state == ROOM_BUILD_STATE.IS_BUILDING: if Input.is_action_pressed("select"): place.init_select_drag(build_drag_start_pos, event_position) else: room_build_state = ROOM_BUILD_STATE.ALLOWED place.end_select_drag() elif room_build_state == ROOM_BUILD_STATE.IS_PLACING_DOOR: if not Input.is_action_pressed("select"): place.hover_door(event_position) if Input.is_action_pressed("select"): room_build_state = ROOM_BUILD_STATE.NONE place.confirm_door() emit_signal("room_built") func _on_confirm_button_pressed() -> void: if place.selection_dict: if room_build_state == ROOM_BUILD_STATE.ALLOWED: if place.build_confirm_allowed: last_room = place.build_selection() room_build_state = ROOM_BUILD_STATE.IS_PLACING_DOOR else: pass