🚧 WIP trying to make fields have outlines again

This commit is contained in:
2025-12-15 22:45:02 +01:00
parent ce113e16da
commit abed751d29
4 changed files with 28 additions and 18 deletions
@@ -14,7 +14,7 @@ public partial class Detector : Area2D
[Export] private ShapeCast2D _shapeCast2D;
[Export] private VariableResource _itemToTriggerResource;
private readonly List<ulong> _areasInDetector = new();
private List<ulong> _areasInDetector = new();
public bool IsActive
{
@@ -41,12 +41,8 @@ public partial class Detector : Area2D
if (!_active || !InputService.Instance.InputEnabled)
return;
if (area is DetectableInteractionArea detectable)
{
ulong id = detectable.GetInstanceId();
_areasInDetector.Add(id);
CalculateClosestInteractable();
}
PopulateList();
CalculateClosestInteractable();
}
/// <summary>
@@ -58,12 +54,23 @@ public partial class Detector : Area2D
if (!_active || !InputService.Instance.InputEnabled)
return;
if (area is DetectableInteractionArea detectable)
PopulateList();
CalculateClosestInteractable();
}
private void PopulateList()
{
// repopulate the list of areas in the detector to account for enabled / disabled areas
var currentOverlap = GetOverlappingAreas();
_areasInDetector = new List<ulong>();
foreach (var area2D in currentOverlap)
{
ulong id = detectable.GetInstanceId();
if( _areasInDetector.Contains(id))
_areasInDetector.Remove(id);
CalculateClosestInteractable();
if (area2D is DetectableInteractionArea detectable)
{
ulong id = detectable.GetInstanceId();
_areasInDetector.Add(id);
}
}
}