Added FindPath to C# API for path finding

This commit is contained in:
Antoine Pilote
2024-08-09 19:12:42 -04:00
parent 5bd6690f20
commit 3fcd63ff34
9 changed files with 152 additions and 20 deletions

View File

@@ -319,4 +319,28 @@ namespace Nuake.Net
public string Sprite { get; set; }
}
public class NavMeshVolumeComponent : IComponent
{
internal static unsafe delegate*<int, float, float, float, float, float, float, NativeArray<float>> FindPathIcall;
public NavMeshVolumeComponent(int entityId) { EntityID = entityId; }
public List<Vector3> FindStraightPath(Vector3 start, Vector3 end)
{
List<Vector3> pathWaypoints = [];
unsafe
{
NativeArray<float> waypoints = FindPathIcall(EntityID, start.X, start.Y, start.Z, end.X, end.Y, end.Z);
for(int i = 0; i < waypoints.Length; i += 3)
{
Vector3 waypointPosition = new Vector3(waypoints[i], waypoints[i + 1], waypoints[i + 2]);
pathWaypoints.Add(waypointPosition);
}
return pathWaypoints;
}
}
}
}

View File

@@ -45,7 +45,8 @@ namespace Nuake.Net
PARTICLE_EMITTER,
QUAKE_MAP,
BSP_BRUSH,
SPRITE
SPRITE,
NAVMESH
}
public int ID { get; set; }
@@ -101,7 +102,8 @@ namespace Nuake.Net
{ typeof(ParticleEmitterComponent), ComponentTypes.PARTICLE_EMITTER },
{ typeof(QuakeMapComponent), ComponentTypes.QUAKE_MAP },
{ typeof(BSPBrushComponent), ComponentTypes.BSP_BRUSH },
{ typeof(SpriteComponent), ComponentTypes.SPRITE }
{ typeof(SpriteComponent), ComponentTypes.SPRITE },
{ typeof(NavMeshVolumeComponent), ComponentTypes.NAVMESH }
};
public bool HasComponent<T>()