Skip to content

Commit 5f0318f

Browse files
food-pleaseNathanLovato
authored andcommitted
Clean up Interactions in Main.tscn
1 parent 31a903c commit 5f0318f

File tree

17 files changed

+193
-282
lines changed

17 files changed

+193
-282
lines changed

overworld/maps/default_gameboard.tres

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Main2.tscn

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/field/cutscenes/Trigger.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ script = ExtResource("1_htew5")
1111
[node name="Area2D" type="Area2D" parent="."]
1212
collision_layer = 32
1313
collision_mask = 4
14+
monitoring = false
1415

1516
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
1617
shape = SubResource("RectangleShape2D_dru4t")

src/field/cutscenes/popups/interaction_popup.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ position = Vector2(0, -12)
1919
show_behind_parent = true
2020
collision_layer = 0
2121
collision_mask = 4
22+
input_pickable = false
2223
monitorable = false
2324

2425
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" index="0"]

src/field/cutscenes/templates/doors/door.gd

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
@tool
2-
32
class_name Door extends AreaTransition
43

54
@export var is_locked: = false:
65
set(value):
7-
is_locked = value
8-
9-
if not Engine.is_editor_hint():
10-
if not is_inside_tree():
11-
await ready
12-
13-
_blocking_area.get_node("CollisionShape2D").disabled = !is_locked
6+
if value != is_locked:
7+
is_locked = value
8+
if not is_locked:
9+
open()
1410

1511
@onready var _anim: = $AnimationPlayer as AnimationPlayer
16-
@onready var _blocking_area: = $Area2D/ClosedDoor/BlockingArea as Area2D
1712
@onready var _closed_door: = $Area2D/ClosedDoor as Sprite2D
1813

1914

src/field/cutscenes/templates/doors/door.tscn

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=14 format=3 uid="uid://p0e4b0txynkd"]
1+
[gd_scene load_steps=13 format=3 uid="uid://p0e4b0txynkd"]
22

33
[ext_resource type="PackedScene" uid="uid://bd624fi8r2avm" path="res://src/field/cutscenes/templates/area_transitions/area_transition.tscn" id="1_0tk0k"]
44
[ext_resource type="Texture2D" uid="uid://d2qfi5sncf72b" path="res://overworld/maps/tilesets/town_tilemap.png" id="2_4mdkx"]
@@ -8,9 +8,6 @@
88
[ext_resource type="AudioStream" uid="uid://bt1obi05x1xda" path="res://assets/sfx/impactWood_light_002.ogg" id="6_ui4yk"]
99
[ext_resource type="FontFile" uid="uid://cfhyd5hmym1s4" path="res://assets/gui/font/Kenney Pixel.ttf" id="7_er0br"]
1010

11-
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xgpwx"]
12-
size = Vector2(15, 15)
13-
1411
[sub_resource type="Animation" id="Animation_8loys"]
1512
length = 0.001
1613
tracks/0/type = "value"
@@ -22,7 +19,7 @@ tracks/0/loop_wrap = true
2219
tracks/0/keys = {
2320
"times": PackedFloat32Array(0),
2421
"transitions": PackedFloat32Array(1),
25-
"update": 1,
22+
"update": 0,
2623
"values": [true]
2724
}
2825
tracks/1/type = "value"
@@ -134,7 +131,7 @@ tracks/0/loop_wrap = true
134131
tracks/0/keys = {
135132
"times": PackedFloat32Array(0),
136133
"transitions": PackedFloat32Array(1),
137-
"update": 1,
134+
"update": 0,
138135
"values": [false]
139136
}
140137
tracks/1/type = "audio"
@@ -172,6 +169,7 @@ is_locked = false
172169

173170
[node name="Area2D" parent="." index="0"]
174171
position = Vector2(0, -8)
172+
monitoring = true
175173

176174
[node name="OpenDoor" type="Sprite2D" parent="Area2D" index="1"]
177175
texture = ExtResource("2_4mdkx")
@@ -183,16 +181,9 @@ texture = ExtResource("2_4mdkx")
183181
region_enabled = true
184182
region_rect = Rect2(17, 119, 16, 16)
185183

186-
[node name="BlockingArea" type="Area2D" parent="Area2D/ClosedDoor" index="0"]
187-
collision_mask = 0
188-
monitoring = false
189-
190-
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D/ClosedDoor/BlockingArea" index="0"]
191-
shape = SubResource("RectangleShape2D_xgpwx")
192-
193184
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="3"]
194185
libraries = {
195-
"": SubResource("AnimationLibrary_k2tlp")
186+
&"": SubResource("AnimationLibrary_k2tlp")
196187
}
197188
autoplay = "RESET"
198189

src/field/cutscenes/trigger.gd

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -8,100 +8,100 @@
88
@icon("res://assets/editor/icons/Contact.svg")
99
class_name Trigger extends Cutscene
1010

