otherworldly_simulation/scene/test/self_character.gd
2024-11-01 23:23:07 +08:00

50 lines
1.1 KiB
GDScript

extends Unit
class_name SelfUnit
func _ready() -> void:
unit_data=Database.get_unit_data(unit_data_from_id,unit_id)
super._ready()
state_machine.launch()
func _on_state_value_changed(state_value_name: String, value: Variant) -> void:
match state_value_name:
"hp":
%hp.value=value
"hp_max":
%hp.max_value=value
pass # Replace with function body.
var e_interaction_item:EInteractionItem
var door_area:Door
func _on_touch_area_area_entered(area: Area2D) -> void:
if area is Door:
door_area=area
%door.show()
if area is EInteractionItem:
if e_interaction_item!=null:
e_interaction_item._exit_highlight()
e_interaction_item=area
%door.show()
pass # Replace with function body.
func _on_touch_area_area_exited(area: Area2D) -> void:
if area is EInteractionItem:
if e_interaction_item==area:
e_interaction_item._exit_highlight()
e_interaction_item=null
pass # Replace with function body.
func is_door_availible():
return door_area!=null
func get_e_interaction_item():
return e_interaction_item
func e_pressed():
if e_interaction_item!=null:
e_interaction_item.E_pressed()