23 lines
544 B
GDScript
23 lines
544 B
GDScript
class_name EventWithChildren extends "res://scripts/Events/Event.gd"
|
|
|
|
var childEvents:Array[Event] = []
|
|
|
|
func _init() -> void:
|
|
super._init()
|
|
_updateChildEvents()
|
|
_updateChildEvents()
|
|
self.child_entered_tree.connect(onChildEntered)
|
|
self.child_exiting_tree.connect(onChildExited)
|
|
|
|
func _updateChildEvents() -> void:
|
|
childEvents = []
|
|
for child in get_children():
|
|
if child is Event:
|
|
childEvents.append(child)
|
|
|
|
func onChildEntered(child:Node) -> void:
|
|
_updateChildEvents()
|
|
|
|
func onChildExited(child:Node) -> void:
|
|
_updateChildEvents()
|