meat_madness_redux/godot/player/ObjectiveTracker.gd

14 lines
434 B
GDScript

extends Node
var objective_who: WeakRef = weakref(null)
var objective_distance: float = 0.0
func _ready():
var _ignored = GlobalEventBus.connect("player_objective_ping", self, "update_objective_distance")
func update_objective_distance(who: Node, distance: float):
var node = objective_who.get_ref()
if node == null or node == who or distance < objective_distance:
objective_who = weakref(who)
objective_distance = distance