This commit is contained in:
2025-05-20 08:24:38 -05:00
parent 6b2fa2b381
commit 36762682b8
8 changed files with 150 additions and 21 deletions

View File

@@ -1,7 +1,40 @@
class_name EventFlagOn extends "res://scripts/Event/Event.gd"
@export var event:EventSystem.SpecialEvent;
@export_flags("1:1", "2:2", "3:4", "4:8", "5:16", "6:32", "7:64", "8:128", "9:256", "10:512", "11:1024", "12:2048", "13:4096", "14:8192", "15:16384", "16:32768")
@export_flags(
"1:1",
"2:2",
"3:4",
"4:8",
"5:16",
"6:32",
"7:64",
"8:128",
"9:256",
"10:512",
"11:1024",
"12:2048",
"13:4096",
"14:8192",
"15:16384",
"16:32768",
"17:65536",
"18:131072",
"19:262144",
"20:524288",
"21:1048576",
"22:2097152",
"23:4194304",
"24:8388608",
"25:16777216",
"26:33554432",
"27:67108864",
"28:134217728",
"29:268435456",
"30:536870912",
"31:1073741824",
"32:2147483648"
)
var eventFlag:int = 0;
func start() -> void:

View File

@@ -8,21 +8,28 @@ enum ProcessType {
@export var processType:ProcessType = ProcessType.SEQUENTIAL;
var childIndex:int = 0
var eventGroupStarted:bool = false
func shouldAutoStart() -> bool:
return true
func start() -> void:
super.start()
# If sequential, start first child
if shouldAutoStart():
startEventGroup()
func startEventGroup() -> void:
eventGroupStarted = true
# This is called by the parent event to start the group
if processType == ProcessType.SEQUENTIAL:
childIndex = -1
nextChild()
# If parallel, start all children
elif processType == ProcessType.PARALLEL:
for child in childEvents:
startChild(child)
func update(delta:float) -> void:
super.update(delta)
@@ -42,6 +49,9 @@ func nextChild() -> void:
func isDone() -> bool:
if !super.isDone():
return false
if started && !eventGroupStarted:
return true
# If sequential, check if we've reached the end of the children
if processType == ProcessType.SEQUENTIAL:
@@ -66,6 +76,7 @@ func end() -> void:
func reset() -> void:
childIndex = -1
eventGroupStarted = false
for child in childEvents:
child.reset()
# Send to the parent to reset the extra events

View File

@@ -0,0 +1,13 @@
class_name EventIf extends "res://scripts/Event/Flow/EventGroup.gd"
func ifCondition() -> bool:
return false
func shouldAutoStart() -> bool:
return false
func start() -> void:
super.start()
if ifCondition():
startEventGroup()

View File

@@ -0,0 +1 @@
uid://bn2nw17cf11wp

View File

@@ -0,0 +1,58 @@
class_name EventIfEvent extends "res://scripts/Event/Flow/EventIf.gd"
enum Type {
ANY_OF_FLAGS_ON,
ALL_OF_FLAGS_ON,
ANY_OF_FLAGS_OFF,
ALL_OF_FLAGS_OFF,
}
@export var event:EventSystem.SpecialEvent;
@export var type:Type = Type.ANY_OF_FLAGS_ON;
@export_flags(
"1:1",
"2:2",
"3:4",
"4:8",
"5:16",
"6:32",
"7:64",
"8:128",
"9:256",
"10:512",
"11:1024",
"12:2048",
"13:4096",
"14:8192",
"15:16384",
"16:32768",
"17:65536",
"18:131072",
"19:262144",
"20:524288",
"21:1048576",
"22:2097152",
"23:4194304",
"24:8388608",
"25:16777216",
"26:33554432",
"27:67108864",
"28:134217728",
"29:268435456",
"30:536870912",
"31:1073741824",
"32:2147483648"
)
var eventFlag:int = 0;
func ifCondition() -> bool:
match type:
Type.ANY_OF_FLAGS_ON:
return EVENT.eventIsAnyOfFlagsOn(event, eventFlag)
Type.ALL_OF_FLAGS_ON:
return EVENT.eventAreFlagsOn(event, eventFlag)
Type.ANY_OF_FLAGS_OFF:
return EVENT.eventIsAnyOfFlagsOff(event, eventFlag)
Type.ALL_OF_FLAGS_OFF:
return EVENT.eventAreFlagsOff(event, eventFlag)
return false

View File

@@ -0,0 +1 @@
uid://ccujhcc446mvh

View File

@@ -13,7 +13,7 @@ func _ready() -> void:
for i in range(0, EventSystem.EVENT_FLAG_COUNT):
var checkbox:CheckBox = CheckBox.new()
checkbox.text = "Flag %s" % str(i)
checkbox.text = "Flag %s" % str(i+1)
grid.add_child(checkbox)
checkboxes.append(checkbox)
checkbox.pressed.connect(_on_CheckboxPressed)