11-
## Emitted when a [Gamepiece] begins moving to the cell occupied by the [code]Trigger[/code].
12-
signal gamepiece_entered(gamepiece: Gamepiece)
13-
14-
## Emitted when a [Gamepiece] begins moving away from the cell occupied by the [code]Trigger[/code].
15-
signal gamepiece_exited(gamepiece: Gamepiece)
16-
17-
## Emitted when a [Gamepiece] is finishing moving to the cell occupied by the [code]Trigger[/code].
18-
signal triggered(gamepiece: Gamepiece)
19-
20-
## An active [code]Trigger[/code] may be run, whereas one that is inactive may only be run
21-
## directly through code via the [method Cutscene.run] method.
22-
@export var is_active: = true:
23-
set(value):
24-
is_active = value
25-
26-
if not Engine.is_editor_hint():
27-
if not is_inside_tree():
28-
await ready
29-
30-
# We use "Visible Collision Shapes" to debug positions on the gameboard, so we'll want
31-
# to change the state of child collision shapes.These could be either CollisionShape2Ds
32-
# or CollisionPolygon2Ds.
33-
# Note that we only want to disable the collision shapes of objects that are actually
34-
# connected to this Interaction.
35-
for data in get_incoming_connections():
36-
var callable: = data["callable"] as Callable
37-
if callable == _on_area_entered :
38-
var connected_area: = data["signal"].get_object() as Area2D
39-
if connected_area:
40-
for node in connected_area.find_children("*", "CollisionShape2D"):
41-
(node as CollisionShape2D).disabled = !is_active
42-
for node in connected_area.find_children("*", "CollisionPolygon2D"):
43-
(node as CollisionPolygon2D).disabled = !is_active
44-
45-
46-
func _ready() -> void:
47-
if not Engine.is_editor_hint():
48-
FieldEvents.input_paused.connect(_on_input_paused)
49-
50-
51-
# Ensure that something is connected to _on_area_entered, which the Trigger requires.
52-
# If nothing is connected, issue a configuration warning.
53-
func _get_configuration_warnings() -> PackedStringArray:
54-
var warnings: PackedStringArray = []
55-
var has_area_entered_bindings: = false
56-
57-
for data in get_incoming_connections():
58-
if data["callable"] == _on_area_entered:
59-
has_area_entered_bindings = true
60-
61-
if not has_area_entered_bindings:
62-
warnings.append("This object does not have a CollisionObject2D's signals connected to " +
63-
"this Trigger's _on_area_entered method. The Trigger will never be triggered!")
64-
return warnings
65-
66-
67-
# Pause any collision objects that would normally send signals regarding interactions.
68-
# This will automatically accept or ignore currently overlapping areas.
69-
func _on_input_paused(is_paused: bool) -> void:
70-
for data in get_incoming_connections():
71-
# Note that we only want to check _on_area_entered, since _on_area_exited will clean up any
72-
# lingering references once the Area2Ds are 'shut off' (i.e. not monitoring/monitorable).
73-
if data["callable"] == _on_area_entered:
74-
var connected_area: = data["signal"].get_object() as Area2D
75-
if connected_area:
76-
connected_area.monitoring = !is_paused
77-
connected_area.monitorable = !is_paused
78-
79-
80-
# Register the colliding gamepiece and wait for it to finish moving before running the trigger.
81-
func _on_area_entered(area: Area2D) -> void:
82-
var gamepiece: = area.owner as Gamepiece
83-
84-
# Check to make sure that the gamepiece is moving before connecting to its 'arriving'
85-
# signal. This catches edge cases where the Trigger is unpaused while a colliding object
86-
# is standing on top of it (which would mean that _on_gamepiece_arriving would trigger once
87-
# the gamepiece moves OFF of it. Which is bad.).
88-
if gamepiece and gamepiece.is_moving():
89-
gamepiece_entered.emit(gamepiece)
90-
gamepiece.arriving.connect(_on_gamepiece_arriving.bind(gamepiece), CONNECT_ONE_SHOT)
91-
92-
# Triggers need to block input early. Otherwise, if waiting until the gamepiece is arriving,
93-
# there's a chance that the player's controller may have received the gamepiece.arriving
94-
# signal first and continue moving the gamepiece.
95-
await get_tree().process_frame
96-
_is_cutscene_in_progress = true
97-
98-
99-
func _on_area_exited(area: Area2D) -> void:
100-
var gamepiece: = area.owner as Gamepiece
101-
if gamepiece:
102-
gamepiece_exited.emit(gamepiece)
103-
104-
105-
func _on_gamepiece_arriving(_distance: float, gamepiece: Gamepiece) -> void:
106-
triggered.emit(gamepiece)
107-
run()
11+
### Emitted when a [Gamepiece] begins moving to the cell occupied by the [code]Trigger[/code].
12+
#signal gamepiece_entered(gamepiece: Gamepiece)
13+
#
14+
### Emitted when a [Gamepiece] begins moving away from the cell occupied by the [code]Trigger[/code].
15+
#signal gamepiece_exited(gamepiece: Gamepiece)
16+
#
17+
### Emitted when a [Gamepiece] is finishing moving to the cell occupied by the [code]Trigger[/code].
18+
#signal triggered(gamepiece: Gamepiece)
19+
#
20+
### An active [code]Trigger[/code] may be run, whereas one that is inactive may only be run
21+
### directly through code via the [method Cutscene.run] method.
22+
#@export var is_active: = true:
23+
#set(value):
24+
#is_active = value
25+
#
26+
#if not Engine.is_editor_hint():
27+
#if not is_inside_tree():
28+
#await ready
29+
#
30+
## We use "Visible Collision Shapes" to debug positions on the gameboard, so we'll want
31+
## to change the state of child collision shapes.These could be either CollisionShape2Ds
32+
## or CollisionPolygon2Ds.
33+
## Note that we only want to disable the collision shapes of objects that are actually
34+
## connected to this Interaction.
35+
#for data in get_incoming_connections():
36+
#var callable: = data["callable"] as Callable
37+
#if callable == _on_area_entered :
38+
#var connected_area: = data["signal"].get_object() as Area2D
39+
#if connected_area:
40+
#for node in connected_area.find_children("*", "CollisionShape2D"):
41+
#(node as CollisionShape2D).disabled = !is_active
42+
#for node in connected_area.find_children("*", "CollisionPolygon2D"):
43+
#(node as CollisionPolygon2D).disabled = !is_active
44+
#
45+
#
46+
#func _ready() -> void:
47+
#if not Engine.is_editor_hint():
48+
#FieldEvents.input_paused.connect(_on_input_paused)
49+
#
50+
#
51+
## Ensure that something is connected to _on_area_entered, which the Trigger requires.
52+
## If nothing is connected, issue a configuration warning.
53+
#func _get_configuration_warnings() -> PackedStringArray:
54+
#var warnings: PackedStringArray = []
55+
#var has_area_entered_bindings: = false
56+
#
57+
#for data in get_incoming_connections():
58+
#if data["callable"] == _on_area_entered:
59+
#has_area_entered_bindings = true
60+
#
61+
#if not has_area_entered_bindings:
62+
#warnings.append("This object does not have a CollisionObject2D's signals connected to " +
63+
#"this Trigger's _on_area_entered method. The Trigger will never be triggered!")
64+
#return warnings
65+
#
66+
#
67+
## Pause any collision objects that would normally send signals regarding interactions.
68+
## This will automatically accept or ignore currently overlapping areas.
69+
#func _on_input_paused(is_paused: bool) -> void:
70+
#for data in get_incoming_connections():
71+
## Note that we only want to check _on_area_entered, since _on_area_exited will clean up any
72+
## lingering references once the Area2Ds are 'shut off' (i.e. not monitoring/monitorable).
73+
#if data["callable"] == _on_area_entered:
74+
#var connected_area: = data["signal"].get_object() as Area2D
75+
#if connected_area:
76+
#connected_area.monitoring = !is_paused
77+
#connected_area.monitorable = !is_paused
78+
#
79+
#
80+
## Register the colliding gamepiece and wait for it to finish moving before running the trigger.
81+
#func _on_area_entered(area: Area2D) -> void:
82+
#var gamepiece: = area.owner as Gamepiece
83+
#
84+
## Check to make sure that the gamepiece is moving before connecting to its 'arriving'
85+
## signal. This catches edge cases where the Trigger is unpaused while a colliding object
86+
## is standing on top of it (which would mean that _on_gamepiece_arriving would trigger once
87+
## the gamepiece moves OFF of it. Which is bad.).
88+
#if gamepiece and gamepiece.is_moving():
89+
#gamepiece_entered.emit(gamepiece)
90+
#gamepiece.arriving.connect(_on_gamepiece_arriving.bind(gamepiece), CONNECT_ONE_SHOT)
91+
#
92+
## Triggers need to block input early. Otherwise, if waiting until the gamepiece is arriving,
93+
## there's a chance that the player's controller may have received the gamepiece.arriving
94+
## signal first and continue moving the gamepiece.
95+
#await get_tree().process_frame
96+
#_is_cutscene_in_progress = true
97+
#
98+
#
99+
#func _on_area_exited(area: Area2D) -> void:
100+
#var gamepiece: = area.owner as Gamepiece
101+
#if gamepiece:
102+
#gamepiece_exited.emit(gamepiece)
103+
#
104+
#
105+
#func _on_gamepiece_arriving(_distance: float, gamepiece: Gamepiece) -> void:
106+
#triggered.emit(gamepiece)
107+
#run()

0 commit comments

Comments
 (0)