Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,12 @@ position = Vector2(225, 152)
character_seed = 138976455

[node name="InteractArea" type="Area2D" parent="OnTheGround/Townie" unique_id=713209077]
visible = false
collision_layer = 32
collision_mask = 0
script = ExtResource("3_p47ir")

[node name="CollisionShape2D" type="CollisionShape2D" parent="OnTheGround/Townie/InteractArea" unique_id=780074207]
visible = false
position = Vector2(0, -29)
shape = SubResource("RectangleShape2D_22pcm")
debug_color = Color(0.600391, 0.54335, 0, 0.42)
Expand Down Expand Up @@ -772,12 +772,12 @@ sprite_frames = SubResource("SpriteFrames_3lql5")
sprite_frames = Array[SpriteFrames]([SubResource("SpriteFrames_ft3li"), SubResource("SpriteFrames_3lql5"), SubResource("SpriteFrames_txqd1"), SubResource("SpriteFrames_7xna1"), SubResource("SpriteFrames_y1u7u")])

[node name="InteractArea" type="Area2D" parent="OnTheGround/Townie2" unique_id=1760778420]
visible = false
collision_layer = 32
collision_mask = 0
script = ExtResource("3_p47ir")

[node name="CollisionShape2D" type="CollisionShape2D" parent="OnTheGround/Townie2/InteractArea" unique_id=1656214821]
visible = false
position = Vector2(0, -29)
shape = SubResource("RectangleShape2D_22pcm")
debug_color = Color(0.600391, 0.54335, 0, 0.42)
Expand Down Expand Up @@ -806,12 +806,12 @@ character_seed = 1246173203
look_at_side = 1

[node name="InteractArea" type="Area2D" parent="OnTheGround/Townie4" unique_id=785629688]
visible = false
collision_layer = 32
collision_mask = 0
script = ExtResource("3_p47ir")

[node name="CollisionShape2D" type="CollisionShape2D" parent="OnTheGround/Townie4/InteractArea" unique_id=36122957]
visible = false
position = Vector2(0, -29)
shape = SubResource("RectangleShape2D_22pcm")
debug_color = Color(0.600391, 0.54335, 0, 0.42)
Expand Down
1 change: 1 addition & 0 deletions scenes/game_elements/characters/npcs/cat/cat.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ action = "Pet the cat"
metadata/_custom_type_script = "uid://du8wfijr35r35"

[node name="CollisionShape2D" type="CollisionShape2D" parent="InteractArea" unique_id=1720455095]
visible = false
position = Vector2(5, -28)
shape = SubResource("RectangleShape2D_t04tf")
debug_color = Color(0.6290859, 0.52632225, 0.15803415, 0.41960785)
Expand Down
1 change: 0 additions & 1 deletion scenes/game_elements/characters/npcs/talker/talker.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ unique_name_in_owner = true
collision_layer = 32
collision_mask = 0
script = ExtResource("3_c0xhn")
interact_label_position = Vector2(0, -100)

[node name="CollisionShape2D" type="CollisionShape2D" parent="InteractArea" unique_id=792948505]
position = Vector2(0, -29)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
class_name PlayerInteraction
extends Node2D

## Emitted when [method can_interact] will return a different value.
signal can_interact_changed
## Emitted when the entity the player is able to interact with changes (possibly
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first read I though that you were trying to say either "the entity" or "the player", not both. But after a second read, I got it!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it's a tricky sentence...

## to nothing).
signal interact_action_changed

## The character that gains interaction.
## [br][br]
Expand All @@ -14,8 +15,6 @@ signal can_interact_changed
set = _set_character

@onready var character_sight: CharacterSight = %CharacterSight
@onready var interact_marker: Marker2D = %InteractMarker
@onready var interact_label: FixedSizeLabel = %InteractLabel

@onready var player: Player = self.owner as Player

Expand All @@ -25,10 +24,15 @@ func _set_character(new_character: CharacterBody2D) -> void:
update_configuration_warnings()


## Returns [code]true[/code] if the character is currently able to interact with
## something in the environment.
func can_interact() -> bool:
return character_sight.interact_area != null
## Returns the human-readable text of [member character]'s current interact
## action (e.g. [code]"Talk"[/code]), or [code]""[/code] (empty string) if
## [member character] cannot currently interact with anything. Use [signal
## interact_action_changed] to monitor for changes.
func get_interact_action() -> String:
Comment on lines +27 to +31
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if character_sight.interact_area != null:
var action := character_sight.interact_area.action
return action if action else tr("Interact")
return ""


