Cleaned and improved some event stuff

This commit is contained in:
2025-05-26 13:11:27 -05:00
parent c1d8dd46d8
commit d6a2f4b567
27 changed files with 296 additions and 108 deletions

View File

@@ -1,7 +1,7 @@
class_name EventWithChildren extends "res://scripts/Event/Event.gd"
var childEvents:Array[Event] = []
var extraEvents:Array[Event] = []
var addedEvents:Array[Event] = []
func start():
super.start()
@@ -22,16 +22,29 @@ func _updateChildEvents() -> void:
childEvents.append(child)
func _cleanupExtraEvents():
for event in extraEvents:
for event in addedEvents:
remove_child(event)
event.queue_free()
extraEvents = []
addedEvents = []
_updateChildEvents()
func addExtraEvent(child:Event, position:int) -> void:
func addChildEvent(child:Event, position:int = -1) -> void:
assert(started == false || ended == true)
# Add the child to the extra events list
extraEvents.append(child)
if position < 0:
position = childEvents.size() + position + 1
add_child(child)
move_child(child, position)
_updateChildEvents()
addedEvents.append(child)
_updateChildEvents()
func startChild(child:Event) -> void:
assert(child.get_parent() == self)
# Inherits some properties from this event.
child.interactee = self.interactee
child.interactor = self.interactor
child.start()
if child.isEndingEvent():
self.end()