-
Notifications
You must be signed in to change notification settings - Fork 315
Move interact verb/action to HUD #2150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| ## to nothing). | ||
| signal interact_action_changed | ||
|
|
||
| ## The character that gains interaction. | ||
| ## [br][br] | ||
|
|
@@ -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 | ||
|
|
||
|
|
@@ -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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
|
@@ -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 | ||
|
|
@@ -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) | ||
|
|
||
|
|
@@ -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() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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...