mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Better handling of selection
This commit is contained in:
parent
acf3857129
commit
1c7afec7e2
2 changed files with 47 additions and 23 deletions
|
|
@ -37,7 +37,12 @@ public partial class ActivationProvider : Area2D
|
|||
{
|
||||
if (_inputProvider.GetUseJustPressed())
|
||||
{
|
||||
TrySelect();
|
||||
if (!TrySelect())
|
||||
{
|
||||
_selector.SelectNext();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_inputProvider.GetScanJustPressed())
|
||||
|
|
@ -46,33 +51,33 @@ public partial class ActivationProvider : Area2D
|
|||
}
|
||||
}
|
||||
|
||||
private void TrySelect()
|
||||
private bool TrySelect()
|
||||
{
|
||||
var selected = _selector.SelectedInteractable;
|
||||
if (selected is null)
|
||||
{
|
||||
_errorSound?.Play();
|
||||
return;
|
||||
return false;
|
||||
};
|
||||
if (!selected.CanActivate())
|
||||
{
|
||||
_errorSound?.Play();
|
||||
return;
|
||||
return true;
|
||||
};
|
||||
bool success = selected.Activate();
|
||||
|
||||
if (success)
|
||||
{
|
||||
// Deselect and scan for next
|
||||
_selector.RemoveInteractable(selected);
|
||||
//_selector.SelectedInteractable = null;
|
||||
//_selector.SelectNext();
|
||||
_selector.SelectNext();
|
||||
//_selector.RemoveInteractable(selected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_errorSound?.Play();
|
||||
}
|
||||
|
||||
return true;
|
||||
//var spaceState = GetWorld2D().DirectSpaceState;
|
||||
|
||||
//var query = PhysicsRayQueryParameters2D.Create(Vector2.Zero, )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue