Adding A* Algorythm and carpet roads

This commit is contained in:
Nicolas SANS
2023-04-24 15:49:03 +02:00
parent 75018ee6cd
commit 690e3fbd0b
685 changed files with 134125 additions and 19 deletions

View File

@ -0,0 +1,55 @@
using UnityEngine;
using System.Collections.Generic;
using Pathfinding.Util;
using Pathfinding.Serialization;
#if UNITY_5_5_OR_NEWER
using UnityEngine.Profiling;
#endif
namespace Pathfinding {
/// <summary>
/// Helper for navmesh cut objects.
/// Responsible for keeping track of which navmesh cuts have moved and coordinating graph updates to account for those changes.
///
/// See: navmeshcutting (view in online documentation for working links)
/// See: <see cref="AstarPath.navmeshUpdates"/>
/// See: <see cref="Pathfinding.NavmeshBase.enableNavmeshCutting"/>
/// </summary>
[System.Serializable]
public class NavmeshUpdates {
/// <summary>
/// How often to check if an update needs to be done (real seconds between checks).
/// For worlds with a very large number of NavmeshCut objects, it might be bad for performance to do this check every frame.
/// If you think this is a performance penalty, increase this number to check less often.
///
/// For almost all games, this can be kept at 0.
///
/// If negative, no updates will be done. They must be manually triggered using <see cref="ForceUpdate"/>.
///
/// <code>
/// // Check every frame (the default)
/// AstarPath.active.navmeshUpdates.updateInterval = 0;
///
/// // Check every 0.1 seconds
/// AstarPath.active.navmeshUpdates.updateInterval = 0.1f;
///
/// // Never check for changes
/// AstarPath.active.navmeshUpdates.updateInterval = -1;
/// // You will have to schedule updates manually using
/// AstarPath.active.navmeshUpdates.ForceUpdate();
/// </code>
///
/// You can also find this in the AstarPath inspector under Settings.
/// [Open online documentation to see images]
/// </summary>
public float updateInterval;
internal class NavmeshUpdateSettings {
public NavmeshUpdateSettings(NavmeshBase graph) {}
public void OnRecalculatedTiles (NavmeshTile[] tiles) {}
}
internal void Update () {}
internal void OnEnable () {}
internal void OnDisable () {}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8c8c76379ef6d496bb3624f29adc556a
timeCreated: 1526234716
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,94 @@
using UnityEngine;
namespace Pathfinding {
/// <summary>
/// Pruning of recast navmesh regions.
/// A RelevantGraphSurface component placed in the scene specifies that
/// the navmesh region it is inside should be included in the navmesh.
///
/// See: Pathfinding.RecastGraph.relevantGraphSurfaceMode
/// </summary>
[AddComponentMenu("Pathfinding/Navmesh/RelevantGraphSurface")]
[HelpURL("http://arongranberg.com/astar/docs/class_pathfinding_1_1_relevant_graph_surface.php")]
public class RelevantGraphSurface : VersionedMonoBehaviour {
private static RelevantGraphSurface root;
public float maxRange = 1;
private RelevantGraphSurface prev;
private RelevantGraphSurface next;
private Vector3 position;
public Vector3 Position {
get { return position; }
}
public RelevantGraphSurface Next {
get { return next; }
}
public RelevantGraphSurface Prev {
get { return prev; }
}
public static RelevantGraphSurface Root {
get { return root; }
}
public void UpdatePosition () {
position = transform.position;
}
void OnEnable () {
UpdatePosition();
if (root == null) {
root = this;
} else {
next = root;
root.prev = this;
root = this;
}
}
void OnDisable () {
if (root == this) {
root = next;
if (root != null) root.prev = null;
} else {
if (prev != null) prev.next = next;
if (next != null) next.prev = prev;
}
prev = null;
next = null;
}
/// <summary>
/// Updates the positions of all relevant graph surface components.
/// Required to be able to use the position property reliably.
/// </summary>
public static void UpdateAllPositions () {
RelevantGraphSurface c = root;
while (c != null) { c.UpdatePosition(); c = c.Next; }
}
public static void FindAllGraphSurfaces () {
var srf = GameObject.FindObjectsOfType(typeof(RelevantGraphSurface)) as RelevantGraphSurface[];
for (int i = 0; i < srf.Length; i++) {
srf[i].OnDisable();
srf[i].OnEnable();
}
}
public void OnDrawGizmos () {
Gizmos.color = new Color(57/255f, 211/255f, 46/255f, 0.4f);
Gizmos.DrawLine(transform.position - Vector3.up*maxRange, transform.position + Vector3.up*maxRange);
}
public void OnDrawGizmosSelected () {
Gizmos.color = new Color(57/255f, 211/255f, 46/255f);
Gizmos.DrawLine(transform.position - Vector3.up*maxRange, transform.position + Vector3.up*maxRange);
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d064c7cb576144978a3535f4c71ac247
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: