EventIf
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								scripts/Event/Flow/EventIf.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								scripts/Event/Flow/EventIf.gd
									
									
									
									
									
										Normal 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()
 | 
			
		||||
							
								
								
									
										1
									
								
								scripts/Event/Flow/EventIf.gd.uid
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								scripts/Event/Flow/EventIf.gd.uid
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
uid://bn2nw17cf11wp
 | 
			
		||||
							
								
								
									
										58
									
								
								scripts/Event/Flow/EventIfFlag.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								scripts/Event/Flow/EventIfFlag.gd
									
									
									
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										1
									
								
								scripts/Event/Flow/EventIfFlag.gd.uid
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								scripts/Event/Flow/EventIfFlag.gd.uid
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
uid://ccujhcc446mvh
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user