33 lines
819 B
C#
33 lines
819 B
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public partial class GridMarker : Marker2D
|
|
{
|
|
public Vector2I _address;
|
|
public Node _occupant;
|
|
|
|
public List<GridMarker> _gridMarkers;
|
|
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
}
|
|
|
|
public List<GridMarker> GetMarkersInRange(float RANGE = 1.0f, bool INCLUDE_SELF = false){
|
|
if (_gridMarkers == null || _gridMarkers.Count == 0)
|
|
{
|
|
_gridMarkers = [.. GetTree().GetNodesInGroup("GridMarkers").Cast<GridMarker>()];
|
|
}
|
|
List<GridMarker> returnList = [.. _gridMarkers.Where(m => (_address - m._address).Length() <= RANGE).Cast<GridMarker>()];
|
|
if (!INCLUDE_SELF)
|
|
{
|
|
returnList.Remove(this);
|
|
}
|
|
return returnList;
|
|
}
|
|
|
|
|
|
}
|