mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 14:05:54 +00:00
Interactable interface
This commit is contained in:
parent
49e58ff735
commit
54d9824581
27 changed files with 102 additions and 61 deletions
|
|
@ -1,19 +1,20 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cirno.Scripts.Interactables;
|
||||
|
||||
public partial class Selector : Node2D
|
||||
{
|
||||
private Interactable _lastInteractable;
|
||||
|
||||
private List<Interactable> _interactables = new List<Interactable>();
|
||||
private List<IInteractable> _interactables = [];
|
||||
|
||||
private int _selectedInteractable;
|
||||
|
||||
[Signal]
|
||||
public delegate void SelectedItemInteractableChangedEventHandler(Interactable interactable);
|
||||
//[Signal]
|
||||
//public delegate void SelectedItemInteractableChangedEventHandler(IInteractable interactable);
|
||||
|
||||
public Interactable SelectedInteractable
|
||||
public IInteractable SelectedInteractable
|
||||
{
|
||||
get =>
|
||||
_interactables.Count > 0
|
||||
|
|
@ -79,12 +80,12 @@ public partial class Selector : Node2D
|
|||
UpdatePosition();
|
||||
}
|
||||
|
||||
private void NotifyChanged(Interactable interactable)
|
||||
private void NotifyChanged(IInteractable interactable)
|
||||
{
|
||||
EmitSignal(nameof(SelectedItemInteractableChanged), interactable);
|
||||
//EmitSignal(nameof(SelectedItemInteractableChanged), interactable);
|
||||
}
|
||||
|
||||
public void AddInteractable(Interactable interactable)
|
||||
public void AddInteractable(IInteractable interactable)
|
||||
{
|
||||
if (!_interactables.Contains(interactable)) {
|
||||
_interactables.Add(interactable);
|
||||
|
|
@ -98,7 +99,7 @@ public partial class Selector : Node2D
|
|||
UpdatePosition();
|
||||
}
|
||||
|
||||
public void RemoveInteractable(Interactable interactable)
|
||||
public void RemoveInteractable(IInteractable interactable)
|
||||
{
|
||||
if (_interactables.Contains(interactable))
|
||||
{
|
||||
|
|
@ -117,7 +118,7 @@ public partial class Selector : Node2D
|
|||
{
|
||||
if (SelectedInteractable != null)
|
||||
{
|
||||
this.Position = SelectedInteractable.Position;
|
||||
this.Position = SelectedInteractable.GetPosition();
|
||||
this.Visible = true;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue