meat_madness_redux/godot/player/ObjectiveTracker.gd

14 lines
448 B
GDScript3
Raw Normal View History

2022-12-27 13:24:35 -07:00
extends Node
var objective_who: WeakRef = weakref(null)
2022-12-28 16:53:17 -07:00
var objective_distance: float = 999999999999999.0
2022-12-27 13:24:35 -07:00
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