Stealth: Allow guards to detect any node #1811
Open
+12
−12
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.
Previously, guard.gd would check that the detected node was an instance of the Player script. This could be limiting if, for example, we wanted to make a challenge whether the player needs to escort an NPC without the NPC or the player-character being detected.
We also wish to add a level to the Champ StoryQuest where the player-character is not an instance of our Player script/scene, but a simple hand-rolled CharacterBody2D. This is intended to provide a venue for participants to explore their own player-character implementation and abilities. Because a hand-rolled player cannot interact, fight, or grapple, the obvious mechanic to use in this level is stealth. So we would like it to be possible for guards to detect an arbitrary CharacterBody2D that happens to be in the "players" physics layer.
This is easy to achieve by removing the type checks, adjusting the signal signature, and in stealth_game_logic.gd use a duck-typing approach of calling the defeat() method on the detected node if it is present. Nowhere else is the specific API of the Player script used.
Helps #1738