func _is_interacting() -> bool:
Expand All @@ -47,14 +51,6 @@ func _ready() -> void:
_on_character_sight_interact_area_changed()


func _process(_delta: float) -> void:
if not character_sight.interact_area:
return
interact_marker.global_position = (
character_sight.interact_area.get_global_interact_label_position()
)


func _unhandled_input(_event: InputEvent) -> void:
if _is_interacting():
return
Expand All @@ -68,7 +64,6 @@ func _unhandled_input(_event: InputEvent) -> void:

get_viewport().set_input_as_handled()
character_sight.monitoring = false
interact_label.visible = false
interact_area.interaction_ended.connect(_on_interaction_ended, CONNECT_ONE_SHOT)
interact_area.start_interaction(player, character_sight.is_looking_from_right)

Expand All @@ -81,13 +76,4 @@ func _on_interaction_ended() -> void:


func _on_character_sight_interact_area_changed() -> void:
if _is_interacting():
return

if not character_sight.interact_area:
interact_label.visible = false
else:
interact_label.visible = true
interact_label.label_text = character_sight.interact_area.action

can_interact_changed.emit()
interact_action_changed.emit()
17 changes: 0 additions & 17 deletions scenes/game_elements/characters/player/player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
[ext_resource type="Script" uid="uid://bpu6jo4kvehlg" path="res://scenes/game_elements/characters/player/components/player_interaction.gd" id="3_dqkch"]
[ext_resource type="Script" uid="uid://qro4uo83ba8f" path="res://scenes/game_elements/characters/player/components/player_sprite.gd" id="3_qlg0r"]
[ext_resource type="Script" uid="uid://necvar42rnih" path="res://scenes/game_elements/props/character_sight/character_sight.gd" id="6_3in67"]
[ext_resource type="PackedScene" uid="uid://yfpfno276rol" path="res://scenes/game_elements/props/fixed_size_label/fixed_size_label.tscn" id="6_h17s1"]
[ext_resource type="Script" uid="uid://e78f8iq448e1" path="res://scenes/game_elements/characters/player/components/animation_player.gd" id="7_0owmy"]
[ext_resource type="AudioStream" uid="uid://cx6jv2cflrmqu" path="res://assets/third_party/sounds/characters/player/Foot.ogg" id="11_blfj0"]
[ext_resource type="Texture2D" uid="uid://dxaq5piwxqnht" path="res://scenes/game_elements/characters/player/components/dust.png" id="12_3in67"]
Expand Down Expand Up @@ -420,22 +419,6 @@ position = Vector2(47, -30)
shape = SubResource("RectangleShape2D_blfj0")
debug_color = Color(0.600391, 0.54335, 0, 0.42)

[node name="InteractMarker" type="Marker2D" parent="PlayerInteraction" unique_id=439387414]
unique_name_in_owner = true
position = Vector2(-1, -116)

[node name="InteractLabel" parent="PlayerInteraction/InteractMarker" unique_id=554498577 instance=ExtResource("6_h17s1")]
unique_name_in_owner = true
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 1.0
offset_top = 11.0
offset_right = 1.0
offset_bottom = 11.0
grow_horizontal = 2
grow_vertical = 2

[node name="PlayerRepel" parent="." unique_id=1324972992 instance=ExtResource("12_tnibl")]
unique_name_in_owner = true
position = Vector2(0, -24)
Expand Down
13 changes: 9 additions & 4 deletions scenes/game_elements/props/character_sight/character_sight.gd
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@ func _process(_delta: float) -> void:


func _on_area_entered(_area: Area2D) -> void:
interact_area = _get_best_interact_area()
interact_area_changed.emit()
_update_interact_area()


func _on_area_exited(_area: Area2D) -> void:
interact_area = _get_best_interact_area()
interact_area_changed.emit()
_update_interact_area()


func _update_interact_area() -> void:
var best := _get_best_interact_area()
if interact_area != best:
interact_area = best
interact_area_changed.emit()
7 changes: 5 additions & 2 deletions scenes/game_elements/props/checkpoint/checkpoint.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ sprite_frames = ExtResource("4_3xcwf")
animation = &"idle"
autoplay = "idle"

