Cleaned and improved some event stuff
This commit is contained in:
@@ -80,13 +80,4 @@ func reset() -> void:
|
||||
for child in childEvents:
|
||||
child.reset()
|
||||
# Send to the parent to reset the extra events
|
||||
super.reset()
|
||||
|
||||
func startChild(child:Event) -> void:
|
||||
# Inherits some properties from this event.
|
||||
child.interactee = self.interactee
|
||||
child.interactor = self.interactor
|
||||
child.start()
|
||||
|
||||
if child.isEndingEvent():
|
||||
self.end()
|
||||
super.reset()
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user