42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Sirenix.OdinInspector;
|
|
using Unity.AI.Navigation;
|
|
using UnityEngine;
|
|
using VOID.Generic.Objects.Abstract;
|
|
|
|
namespace VOID.Generic.Objects.Traversable
|
|
{
|
|
[RequireComponent(typeof(NavMeshLink))]
|
|
public class TraversableObject : AbstractObject
|
|
{
|
|
[Title("=== Traversable properties ===")]
|
|
public TraversableObjectData traversableData;
|
|
|
|
private void OnDrawGizmosSelected()
|
|
{
|
|
if (traversableData.path.Count > 1)
|
|
{
|
|
Gizmos.color = Color.blue;
|
|
traversableData.path.ForEach(t =>
|
|
{
|
|
var pos = t.position;
|
|
Gizmos.DrawSphere(pos, 0.05f);
|
|
Gizmos.DrawLine(pos, pos + t.forward * 0.25f);
|
|
});
|
|
Gizmos.DrawLineList(traversableData.path.Select(t => t.position).ToArray());
|
|
}
|
|
}
|
|
|
|
protected override List<ObjectComponent> GetObjectComponents()
|
|
{
|
|
return base.GetObjectComponents()
|
|
.Union(new List<ObjectComponent>
|
|
{
|
|
traversableData
|
|
})
|
|
.ToList();
|
|
}
|
|
}
|
|
}
|