rename honeydew moving to tweening

This commit is contained in:
Teatov 2024-10-13 22:39:55 +10:00
parent a4b4ff89eb
commit 27ee586028
2 changed files with 11 additions and 11 deletions

View File

@ -1,11 +1,11 @@
extends Interactable extends Interactable
class_name Honeydew class_name Honeydew
signal moved signal tween_finished
const HEIGHT_OFFSET: float = 0.1 const HEIGHT_OFFSET: float = 0.1
const MOVE_SPEED: float = 8 const TWEEN_SPEED: float = 8
const MOVE_ARC_HEIGHT: float = 0.5 const TWEEN_ARC_HEIGHT: float = 0.5
var carried: bool = false var carried: bool = false
@ -29,12 +29,12 @@ func _process(delta: float) -> void:
if _moving_timer <= 0: if _moving_timer <= 0:
if _move_to != Vector3.ZERO: if _move_to != Vector3.ZERO:
_move_to = Vector3.ZERO _move_to = Vector3.ZERO
moved.emit() tween_finished.emit()
return return
_moving_timer -= delta * MOVE_SPEED _moving_timer -= delta * TWEEN_SPEED
global_position = _move_from.bezier_interpolate( global_position = _move_from.bezier_interpolate(
_move_from + Vector3.UP * MOVE_ARC_HEIGHT, _move_from + Vector3.UP * TWEEN_ARC_HEIGHT,
_move_to + Vector3.UP * MOVE_ARC_HEIGHT, _move_to + Vector3.UP * TWEEN_ARC_HEIGHT,
_move_to, _move_to,
(1 - _moving_timer), (1 - _moving_timer),
) )
@ -58,7 +58,7 @@ func set_carried(on: bool) -> void:
collision_shape.disabled = carried collision_shape.disabled = carried
func start_moving(to: Vector3) -> Honeydew: func start_tweening(to: Vector3) -> Honeydew:
_moving_timer = 1 _moving_timer = 1
_move_from = global_position _move_from = global_position
_move_to = to _move_to = to

View File

@ -142,9 +142,9 @@ func _pick_up() -> void:
_carrying_items.append(_target) _carrying_items.append(_target)
_target.set_carried(true) _target.set_carried(true)
audio_player.play_sound(SoundManager.swoosh()) audio_player.play_sound(SoundManager.swoosh())
await _target.start_moving( await _target.start_tweening(
_get_nth_pile_pos(_carrying_items.size() - 1) _get_nth_pile_pos(_carrying_items.size() - 1)
).moved ).tween_finished
audio_player.play_sound(SoundManager.pop()) audio_player.play_sound(SoundManager.pop())
await get_tree().create_timer(_pickup_interval).timeout await get_tree().create_timer(_pickup_interval).timeout
@ -168,7 +168,7 @@ func _deposit() -> void:
var item := _carrying_items.pop_back() as Honeydew var item := _carrying_items.pop_back() as Honeydew
audio_player.play_sound(SoundManager.swoosh()) audio_player.play_sound(SoundManager.swoosh())
await item.start_moving(_unit.anthill.global_position).moved await item.start_tweening(_unit.anthill.global_position).tween_finished
audio_player.play_sound(SoundManager.tok()) audio_player.play_sound(SoundManager.tok())
item.remove_from_spawner() item.remove_from_spawner()