cirnogodot/Scripts/TilemapAvoidance.cs

25 lines
592 B
C#
Raw Normal View History

2025-01-31 15:05:45 +01:00
using Godot;
using System;
using System.Linq;
using Godot.Collections;
2025-01-31 15:05:45 +01:00
public partial class TilemapAvoidance : TileMapLayer
{
[Export] private Array<TileMapLayer> _solidLayers;
2025-01-31 15:05:45 +01:00
public override bool _UseTileDataRuntimeUpdate(Vector2I coords)
{
// if (_solidLayer.GetUsedCellsById(0).Contains(coords))
// {
// return true;
// }
2025-01-31 15:05:45 +01:00
return _solidLayers.Aggregate(false, (current, layer) => current | layer.GetUsedCellsById(0).Contains(coords));
2025-01-31 15:05:45 +01:00
}
public override void _TileDataRuntimeUpdate(Vector2I coords, TileData tileData)
{
tileData.SetNavigationPolygon(0, null);
}
}