2023-06-13 21:36:01 +02:00
|
|
|
class_name MoveToDestinationAction
|
2023-06-12 16:48:35 +02:00
|
|
|
extends ActionLeaf
|
|
|
|
|
2023-06-12 18:50:58 +02:00
|
|
|
func before_run(actor, blackboard):
|
|
|
|
var destination = blackboard.get_value("destination")
|
2023-07-01 13:26:45 +02:00
|
|
|
actor.flip_sprite(destination)
|
|
|
|
actor.play_walk_animation()
|
2023-06-12 16:48:35 +02:00
|
|
|
|
2023-06-12 18:50:58 +02:00
|
|
|
func tick(actor: Node, blackboard: Blackboard):
|
|
|
|
var destination = blackboard.get_value("destination")
|
2023-07-01 13:26:45 +02:00
|
|
|
actor.move_to(destination)
|
2023-06-12 16:48:35 +02:00
|
|
|
|
2023-06-12 18:50:58 +02:00
|
|
|
if actor.position == destination:
|
2023-07-01 18:56:45 +02:00
|
|
|
actor.next_destination = null
|
2023-06-12 16:48:35 +02:00
|
|
|
return SUCCESS
|
|
|
|
return RUNNING
|
2023-06-18 20:30:25 +02:00
|
|
|
|
|
|
|
func after_run(actor, blackboard):
|
2023-07-01 13:26:45 +02:00
|
|
|
actor.play_idle_animation()
|
|
|
|
# Debug
|
2023-06-18 20:30:25 +02:00
|
|
|
var destination = blackboard.get_value("destination")
|
2023-07-01 13:26:45 +02:00
|
|
|
actor.reset_tile(destination)
|