mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-23 00:24:21 +00:00
24 lines
801 B
GDScript
24 lines
801 B
GDScript
extends Tracker
|
|
class_name TrackerTracker
|
|
|
|
## Tracks [Tracker]s tracking the parent.
|
|
|
|
|
|
## Start [field tracking] a [Node2D] if it overlaps this [Area2D].
|
|
##
|
|
## Returns whether the body was added to the [field tracking] array.
|
|
func track_if_detected(body: Node2D) -> bool:
|
|
if overlaps_body(body):
|
|
return track(body)
|
|
return false
|
|
|
|
## Start [field tracking] a [Node2D] if it has a [Tracker] tracking this node or one of its ancestors.
|
|
##
|
|
## Returns whether the body was added to the [field tracking] array.
|
|
func track_if_tracked(body: Node2D) -> bool:
|
|
var act: bool = false
|
|
for tracker in body.find_children("*", "Tracker", true, false):
|
|
for ancestor in Traversal.get_ancestors(self): # Make more efficient, perhaps?
|
|
if ancestor in tracker.tracking:
|
|
act = track(body) or act
|
|
return act
|