mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:05:34 +00:00
Interactable handling
This commit is contained in:
parent
a4b39a97dc
commit
d804441378
5 changed files with 89 additions and 17 deletions
|
|
@ -22,9 +22,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
[Export]
|
||||
public string GameOverScene { get; set; }
|
||||
|
||||
private Node2D _selector;
|
||||
private Selector _selector;
|
||||
|
||||
private Interactable _lastInteractable;
|
||||
//private Interactable _lastInteractable;
|
||||
|
||||
[Export]
|
||||
public Marker2D Muzzle { get; set; }
|
||||
|
|
@ -94,7 +94,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
if (SelectorScene != null)
|
||||
{
|
||||
_selector = this.CreateSibling<Node2D>(SelectorScene, this.GlobalPosition);
|
||||
_selector = this.CreateSibling<Selector>(SelectorScene, this.GlobalPosition);
|
||||
_selector.Visible = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -121,9 +121,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
private void FindInteractable()
|
||||
{
|
||||
if (Input.IsActionJustPressed("Use") && _lastInteractable != null)
|
||||
if (Input.IsActionJustPressed("Use") && _selector.SelectedInteractable != null)
|
||||
{
|
||||
_lastInteractable.Activate();
|
||||
_selector.SelectedInteractable.Activate();
|
||||
}
|
||||
|
||||
//var spaceState = GetWorld2D().DirectSpaceState;
|
||||
|
|
@ -267,12 +267,10 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
EmitSignal(nameof(InteractableAreaEntered), interactable);
|
||||
|
||||
if (_selector != null)
|
||||
{
|
||||
_selector.Position = interactable.Position;
|
||||
_selector.Visible = true;
|
||||
_lastInteractable = interactable;
|
||||
}
|
||||
if (_selector == null) return;
|
||||
_selector.Position = interactable.Position;
|
||||
//_selector.Visible = true;
|
||||
//_lastInteractable = interactable;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -283,6 +281,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
Debug.WriteLine($"Interactable {area.Name} Exited");
|
||||
|
||||
EmitSignal(nameof(InteractableAreaExited), interactable);
|
||||
|
||||
if (_selector == null) return;
|
||||
_selector.RemoveInteractable(interactable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue