mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 15:15:54 +00:00
Automatic box deselection
This commit is contained in:
parent
cc5376e94e
commit
ad985ce1ac
6 changed files with 73 additions and 19 deletions
|
|
@ -121,9 +121,15 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
private void FindInteractable()
|
||||
{
|
||||
if (Input.IsActionJustPressed("Use") && _selector.SelectedInteractable != null)
|
||||
if (!Input.IsActionJustPressed("Use") || _selector.SelectedInteractable == null) return;
|
||||
if (!_selector.SelectedInteractable.CanActivate()) return;
|
||||
bool success = _selector.SelectedInteractable.Activate();
|
||||
|
||||
if (success)
|
||||
{
|
||||
_selector.SelectedInteractable.Activate();
|
||||
// Deselect and scan for next
|
||||
_selector.SelectedInteractable = null;
|
||||
_selector.SelectNext();
|
||||
}
|
||||
|
||||
//var spaceState = GetWorld2D().DirectSpaceState;
|
||||
|
|
@ -261,7 +267,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
private void _on_interaction_controller_area_entered(Area2D area)
|
||||
{
|
||||
// Replace with function body.
|
||||
if (area.IsInGroup("Interactable") && area is Interactable interactable)
|
||||
if (area.IsInGroup("Interactable") && area is Interactable interactable && interactable.CanActivate())
|
||||
{
|
||||
Debug.WriteLine($"Interactable {area.Name} Entered");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue