44 lines
1,019 B
GDScript
44 lines
1,019 B
GDScript
@tool
|
|
extends Node2D
|
|
|
|
|
|
@export var is_open = false:
|
|
set(new_value):
|
|
is_open = new_value
|
|
_update_suitcase()
|
|
|
|
|
|
func _ready():
|
|
if Engine.is_editor_hint(): return
|
|
_update_suitcase()
|
|
|
|
func _update_suitcase():
|
|
if not is_node_ready(): return
|
|
|
|
if is_open:
|
|
$SuitcaseOpen.show()
|
|
$SuitcaseClosed.hide()
|
|
else:
|
|
$SuitcaseOpen.hide()
|
|
$SuitcaseClosed.show()
|
|
$SuitcaseOpen/DropoffArea.input_pickable = is_open
|
|
$SuitcaseOpen/CloseOnClickArea.input_pickable = is_open
|
|
$SuitcaseClosed/OpenOnClickArea.input_pickable = not is_open
|
|
if Engine.is_editor_hint():
|
|
$SuitcaseOpen.queue_redraw()
|
|
$SuitcaseClosed.queue_redraw()
|
|
|
|
|
|
func _on_area_2d_input_event(viewport, event, shape_idx):
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
func _on_close_on_click_area_input_event(viewport, event, shape_idx):
|
|
if event is InputEventMouseButton and event.is_pressed():
|
|
is_open = false
|
|
|
|
|
|
func _on_open_on_click_area_input_event(viewport, event, shape_idx):
|
|
if event is InputEventMouseButton and event.is_pressed():
|
|
is_open = true
|