Browse Source

:sparkles: Simplify chocolate code

DricomDragon 2 months ago
parent
commit
69bcf84c44
1 changed files with 3 additions and 9 deletions
  1. 3 9
      godot/component/entity/collectibles/chocolate/chocolate.gd

+ 3 - 9
godot/component/entity/collectibles/chocolate/chocolate.gd

@@ -22,19 +22,13 @@ func _on_chocolate_tablet_body_entered(body: Node3D) -> void:
 
 func _give_chocolate_to(walker: Walker) -> void:
 	walker.give_chocolate()
-	_go_to.call_deferred(walker)
+	_go_to_pocket.call_deferred(walker)
 	chocolateAnimation.play(COLLECT_ANIM)
-	chocolateAnimation.animation_finished.connect(_finish)
 	pickupSound.play()
 
 
-func _go_to(walker: Walker) -> void:
+func _go_to_pocket(walker: Walker) -> void:
 	reparent(walker)
 	var center_tween = create_tween()
 	center_tween.tween_property(self, "position", walker.get_pocket_position(), COLLECT_DURATION)
-
-
-func _finish(animation_name: String) -> void:
-	if COLLECT_ANIM == animation_name:
-		# Collection is finished
-		queue_free()
+	center_tween.tween_callback(queue_free)