Fixed UI system
This commit is contained in:
37
scripts/Event/Flow/EventWithChildren.gd
Normal file
37
scripts/Event/Flow/EventWithChildren.gd
Normal file
@@ -0,0 +1,37 @@
|
||||
class_name EventWithChildren extends "res://scripts/Event/Event.gd"
|
||||
|
||||
var childEvents:Array[Event] = []
|
||||
var extraEvents:Array[Event] = []
|
||||
|
||||
func start():
|
||||
super.start()
|
||||
_updateChildEvents()
|
||||
|
||||
func reset() -> void:
|
||||
super.reset()
|
||||
_cleanupExtraEvents()
|
||||
|
||||
func end() -> void:
|
||||
super.end()
|
||||
_cleanupExtraEvents()
|
||||
|
||||
func _updateChildEvents() -> void:
|
||||
childEvents = []
|
||||
for child in get_children():
|
||||
if child is Event:
|
||||
childEvents.append(child)
|
||||
|
||||
func _cleanupExtraEvents():
|
||||
for event in extraEvents:
|
||||
remove_child(event)
|
||||
event.queue_free()
|
||||
extraEvents = []
|
||||
_updateChildEvents()
|
||||
|
||||
func addExtraEvent(child:Event, position:int) -> void:
|
||||
assert(started == false || ended == true)
|
||||
# Add the child to the extra events list
|
||||
extraEvents.append(child)
|
||||
add_child(child)
|
||||
move_child(child, position)
|
||||
_updateChildEvents()
|
Reference in New Issue
Block a user