[node name="InteractArea" type="Area2D" parent="." unique_id=2037902510]
[node name="InteractArea" type="Area2D" parent="." unique_id=2037902510 node_paths=PackedStringArray("marker")]
unique_name_in_owner = true
collision_layer = 0
collision_mask = 0
script = ExtResource("4_bjlxs")
interact_label_position = Vector2(0, -128)
marker = NodePath("Marker")
disabled = true
action = "Admire"
metadata/_custom_type_script = "uid://du8wfijr35r35"
Expand All @@ -39,6 +39,9 @@ position = Vector2(1, -4)
shape = SubResource("CircleShape2D_3xcwf")
debug_color = Color(0.600391, 0.54335, 0, 0.42)

[node name="Marker" type="Marker2D" parent="InteractArea" unique_id=1178774098]
position = Vector2(0, -128)

[node name="TalkBehavior" type="Node" parent="." unique_id=487856562 node_paths=PackedStringArray("interact_area")]
unique_name_in_owner = true
script = ExtResource("5_3xcwf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ tracks/6/keys = {
"update": 0,
"values": [0.0]
}
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("InteractArea:disabled")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="Animation" id="Animation_7ff3m"]
resource_name = "collected"
Expand Down Expand Up @@ -197,6 +209,18 @@ tracks/7/keys = {
"update": 0,
"values": [0.0, 0.0, -12.0]
}
tracks/8/type = "value"
tracks/8/imported = false
tracks/8/enabled = true
tracks/8/path = NodePath("InteractArea:disabled")
tracks/8/interp = 1
tracks/8/loop_wrap = true
tracks/8/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}

[sub_resource type="Animation" id="Animation_qy0vu"]
resource_name = "reveal"
Expand Down Expand Up @@ -277,18 +301,21 @@ height = 28.0
[node name="CollectibleItem" type="Node2D" unique_id=327991066]
script = ExtResource("1_7ff3m")

[node name="InteractArea" type="Area2D" parent="." unique_id=1327503985]
[node name="InteractArea" type="Area2D" parent="." unique_id=1327503985 node_paths=PackedStringArray("marker")]
collision_layer = 32
collision_mask = 0
script = ExtResource("2_1kegn")
interact_label_position = Vector2(0, -71)
marker = NodePath("Marker")
action = "Collect"
metadata/_custom_type_script = "uid://du8wfijr35r35"

[node name="CollisionShape2D" type="CollisionShape2D" parent="InteractArea" unique_id=1121983883]
shape = SubResource("CircleShape2D_ghwae")
debug_color = Color(0.600391, 0.54335, 0, 0.42)

[node name="Marker" type="Marker2D" parent="InteractArea" unique_id=1961850851]
position = Vector2(0, -48)

[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1869284545]
libraries/ = SubResource("AnimationLibrary_8dm1m")

Expand Down
8 changes: 5 additions & 3 deletions scenes/game_elements/props/eternal_loom/eternal_loom.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,13 @@ position = Vector2(-1.5, 32)
shape = SubResource("RectangleShape2D_uojly")
debug_color = Color(0, 0.588235, 0.698039, 0.419608)

[node name="InteractArea" type="Area2D" parent="." unique_id=1735004807]
[node name="InteractArea" type="Area2D" parent="." unique_id=1735004807 node_paths=PackedStringArray("marker")]
unique_name_in_owner = true
visible = false
position = Vector2(0, 55)
collision_layer = 32
collision_mask = 0
script = ExtResource("3_mjlja")
interact_label_position = Vector2(0, 45)
marker = NodePath("Marker")
action = "Use Eternal Loom"
metadata/_custom_type_script = "uid://du8wfijr35r35"

Expand All @@ -558,6 +557,9 @@ position = Vector2(0, 120)
shape = SubResource("RectangleShape2D_uhynt")
debug_color = Color(0.600391, 0.54335, 0, 0.42)

[node name="Marker" type="Marker2D" parent="InteractArea" unique_id=556753843]
position = Vector2(0, -152)

[node name="TalkBehavior" type="Node" parent="." unique_id=562216088 node_paths=PackedStringArray("interact_area")]
unique_name_in_owner = true
script = ExtResource("4_eq7jh")
Expand Down
Loading
Loading