extends RayCast3D
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
if Globals.is_options_menu_active: return
|
|
|
|
if is_colliding():
|
|
var collider: Object = get_collider()
|
|
|
|
if collider is Block:
|
|
if Input.is_action_just_pressed("left_click_interact"):
|
|
(collider as Block).interact_left_click()
|
|
if Input.is_action_just_pressed("right_click_interact"):
|
|
EntityManager.create_block.emit(
|
|
InventoryManager.quick_slot_item_id,
|
|
collider.position + get_collision_normal()
|
|
)
|
|
|
|
if Waila.ref.get_target() == collider:
|
|
return
|
|
if not Waila.ref.get_target():
|
|
hook_block(collider)
|
|
else:
|
|
release_target()
|
|
else: # Not looking at anything
|
|
if Waila.ref.get_target():
|
|
release_target()
|
|
|
|
|
|
func hook_block(target_block: Block) -> void:
|
|
target_block.hook()
|
|
Waila.ref.set_target(target_block)
|
|
|
|
var id: String = target_block.get_id()
|
|
Waila.ref.hook_target(id)
|
|
|
|
func release_target() -> void:
|
|
Waila.ref.get_target().release()
|
|
Waila.ref.set_target(null)
|
|
Waila.ref.release_target()
|