meat_madness_redux/godot/player/ObjectiveTracker.gd

14 lines
448 B
GDScript

extends Node
var objective_who: WeakRef = weakref(null)
var objective_distance: float = 999999999999999.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