diff --git a/scenes/Maps/TestMap/TestMap.tscn b/scenes/Maps/TestMap/TestMap.tscn index f6dc0d0..a7a26f1 100644 --- a/scenes/Maps/TestMap/TestMap.tscn +++ b/scenes/Maps/TestMap/TestMap.tscn @@ -12,7 +12,7 @@ [ext_resource type="PackedScene" uid="uid://bkj630bhmnvsi" path="res://scenes/Entities/Sign.tscn" id="9_xfqoe"] [ext_resource type="Script" uid="uid://b41umpbgqfuc2" path="res://scripts/Event/Item/EventGetItem.gd" id="10_avybc"] [ext_resource type="Script" uid="uid://0ygswaohp7kj" path="res://scripts/Event/EventFlagModify.gd" id="12_ncdgy"] -[ext_resource type="Script" uid="uid://da7fr2bave0c" path="res://scripts/Event/Flow/EventGoTo.gd" id="13_60ixl"] +[ext_resource type="Script" uid="uid://ccujhcc446mvh" path="res://scripts/Event/Flow/EventIfFlag.gd" id="13_60ixl"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_e1h75"] sky_horizon_color = Color(0.59625, 0.6135, 0.6375, 1) @@ -79,38 +79,50 @@ omni_range = 281.646 [node name="TestConversation" type="Node" parent="Events"] script = ExtResource("5_cg1ph") -[node name="EventFlagModify" type="Node" parent="Events/TestConversation"] -script = ExtResource("12_ncdgy") -action = 4 +[node name="EventIfEvent2" type="Node" parent="Events/TestConversation"] +script = ExtResource("13_60ixl") event = 1 -eventFlag = 1539 -metadata/_custom_type_script = "uid://0ygswaohp7kj" +eventFlag = 1 +metadata/_custom_type_script = "uid://ccujhcc446mvh" -[node name="Text 0" type="Node" parent="Events/TestConversation"] +[node name="Text 0" type="Node" parent="Events/TestConversation/EventIfEvent2"] +script = ExtResource("6_gxq5o") +text = "Go find those ingredients!" + +[node name="EventIfEvent" type="Node" parent="Events/TestConversation"] +script = ExtResource("13_60ixl") +event = 1 +type = 2 +eventFlag = 1 +metadata/_custom_type_script = "uid://ccujhcc446mvh" + +[node name="Text 0" type="Node" parent="Events/TestConversation/EventIfEvent"] script = ExtResource("6_gxq5o") text = "I am giving you a quest to gather some ingredients." -[node name="EventGoTo" type="Node" parent="Events/TestConversation" node_paths=PackedStringArray("event")] -script = ExtResource("13_60ixl") -event = NodePath("../../TextTest") - -[node name="Quest" type="Node" parent="Events/TestConversation"] +[node name="Quest" type="Node" parent="Events/TestConversation/EventIfEvent"] script = ExtResource("7_brp0k") metadata/_custom_type_script = "uid://c4d7nithqnx5y" -[node name="Text 1" type="Node" parent="Events/TestConversation"] +[node name="Text 1" type="Node" parent="Events/TestConversation/EventIfEvent"] script = ExtResource("6_gxq5o") text = "Thanks for closing the quest menu" -[node name="Get Item" type="Node" parent="Events/TestConversation"] +[node name="Get Item" type="Node" parent="Events/TestConversation/EventIfEvent"] script = ExtResource("10_avybc") getType = 1 metadata/_custom_type_script = "uid://b41umpbgqfuc2" -[node name="Text 2" type="Node" parent="Events/TestConversation"] +[node name="Text 2" type="Node" parent="Events/TestConversation/EventIfEvent"] script = ExtResource("6_gxq5o") text = "Thanks for taking that potion." +[node name="EventFlagModify" type="Node" parent="Events/TestConversation/EventIfEvent"] +script = ExtResource("12_ncdgy") +event = 1 +eventFlag = 1 +metadata/_custom_type_script = "uid://0ygswaohp7kj" + [node name="TextTest" type="Node" parent="Events"] script = ExtResource("6_gxq5o") text = "testestest diff --git a/scripts/Event/EventFlagOn.gd b/scripts/Event/EventFlagOn.gd index fd10aeb..635cefd 100644 --- a/scripts/Event/EventFlagOn.gd +++ b/scripts/Event/EventFlagOn.gd @@ -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: diff --git a/scripts/Event/Flow/EventGroup.gd b/scripts/Event/Flow/EventGroup.gd index d1cf143..41f88ae 100644 --- a/scripts/Event/Flow/EventGroup.gd +++ b/scripts/Event/Flow/EventGroup.gd @@ -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 diff --git a/scripts/Event/Flow/EventIf.gd b/scripts/Event/Flow/EventIf.gd new file mode 100644 index 0000000..65149c6 --- /dev/null +++ b/scripts/Event/Flow/EventIf.gd @@ -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() \ No newline at end of file diff --git a/scripts/Event/Flow/EventIf.gd.uid b/scripts/Event/Flow/EventIf.gd.uid new file mode 100644 index 0000000..0b381c2 --- /dev/null +++ b/scripts/Event/Flow/EventIf.gd.uid @@ -0,0 +1 @@ +uid://bn2nw17cf11wp diff --git a/scripts/Event/Flow/EventIfFlag.gd b/scripts/Event/Flow/EventIfFlag.gd new file mode 100644 index 0000000..451ed8d --- /dev/null +++ b/scripts/Event/Flow/EventIfFlag.gd @@ -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 \ No newline at end of file diff --git a/scripts/Event/Flow/EventIfFlag.gd.uid b/scripts/Event/Flow/EventIfFlag.gd.uid new file mode 100644 index 0000000..27bbe86 --- /dev/null +++ b/scripts/Event/Flow/EventIfFlag.gd.uid @@ -0,0 +1 @@ +uid://ccujhcc446mvh diff --git a/scripts/UI/EventFlagMenu.gd b/scripts/UI/EventFlagMenu.gd index a54e29b..715d5ee 100644 --- a/scripts/UI/EventFlagMenu.gd +++ b/scripts/UI/EventFlagMenu.gd @@ -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)