diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..889d61e --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +bin +/Library +*.db +*.suo +/Assets/Plugins +/Assets/UnityVS +/Assets/AstarPathfindingProject +*.csproj +*.sln +*.user +/Assets/UnityVS.meta diff --git a/Assets/AstarPathfindingProject.meta b/Assets/AstarPathfindingProject.meta new file mode 100644 index 0000000..4fd935d --- /dev/null +++ b/Assets/AstarPathfindingProject.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 852989b7ee417614895ad7f0e7ce3d75 +folderAsset: yes +timeCreated: 1442649884 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules.meta b/Assets/ECSModules.meta new file mode 100644 index 0000000..3d4df3b --- /dev/null +++ b/Assets/ECSModules.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 13f1604b16db004409c73889d3b2e488 +folderAsset: yes +timeCreated: 1442650475 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding.meta b/Assets/ECSModules/AStarPathfinding.meta new file mode 100644 index 0000000..ad925d1 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 407cf11ddafa16f4f9d1c52bab52730f +folderAsset: yes +timeCreated: 1442650491 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions.meta b/Assets/ECSModules/AStarPathfinding/Actions.meta new file mode 100644 index 0000000..a17e0e0 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0703cde7f7edafb43811dd8204dfce66 +folderAsset: yes +timeCreated: 1442650497 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Debug.meta b/Assets/ECSModules/AStarPathfinding/Actions/Debug.meta new file mode 100644 index 0000000..0562eef --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Debug.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7b1dac50fce28df46a16a28b63697b69 +folderAsset: yes +timeCreated: 1442773094 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Debug/DrawDebugPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Debug/DrawDebugPathAction.cs new file mode 100644 index 0000000..7b6a667 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Debug/DrawDebugPathAction.cs @@ -0,0 +1,30 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace EECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Draw Debug Path")] + [ActionDescription("Draws a debug line for the path in the scene")] + public class DrawDebugPathAction : UFAction + { + [In] + public Path Path; + + public Color PathColor = Color.green; + public float TimeToShow = 0.1f; + + public override void Execute() + { + var vectorPath = Path.vectorPath; + for (var i = 1; i < vectorPath.Count; i++) + { + Debug.DrawLine(vectorPath[i - 1], vectorPath[i], PathColor, TimeToShow); + } + } + } +} diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Debug/DrawDebugPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Debug/DrawDebugPathAction.cs.meta new file mode 100644 index 0000000..4eb30d6 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Debug/DrawDebugPathAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5499b05e92e6e9e439f0fef6ca9ebca3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs.meta new file mode 100644 index 0000000..69166e3 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0fabe0d04f8368a499d4b39c17f09950 +folderAsset: yes +timeCreated: 1442773094 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FloodFillGraphsAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FloodFillGraphsAction.cs new file mode 100644 index 0000000..7a7af90 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FloodFillGraphsAction.cs @@ -0,0 +1,28 @@ +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Graphs")] + [ActionTitle("Flood Fill Graphs")] + [ActionDescription("Flood fills graphs forcing updates to propogate")] + public class FloodFillGraphsAction : UFAction + { + [In] + public GraphNode StartingNode; + + [In] + public int Area; + + public override void Execute() + { + if (StartingNode == null) + { AstarPath.active.FloodFill(); } + else if (Area <= 0) + { AstarPath.active.FloodFill(StartingNode); } + else + { AstarPath.active.FloodFill(StartingNode, (uint)Area); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FloodFillGraphsAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FloodFillGraphsAction.cs.meta new file mode 100644 index 0000000..d3a2c90 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FloodFillGraphsAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9374b84ae57f3aa468a3c42b420a2d55 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FlushGraphUpdatesAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FlushGraphUpdatesAction.cs new file mode 100644 index 0000000..5f9656b --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FlushGraphUpdatesAction.cs @@ -0,0 +1,19 @@ + + + +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Graphs")] + [ActionTitle("Flush Graph Updates")] + [ActionDescription("Flushes all graph updates")] + public class FlushGraphUpdatesAction : UFAction + { + public override void Execute() + { + AstarPath.active.FlushGraphUpdates(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FlushGraphUpdatesAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FlushGraphUpdatesAction.cs.meta new file mode 100644 index 0000000..5c95fb2 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/FlushGraphUpdatesAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 37d00cf96836da34fba213549c61da9c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphByIndexAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphByIndexAction.cs new file mode 100644 index 0000000..dbf6f34 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphByIndexAction.cs @@ -0,0 +1,28 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace NodeCanvasAddons +{ + [uFrameCategory("A* Pathfinding", "Graphs")] + [ActionTitle("Get Graph By Index")] + [ActionDescription("Gets a graph in the scene by index")] + public class GetGraphByIndexAction : UFAction + { + [In] + public int GraphIndex; + + [Out] + public NavGraph LocatedGraph; + + public override void Execute() + { + if (AstarPath.active.graphs.Length <= GraphIndex) + { return; } + + LocatedGraph = AstarPath.active.graphs[GraphIndex]; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphByIndexAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphByIndexAction.cs.meta new file mode 100644 index 0000000..85d9164 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphByIndexAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a0cb39ffbfb15f949b98e4d7d245d5ef +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphFromNodeAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphFromNodeAction.cs new file mode 100644 index 0000000..d59ac56 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphFromNodeAction.cs @@ -0,0 +1,25 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Graphs")] + [ActionTitle("Get Graph From Node")] + [ActionDescription("Gets a graph from a node")] + public class GetGraphFromNodeAction : UFAction + { + [In] + public GraphNode Node; + + [Out] + public NavGraph LocatedGraph; + + public override void Execute() + { + LocatedGraph = AstarPath.active.graphs[Node.GraphIndex]; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphFromNodeAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphFromNodeAction.cs.meta new file mode 100644 index 0000000..86a9dda --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/GetGraphFromNodeAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c868d3e8bf2bdae4a9b1b9a290787d6e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphAction.cs new file mode 100644 index 0000000..5ca94e6 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphAction.cs @@ -0,0 +1,22 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Graphs")] + [ActionTitle("Rescan Graph")] + [ActionDescription("Rescans the graph to see if any changes have occurred")] + public class RescanGraphAction : UFAction + { + [In] + public NavGraph Graph; + + public override void Execute() + { + Graph.ScanInternal(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphAction.cs.meta new file mode 100644 index 0000000..5399a6b --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 715e34c280646184c8bae5ef50e3e258 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphsAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphsAction.cs new file mode 100644 index 0000000..43389fd --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphsAction.cs @@ -0,0 +1,19 @@ + + + +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Graphs")] + [ActionTitle("Rescan Graphs")] + [ActionDescription("Rescans all graphs in the scene")] + public class RescanGraphsAction : UFAction + { + public override void Execute() + { + AstarPath.active.Scan(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphsAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphsAction.cs.meta new file mode 100644 index 0000000..9148148 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/RescanGraphsAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e9f529e7794ad3e418b80d82ca9750c9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicAction.cs new file mode 100644 index 0000000..f3175a1 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicAction.cs @@ -0,0 +1,22 @@ + + + +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Set Heuristic")] + [ActionDescription("Sets the heuristic to use when calculating paths")] + public class SetHeuristicAction : UFAction + { + [In] + public Heuristic Heuristic = Heuristic.Euclidean; + + public override void Execute() + { + AstarPath.active.heuristic = Heuristic; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicAction.cs.meta new file mode 100644 index 0000000..fe94bbb --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eb9ec3503812fd64baf248794cb6fb09 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicScaleAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicScaleAction.cs new file mode 100644 index 0000000..8836284 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicScaleAction.cs @@ -0,0 +1,22 @@ + + + +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Set Heuristic Scale")] + [ActionDescription("Sets the heuristic scale to use when calculating paths")] + public class SetHeuristicScaleAction : UFAction + { + [In] + public float HeuristicScale; + + public override void Execute() + { + AstarPath.active.heuristicScale = HeuristicScale; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicScaleAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicScaleAction.cs.meta new file mode 100644 index 0000000..fd9cbfe --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/SetHeuristicScaleAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4294909f5f2aac24a919c5bcf7bd26ea +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/UpdateGraphsAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/UpdateGraphsAction.cs new file mode 100644 index 0000000..7b9ffe2 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/UpdateGraphsAction.cs @@ -0,0 +1,22 @@ + + +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Graphs")] + [ActionTitle("Update Graphs")] + [ActionDescription("Updates graphs nodes within a given boundry")] + public class UpdateGraphsAction : UFAction + { + [In] + public Bounds UpdateBoundry; + + public override void Execute() + { + AstarPath.active.UpdateGraphs(UpdateBoundry); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Graphs/UpdateGraphsAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/UpdateGraphsAction.cs.meta new file mode 100644 index 0000000..b975312 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Graphs/UpdateGraphsAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e0e3690006eab2a4491a1caf38bc6036 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes.meta new file mode 100644 index 0000000..edae0be --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a90f84a31d7bc9b4d84e12435b742fde +folderAsset: yes +timeCreated: 1442773094 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/AddConnectionToNodeAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/AddConnectionToNodeAction.cs new file mode 100644 index 0000000..a41fc29 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/AddConnectionToNodeAction.cs @@ -0,0 +1,28 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Add Connection To Node")] + [ActionDescription("Adds a connection to the node with an associated cost (must be positive)")] + public class AddConnectionToNodeAction : UFAction + { + [In] + public GraphNode Node; + + [In] + public GraphNode ConnectingNode; + + [In] + public int ConnectionCost; + + public override void Execute() + { + Node.AddConnection(ConnectingNode, (uint)ConnectionCost); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/AddConnectionToNodeAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/AddConnectionToNodeAction.cs.meta new file mode 100644 index 0000000..8687926 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/AddConnectionToNodeAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 42b8cabd3442b194f8530dc6105569a7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/ClearNodeConnectionsAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/ClearNodeConnectionsAction.cs new file mode 100644 index 0000000..911b097 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/ClearNodeConnectionsAction.cs @@ -0,0 +1,25 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Clear Nodes Connections")] + [ActionDescription("Clears all nodes connections")] + public class ClearNodeConnectionsAction : UFAction + { + [In] + public GraphNode Node; + + [In] + public bool ClearReverse; + + public override void Execute() + { + Node.ClearConnections(ClearReverse); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/ClearNodeConnectionsAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/ClearNodeConnectionsAction.cs.meta new file mode 100644 index 0000000..72224a2 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/ClearNodeConnectionsAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4b3e2e6162151a4982feff2da526bdd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/DestroyNodeAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/DestroyNodeAction.cs new file mode 100644 index 0000000..38a21de --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/DestroyNodeAction.cs @@ -0,0 +1,22 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Destroy Node")] + [ActionDescription("Destroys a node")] + public class DestroyNodeAction : UFAction + { + [In] + public GraphNode Node; + + public override void Execute() + { + Node.Destroy(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/DestroyNodeAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/DestroyNodeAction.cs.meta new file mode 100644 index 0000000..6ef160b --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/DestroyNodeAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3aee3f612ecd8784f819d3d38f791b4a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNearestNodeAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNearestNodeAction.cs new file mode 100644 index 0000000..6adda9b --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNearestNodeAction.cs @@ -0,0 +1,29 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Get Nearest Node")] + [ActionDescription("Finds the nearest node to a position")] + public class GetNearestNodeAction : UFAction + { + [In] + public Vector3 Position; + + [Out] + public GraphNode NearestNode; + + public override void Execute() + { + var closestResult = AstarPath.active.GetNearest(Position); + if (closestResult.node == null) { return; } + + NearestNode = closestResult.node; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNearestNodeAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNearestNodeAction.cs.meta new file mode 100644 index 0000000..57e0a04 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNearestNodeAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bfa04e5daa0a7504da6d8df982cede1e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeConnectionsAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeConnectionsAction.cs new file mode 100644 index 0000000..0e368f2 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeConnectionsAction.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Get Node Connections")] + [ActionDescription("Gets all connections for a node")] + public class GetNodeConnectionsAction : UFAction + { + [In] + public GraphNode Node; + + [Out] + public List ConnectionList = new List(); + + public override void Execute() + { + Node.GetConnections(connectedNode => ConnectionList.Add(connectedNode)); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeConnectionsAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeConnectionsAction.cs.meta new file mode 100644 index 0000000..129db7e --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeConnectionsAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7572018f212272048947f027b2006844 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodePenaltyAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodePenaltyAction.cs new file mode 100644 index 0000000..cec9456 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodePenaltyAction.cs @@ -0,0 +1,25 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Get Node Penalty")] + [ActionDescription("Gets the penalty for a node")] + public class GetNodePenaltyAction : UFAction + { + [In] + public GraphNode NodeToCheck; + + [Out] + public int Penalty; + + public override void Execute() + { + Penalty = (int)NodeToCheck.Penalty; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodePenaltyAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodePenaltyAction.cs.meta new file mode 100644 index 0000000..e49fdec --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodePenaltyAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5921580c7a8552c4e8871a37d9a20261 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeWalkabilityAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeWalkabilityAction.cs new file mode 100644 index 0000000..be70553 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeWalkabilityAction.cs @@ -0,0 +1,25 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Get Node Walkability")] + [ActionDescription("Gets a boolean indicating if the path is walkable")] + public class GetNodeWalkabilityAction : UFAction + { + [In] + public GraphNode NodeToCheck; + + [Out] + public bool Walkability; + + public override void Execute() + { + Walkability = NodeToCheck.Walkable; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeWalkabilityAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeWalkabilityAction.cs.meta new file mode 100644 index 0000000..7b2633b --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodeWalkabilityAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9b39cf1b65bbd024d9974cf2a4bb1762 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodesPositionAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodesPositionAction.cs new file mode 100644 index 0000000..552eb28 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodesPositionAction.cs @@ -0,0 +1,26 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Get Nodes Position")] + [ActionDescription("Gets the underlying position of a Node")] + public class GetNodesPositionAction : UFAction + { + [In] + public GraphNode Node; + + [Out] + public Vector3 Position; + + public override void Execute() + { + Position = (Vector3)Node.position; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodesPositionAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodesPositionAction.cs.meta new file mode 100644 index 0000000..6a0a92e --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/GetNodesPositionAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6bd2823f7386b9c408b4c33140728b09 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RecalculateNodeConnectionCostsAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RecalculateNodeConnectionCostsAction.cs new file mode 100644 index 0000000..d1529c4 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RecalculateNodeConnectionCostsAction.cs @@ -0,0 +1,22 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Recalculate Node Connection Costs")] + [ActionDescription("Recalculates a nodes connection costs")] + public class RecalculateNodeConnectionCostsAction : UFAction + { + [In] + public GraphNode Node; + + public override void Execute() + { + Node.RecalculateConnectionCosts(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RecalculateNodeConnectionCostsAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RecalculateNodeConnectionCostsAction.cs.meta new file mode 100644 index 0000000..7610254 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RecalculateNodeConnectionCostsAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 703130252a9c9ff4198484aa3438de0d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RemoveConnectionToNodeAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RemoveConnectionToNodeAction.cs new file mode 100644 index 0000000..b3d5b4c --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RemoveConnectionToNodeAction.cs @@ -0,0 +1,25 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Nodes")] + [ActionTitle("Add Connection To Node")] + [ActionDescription("Removes a connected node")] + public class RemoveConnectionToNodeAction : UFAction + { + [In] + public GraphNode Node; + + [In] + public GraphNode ConnectedNode; + + public override void Execute() + { + Node.RemoveConnection(ConnectedNode); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RemoveConnectionToNodeAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RemoveConnectionToNodeAction.cs.meta new file mode 100644 index 0000000..5fa6416 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Nodes/RemoveConnectionToNodeAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf3dfd2c31dc25040b2fafbe74de74e6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths.meta new file mode 100644 index 0000000..360462a --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6624caf51c27b1d4784f5923a1e59634 +folderAsset: yes +timeCreated: 1442773094 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/ClaimPathInPoolAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/ClaimPathInPoolAction.cs new file mode 100644 index 0000000..ea46042 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/ClaimPathInPoolAction.cs @@ -0,0 +1,21 @@ +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [ActionLibrary] + [uFrameCategory("A* Pathfinding")] + [ActionDescription("Claims the path in the pathing pool")] + [ActionTitle("Claim Path In Pool")] + public class ClaimPathInPoolAction : UFAction + { + [In] + public Path Path; + + public override void Execute() + { + Path.Claim(EntityView); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/ClaimPathInPoolAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/ClaimPathInPoolAction.cs.meta new file mode 100644 index 0000000..f1694a7 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/ClaimPathInPoolAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2bd6c8a98bd6d694eb075eebbd24f97e +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateABPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateABPathAction.cs new file mode 100644 index 0000000..dc5d3d1 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateABPathAction.cs @@ -0,0 +1,51 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Create AB Path")] + [ActionDescription("Creates an AB Path from the source position to the destination position.")] + public class CreateABPathAction : UFAction + { + [In] + public Vector3 SourcePosition; + + [In] + public Vector3 DestinationPosition; + + [Out] + public Path GeneratedPath; + + [Out] + public string Error; + + [Out] + public Action PathGenerated; + + [Out] + public Action PathFailed; + + public override void Execute() + { + var currentPath = ABPath.Construct(SourcePosition, DestinationPosition, PathFinishedDelegate); + AstarPath.StartPath(currentPath); + } + + private void PathFinishedDelegate(Path path) + { + if (path.error) + { + Error = path.errorLog; + PathFailed(); + return; + } + + GeneratedPath = path; + PathGenerated(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateABPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateABPathAction.cs.meta new file mode 100644 index 0000000..049d575 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateABPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 31e95b695ef161244ab375e876ac6ad4 +timeCreated: 1442650518 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateConstantPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateConstantPathAction.cs new file mode 100644 index 0000000..6545e6f --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateConstantPathAction.cs @@ -0,0 +1,50 @@ + + +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding - Pro")] + [ActionTitle("Create Constant Path")] + [ActionDescription("Creates a constant path for use")] + public class CreateConstantPathAction : UFAction + { + [In] + public int MaxScore; + + [In] + Vector3 SourcePosition; + + [Out] + public ConstantPath GeneratedPath; + + [Out] public Action PathGenerated; + + [Out] public string Error; + + [Out] public Action PathFailed; + + public override void Execute() + { + var currentPath = ConstantPath.Construct(SourcePosition, MaxScore, PathFinishedDelegate); + AstarPath.StartPath(currentPath); + } + + private void PathFinishedDelegate(Path path) + { + if (path.error) + { + Error = path.errorLog; + PathFailed(); + return; + } + + GeneratedPath = (ConstantPath) path; + PathGenerated(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateConstantPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateConstantPathAction.cs.meta new file mode 100644 index 0000000..771e4d7 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateConstantPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 02b00af805624f449a3427ae8b7e705e +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFleePathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFleePathAction.cs new file mode 100644 index 0000000..3dec5d2 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFleePathAction.cs @@ -0,0 +1,56 @@ + + +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding - Pro")] + [ActionTitle("Create Flee Path")] + [ActionDescription("Creates a flee path for from an agents position")] + public class CreateFleePathAction : UFAction + { + [In] + public Vector3 SourcePosition; + + [In] + public Vector3 AvoidPosition; + + [In] + public int GScoreToStopAt; + + [Out] + public Path GeneratedPath; + + [Out] + public Action PathGenerated; + + [Out] + public string Error; + + [Out] + public Action PathFailed; + + public override void Execute() + { + var path = FleePath.Construct(SourcePosition, AvoidPosition, GScoreToStopAt, PathFinishedDelegate); + AstarPath.StartPath(path); + } + + private void PathFinishedDelegate(Path path) + { + if(path.error) + { + Error = path.errorLog; + PathFailed(); + return; + } + + GeneratedPath = path; + PathGenerated(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFleePathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFleePathAction.cs.meta new file mode 100644 index 0000000..e539748 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFleePathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 58d5aa347edc0ec45812d5813ccaa6a9 +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathAction.cs new file mode 100644 index 0000000..f986a18 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathAction.cs @@ -0,0 +1,50 @@ + + +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding - Pro")] + [ActionTitle("Create Flood Path")] + [ActionDescription("Creates a flood path for subsequent lookups")] + public class CreateFloodPathAction : UFAction + { + [In] + public Vector3 SourcePosition; + + [Out] + public Path GeneratedPath; + + [Out] + public Action PathGenerated; + + [Out] + public string Error; + + [Out] + public Action PathFailed; + + public override void Execute() + { + var currentPath = FloodPath.Construct(SourcePosition, PathFinishedDelegate); + AstarPath.StartPath(currentPath); + } + + private void PathFinishedDelegate(Path path) + { + if (path.error) + { + Error = path.errorLog; + PathFailed(); + return; + } + + GeneratedPath = (FloodPath)path; + PathGenerated(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathAction.cs.meta new file mode 100644 index 0000000..c46f2f0 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dcc37539f1c44874d958a083e35a5d9c +timeCreated: 1442773095 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathTraceAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathTraceAction.cs new file mode 100644 index 0000000..1e6ca01 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathTraceAction.cs @@ -0,0 +1,53 @@ + + +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding - Pro")] + [ActionTitle("Create Flood Path Trace")] + [ActionDescription("Creates a path from the trace start to the flood path start")] + public class CreateFloodPathTraceAction : UFAction + { + [In] + public Vector3 TraceStart; + + [In] + public FloodPath FloodPath; + + [Out] + public Path GeneratedPath; + + [Out] + public Action PathGenerated; + + [Out] + public string Error; + + [Out] + public Action PathFailed; + + public override void Execute() + { + var path = FloodPathTracer.Construct(TraceStart, FloodPath, PathFinishedDelegate); + AstarPath.StartPath(path); + } + + private void PathFinishedDelegate(Path path) + { + if (path.error) + { + Error = path.errorLog; + PathFailed(); + return; + } + + GeneratedPath = path; + PathGenerated(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathTraceAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathTraceAction.cs.meta new file mode 100644 index 0000000..0e451bb --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateFloodPathTraceAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0743631d88506ca41aa837c6e89ab3d9 +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateMultiPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateMultiPathAction.cs new file mode 100644 index 0000000..b72eaf6 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateMultiPathAction.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding - Pro")] + [ActionTitle("Create Multi Path")] + [ActionDescription("Creates a path from the current agent to the destination point")] + public class CreateMultiPathAction : UFAction + { + [In] + public Vector3 SourcePosition; + + [In] + public List TargetDestinations; + + [Out] + public Path GeneratedPath; + + [Out] + public Action PathGenerated; + + [Out] + public string Error; + + [Out] + public Action PathFailed; + + public override void Execute() + { + var currentPath = MultiTargetPath.Construct(SourcePosition, TargetDestinations.ToArray(), null, PathFinishedDelegate); + AstarPath.StartPath(currentPath); + } + + private void PathFinishedDelegate(Path path) + { + if (path.error) + { + Error = path.errorLog; + PathFailed(); + return; + } + + GeneratedPath = path; + PathGenerated(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateMultiPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateMultiPathAction.cs.meta new file mode 100644 index 0000000..4a7faa8 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateMultiPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 92fe4a9f44fa92b4d9cabc0655fd2cce +timeCreated: 1442773095 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateRandomPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateRandomPathAction.cs new file mode 100644 index 0000000..506a407 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateRandomPathAction.cs @@ -0,0 +1,45 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [ActionLibrary] + [uFrameCategory("A* Pathfinding - Pro")] + [ActionTitle("Create Random Path")] + [ActionDescription("Creates a random path based upon the starting point and the search length")] + public class CreateRandomPathAction : UFAction + { + [In] public Vector3 StartingPoint; + [In] public int SearchLength; + + [Out] public Path GeneratedPath; + [Out] public Action PathGenerated; + + [Out] public string Error; + [Out] public Action PathFailed; + + public override void Execute() + { + var currentPath = RandomPath.Construct(StartingPoint, SearchLength, PathFinishedDeletate); + AstarPath.StartPath(currentPath); + } + + private void PathFinishedDeletate(Path path) + { + if (path.error) + { + Error = path.errorLog; + PathFailed(); + } + else + { + GeneratedPath = path; + PathGenerated(); + PathGenerated(); + } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateRandomPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateRandomPathAction.cs.meta new file mode 100644 index 0000000..edf715d --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/CreateRandomPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2f5898d3f6697d341a014b46fc491b29 +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/DuplicatePathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/DuplicatePathAction.cs new file mode 100644 index 0000000..8d4d29d --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/DuplicatePathAction.cs @@ -0,0 +1,25 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Duplicate Path")] + [ActionDescription("Duplicates a given path")] + public class DuplicatePathAction : UFAction + { + [In] + public Path Path; + + [Out] + public Path DuplicatePath; + + public override void Execute() + { + DuplicatePath = Path.DuplicatePath(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/DuplicatePathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/DuplicatePathAction.cs.meta new file mode 100644 index 0000000..daf56f7 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/DuplicatePathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 36c09acdf61aa71429ab02e5275df199 +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/FreePathInPoolAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/FreePathInPoolAction.cs new file mode 100644 index 0000000..22ad538 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/FreePathInPoolAction.cs @@ -0,0 +1,20 @@ +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Free Path In Pool")] + [ActionDescription("Frees the path from the pathing pool")] + public class FreePathInPoolAction : UFAction + { + [In] + public Path Path; + + public override void Execute() + { + Path.Release(EntityView); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/FreePathInPoolAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/FreePathInPoolAction.cs.meta new file mode 100644 index 0000000..6d572d5 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/FreePathInPoolAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b5764e6b49ca0d04e8b5f89b54e25224 +timeCreated: 1442773095 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetAllNodesFromConstantPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetAllNodesFromConstantPathAction.cs new file mode 100644 index 0000000..c32cfcf --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetAllNodesFromConstantPathAction.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding - Pro")] + [ActionTitle("Get All Nodes From Constant Path")] + [ActionDescription("Get all nodes from a constant path")] + public class GetAllNodesFromConstantPathAction : UFAction + { + [In] + public ConstantPath Path; + + [Out] + public List NodeList; + + public override void Execute() + { + NodeList = Path.allNodes; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetAllNodesFromConstantPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetAllNodesFromConstantPathAction.cs.meta new file mode 100644 index 0000000..5a12d1f --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetAllNodesFromConstantPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3d1eecc28e122bc49b55f4c3d6bf184f +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestNodeInPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestNodeInPathAction.cs new file mode 100644 index 0000000..f996b5d --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestNodeInPathAction.cs @@ -0,0 +1,38 @@ +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Get Closest Node In Path")] + [ActionDescription("Gets the closest node in an existing path")] + public class GetClosestNodeInPathAction : UFAction + { + [In] + public Path Path; + + [In] + public Vector3 PositionToCheck; + + [Out] + public GraphNode OutputNode; + + [Out] + public float DistanceToClosest; + + public override void Execute() + { + if(Path.vectorPath.Count == 0) { return; } + + var closestNode = Path.FindClosestNodeTo(PositionToCheck); + OutputNode = closestNode; + if (DistanceToClosest > 0 || DistanceToClosest < 0) + { + var nodePosition = (Vector3) closestNode.position; + DistanceToClosest = Vector3.Distance(nodePosition, PositionToCheck); + } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestNodeInPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestNodeInPathAction.cs.meta new file mode 100644 index 0000000..fbc4e3e --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestNodeInPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 42e788d0ceaf20242a6b72cf44a6d214 +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestPositionInPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestPositionInPathAction.cs new file mode 100644 index 0000000..874dcea --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestPositionInPathAction.cs @@ -0,0 +1,36 @@ +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Get Closest Position In Path")] + [ActionDescription("Gets the closest position in an existing path")] + public class GetClosestPositionInPathAction : UFAction + { + [In] + public Path Path; + + [In] + public Vector3 PositionToCheck; + + [Out] + public Vector3 OutputVector; + + [Out] + public float DistanceToClosest; + + public override void Execute() + { + if (Path.vectorPath.Count == 0) { return; } + + var closestNode = Path.FindClosestPositionTo(PositionToCheck); + OutputVector = closestNode; + + if (DistanceToClosest > 0 || DistanceToClosest < 0) + { DistanceToClosest = Vector3.Distance(closestNode, PositionToCheck); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestPositionInPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestPositionInPathAction.cs.meta new file mode 100644 index 0000000..6676dcf --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetClosestPositionInPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b6298b2628cab6f46868bf7a5c00a484 +timeCreated: 1442773095 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetDistanceOfPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetDistanceOfPathAction.cs new file mode 100644 index 0000000..9ac5794 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetDistanceOfPathAction.cs @@ -0,0 +1,38 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Get Distance Of Path")] + [ActionDescription("Gets the distance of a given path")] + public class GetDistanceOfPathAction : UFAction + { + [In] + public Path Path; + + [Out] + public float TotalDistance; + + public override void Execute() + { + TotalDistance = Path.vectorPath.Count > 1 ? GetTotalDistanceOfPath(Path) : 0; + } + + private float GetTotalDistanceOfPath(Path path) + { + var totalDistance = 0.0f; + for (var i = 1; i < path.vectorPath.Count; i++) + { + var previousPosition = path.vectorPath[i - 1]; + var nextPosition = path.vectorPath[i]; + totalDistance = Vector3.Distance(previousPosition, nextPosition); + } + return totalDistance; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetDistanceOfPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetDistanceOfPathAction.cs.meta new file mode 100644 index 0000000..19dd537 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetDistanceOfPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7310b7a279588384986839dcfa8f662b +timeCreated: 1442773095 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodeFromPathByIndexAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodeFromPathByIndexAction.cs new file mode 100644 index 0000000..267984f --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodeFromPathByIndexAction.cs @@ -0,0 +1,31 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Get Node From Path By Index")] + [ActionDescription("Gets a node from a path by index")] + public class GetNodeFromPathByIndexAction : UFAction + { + [In] + public Path Path; + + [In] + public int Index; + + [Out] + public GraphNode Node; + + public override void Execute() + { + if(Path.path.Count >= Index) + { return; } + + Node = Path.path[Index]; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodeFromPathByIndexAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodeFromPathByIndexAction.cs.meta new file mode 100644 index 0000000..90ca5f4 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodeFromPathByIndexAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4ca9bc1b3ea45e84abdbf08a4df7aeef +timeCreated: 1442773094 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodesFromPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodesFromPathAction.cs new file mode 100644 index 0000000..3fc4b28 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodesFromPathAction.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Get Nodes From Path")] + [ActionDescription("Get nodes from an existing path")] + public class GetNodesFromPathAction : UFAction + { + [In] + public Path Path; + + [Out] + public List NodeList; + + public override void Execute() + { + NodeList = Path.path; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodesFromPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodesFromPathAction.cs.meta new file mode 100644 index 0000000..fa5cdc6 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetNodesFromPathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8877b897a2dc96c4cb7233b15d969095 +timeCreated: 1442773095 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetVectorFromPathByIndexAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetVectorFromPathByIndexAction.cs new file mode 100644 index 0000000..a3eedce --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetVectorFromPathByIndexAction.cs @@ -0,0 +1,31 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Get Vector From Path By Index")] + [ActionDescription("Gets a vector from a path by index")] + public class GetVectorFromPathByIndexAction : UFAction + { + [In] + public Path Path; + + [In] + public int Index; + + [Out] + public Vector3 Vector; + + public override void Execute() + { + if (Path.path.Count >= Index) { return; } + + Vector = Path.vectorPath[Index]; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetVectorFromPathByIndexAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetVectorFromPathByIndexAction.cs.meta new file mode 100644 index 0000000..63c70b5 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/GetVectorFromPathByIndexAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7be83de93cacb7c4e961de8bdfea5026 +timeCreated: 1442773095 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/ReversePathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Paths/ReversePathAction.cs new file mode 100644 index 0000000..8e9cbd9 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/ReversePathAction.cs @@ -0,0 +1,23 @@ +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Reverse Path")] + [ActionDescription("Reverses a given path")] + public class ReversePathAction : UFAction + { + [In] + public Path Path; + + [Out] + public Path ReversedPath; + + public override void Execute() + { + ReversedPath = Path.ReversePath(); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Paths/ReversePathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Paths/ReversePathAction.cs.meta new file mode 100644 index 0000000..7ac0f82 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Paths/ReversePathAction.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f35fa4a072b320c408ad22302643dc0c +timeCreated: 1442773100 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Seeker.meta b/Assets/ECSModules/AStarPathfinding/Actions/Seeker.meta new file mode 100644 index 0000000..e8936ee --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Seeker.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 715210f72e1385642844cdda8f71087b +folderAsset: yes +timeCreated: 1442773094 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Seeker/SeekerProcessPathAction.cs b/Assets/ECSModules/AStarPathfinding/Actions/Seeker/SeekerProcessPathAction.cs new file mode 100644 index 0000000..fc271f2 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Seeker/SeekerProcessPathAction.cs @@ -0,0 +1,23 @@ + + +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding", "Paths")] + [ActionTitle("Seeker Process Path")] + [ActionDescription("Tells the seeker to process the given path making use of modifiers attached")] + public class SeekerProcessPathAction : UFAction + { + [In] + public Path Path; + + public override void Execute() + { + var seeker = EntityView.GetComponent(); + seeker.PostProcess(Path); + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Actions/Seeker/SeekerProcessPathAction.cs.meta b/Assets/ECSModules/AStarPathfinding/Actions/Seeker/SeekerProcessPathAction.cs.meta new file mode 100644 index 0000000..4b76466 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Actions/Seeker/SeekerProcessPathAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b4b846ad2178b1d4799658b97aa1ed1f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions.meta b/Assets/ECSModules/AStarPathfinding/Conditions.meta new file mode 100644 index 0000000..5438547 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6acba352e19c42d48ba77e6397c54aa4 +folderAsset: yes +timeCreated: 1442824888 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes.meta new file mode 100644 index 0000000..7b579b4 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 6dd123217566e2e40aafaae5cb87af79 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeDestroyedCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeDestroyedCondition.cs new file mode 100644 index 0000000..6743b49 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeDestroyedCondition.cs @@ -0,0 +1,30 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Is Node Destroyed")] + [ActionDescription("Checks to see if a node is destroyed")] + public class IsNodeDestroyedCondition : UFAction + { + [In] + public GraphNode NodeToCheck; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + if(NodeToCheck.Destroyed) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeDestroyedCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeDestroyedCondition.cs.meta new file mode 100644 index 0000000..5e02841 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeDestroyedCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c0e397099edc6004e862ed3715bf0aee +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeWalkableCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeWalkableCondition.cs new file mode 100644 index 0000000..784ce68 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeWalkableCondition.cs @@ -0,0 +1,30 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Is Node Walkable")] + [ActionDescription("Checks to see if a node is walkable")] + public class IsNodeWalkableCondition : UFAction + { + [In] + public GraphNode NodeToCheck; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + if(NodeToCheck.Walkable) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeWalkableCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeWalkableCondition.cs.meta new file mode 100644 index 0000000..3917dcc --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsNodeWalkableCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c4e742ce72ef1314398618eef5e3b1f8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPathPossibleCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPathPossibleCondition.cs new file mode 100644 index 0000000..1c79d52 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPathPossibleCondition.cs @@ -0,0 +1,59 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Is Path Possible")] + [ActionDescription("Checks to see if a path is possible between 2 positions")] + public class IsPathPossibleCondition : UFAction + { + [In] + public Vector3 StartPoint; + + [In] + public Vector3 EndPoint; + + [In] + public float MaximumDistanceFromPoint; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + var startNode = AstarPath.active.GetNearest(StartPoint).node; + if (MaximumDistanceFromPoint > 0) + { + var startDistance = Vector3.Distance((Vector3) startNode.position, StartPoint); + if (startDistance > MaximumDistanceFromPoint) + { + False(); + return; + } + } + + var destinationNode = AstarPath.active.GetNearest(EndPoint).node; + if (MaximumDistanceFromPoint > 0) + { + var endDistance = Vector3.Distance((Vector3)destinationNode.position, EndPoint); + if (endDistance > MaximumDistanceFromPoint) + { + False(); + return; + } + } + + if(PathUtilities.IsPathPossible(startNode, destinationNode)) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPathPossibleCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPathPossibleCondition.cs.meta new file mode 100644 index 0000000..bd1807a --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPathPossibleCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6177634da8a06f842b8bc6847583e4a6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPositionWalkableCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPositionWalkableCondition.cs new file mode 100644 index 0000000..a1861a0 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPositionWalkableCondition.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Is Position Walkable")] + [ActionDescription("Checks to see if a position is walkable")] + public class IsPositionWalkableCondition : UFAction + { + [In] + public Vector3 PositionToCheck; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + if(AstarPath.active.graphs.Any(isGraphWalkable)) + { True(); } + else + { False(); } + } + + private bool isGraphWalkable(NavGraph graph) + { + var nearestNode = graph.GetNearest(PositionToCheck); + return nearestNode.node != null && nearestNode.node.Walkable; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPositionWalkableCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPositionWalkableCondition.cs.meta new file mode 100644 index 0000000..23805d8 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsPositionWalkableCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0d7ecd993b12e9949b2103165caae85d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsThereACloseEnoughNodeCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsThereACloseEnoughNodeCondition.cs new file mode 100644 index 0000000..a11eaf8 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsThereACloseEnoughNodeCondition.cs @@ -0,0 +1,42 @@ +using System; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Is There A Close Enough Node")] + [ActionDescription("Checks to see if a node is close enough to a position")] + public class IsThereACloseEnoughNodeCondition : UFAction + { + [In] + public Vector3 Position; + + [In] + public float MaximumDistance; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + var closestResult = AstarPath.active.GetNearest(Position); + if (closestResult.node == null) + { + False(); + return; + } + + var nearestNode = closestResult.node; + var distance = Vector3.Distance((Vector3)nearestNode.position, Position); + if(distance <= MaximumDistance) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsThereACloseEnoughNodeCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsThereACloseEnoughNodeCondition.cs.meta new file mode 100644 index 0000000..2a4924d --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/IsThereACloseEnoughNodeCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c90207881980ab40b0669745ad80610 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodeContainsConnectionCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodeContainsConnectionCondition.cs new file mode 100644 index 0000000..d26ec73 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodeContainsConnectionCondition.cs @@ -0,0 +1,33 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Node Contains Connection")] + [ActionDescription("Checks to see if a node contains a given connection")] + public class NodeContainsConnectionCondition : UFAction + { + [In] + public GraphNode NodeToCheck; + + [In] + public GraphNode ConnectingNode; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + if(NodeToCheck.ContainsConnection(ConnectingNode)) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodeContainsConnectionCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodeContainsConnectionCondition.cs.meta new file mode 100644 index 0000000..5cec62d --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodeContainsConnectionCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f7a2361b7cea50b4b8041fdcfbca85d4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodePenaltyPredicateCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodePenaltyPredicateCondition.cs new file mode 100644 index 0000000..8d759cd --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodePenaltyPredicateCondition.cs @@ -0,0 +1,47 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Node Penalty Predicate")] + [ActionDescription("Checks node penalty with predicate")] + public class NodePenaltyPredicateCondition : UFAction + { + [In] + public GraphNode NodeToCheck; + + [In] + public PredicateTypes PredicateType = PredicateTypes.EqualTo; + + [In] + public int ComparisonValue; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + var penalty = NodeToCheck.Penalty; + var result = false; + switch (PredicateType) + { + case PredicateTypes.EqualTo: { result = (penalty == ComparisonValue); } break; + case PredicateTypes.GreaterThan: { result = (penalty > ComparisonValue); } break; + case PredicateTypes.GreaterThanOrEqualTo: { result = (penalty >= ComparisonValue); } break; + case PredicateTypes.LessThan: { result = (penalty < ComparisonValue); } break; + case PredicateTypes.LessThanOrEqualTo: { result = (penalty <= ComparisonValue); } break; + } + + if(result) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodePenaltyPredicateCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodePenaltyPredicateCondition.cs.meta new file mode 100644 index 0000000..82ac322 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Nodes/NodePenaltyPredicateCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b9d75c8d851ddd14c9b5820b66e8bd97 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Paths.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Paths.meta new file mode 100644 index 0000000..7144d9a --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Paths.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 510b5f0f17262d64fb7758703b7da414 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedNodeCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedNodeCondition.cs new file mode 100644 index 0000000..8fcf777 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedNodeCondition.cs @@ -0,0 +1,39 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Has Reached Node")] + [ActionDescription("Checks to see if the agent is close enough to node")] + public class HasReachedNodeCondition : UFAction + { + [In] + public Vector3 SourcePosition; + + [In] + public GraphNode Node; + + [In] + public float AcceptableDistance = 0.1f; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + var nodeAsWaypoint = (Vector3) Node.position; + var distance = Vector3.Distance(nodeAsWaypoint, SourcePosition); + if(distance <= AcceptableDistance) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedNodeCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedNodeCondition.cs.meta new file mode 100644 index 0000000..9efb9cf --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedNodeCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de3aa99a664504744b3128a90e3ad448 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedWaypointCondition.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedWaypointCondition.cs new file mode 100644 index 0000000..cb21852 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedWaypointCondition.cs @@ -0,0 +1,36 @@ +using System; +using uFrame.Actions; +using uFrame.Attributes; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Has Reached Waypoint")] + [ActionDescription("Checks to see if the agent is close enough to waypoint")] + public class HasReachedWaypointCondition : UFAction + { + [In] public Vector3 SourcePosition; + + [In] + public Vector3 Waypoint; + + [In] + public float AcceptableDistance = 0.1f; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + var distance = Vector3.Distance(Waypoint, SourcePosition); + if(distance <= AcceptableDistance) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedWaypointCondition.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedWaypointCondition.cs.meta new file mode 100644 index 0000000..e17bac3 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/HasReachedWaypointCondition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 330c20cc2b1506c44b2b5b133db01d8a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Paths/IsPathValid.cs b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/IsPathValid.cs new file mode 100644 index 0000000..42e9027 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/IsPathValid.cs @@ -0,0 +1,30 @@ +using System; +using Pathfinding; +using uFrame.Actions; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameCategory("A* Pathfinding")] + [ActionTitle("Is Path Valid")] + [ActionDescription("Checks to see if the path is valid and not null or empty")] + public class IsPathValid : UFAction + { + [In] + public Path Path; + + [Out] + public Action True; + + [Out] + public Action False; + + public override void Execute() + { + if(Path == null || Path.error || Path.vectorPath.Count == 0) + { True(); } + else + { False(); } + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Conditions/Paths/IsPathValid.cs.meta b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/IsPathValid.cs.meta new file mode 100644 index 0000000..4bb9a28 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Conditions/Paths/IsPathValid.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6090861901edc154e8b69a61e94e38b9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Events.meta b/Assets/ECSModules/AStarPathfinding/Events.meta new file mode 100644 index 0000000..0574703 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Events.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 25d8ec6074fef5d4697b83c10fd2550b +folderAsset: yes +timeCreated: 1442651492 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Events/PathCreatedEvent.cs b/Assets/ECSModules/AStarPathfinding/Events/PathCreatedEvent.cs new file mode 100644 index 0000000..e126a89 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Events/PathCreatedEvent.cs @@ -0,0 +1,12 @@ +using Pathfinding; +using uFrame.Attributes; + +namespace ECSModules.AStarPathfinding +{ + [uFrameEvent("Path Created")] + [uFrameCategory("A* Pathfinding")] + public class PathCreatedEvent + { + public Path CreatedPath; + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Events/PathCreatedEvent.cs.meta b/Assets/ECSModules/AStarPathfinding/Events/PathCreatedEvent.cs.meta new file mode 100644 index 0000000..e89b179 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Events/PathCreatedEvent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3add77eaf622a6c41b2496f7562c3901 +timeCreated: 1442651501 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Extensions.meta b/Assets/ECSModules/AStarPathfinding/Extensions.meta new file mode 100644 index 0000000..658d3e3 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Extensions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 151c35ca47bfe4548a9bc2ce18f0190b +folderAsset: yes +timeCreated: 1442773094 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Extensions/ListExtensions.cs b/Assets/ECSModules/AStarPathfinding/Extensions/ListExtensions.cs new file mode 100644 index 0000000..3870dc5 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Extensions/ListExtensions.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace ECSModules.AStarPathfinding +{ + public static class ListExtensions + { + public static List> Split(this List source, int size) + { + var ret = new List>(); + for (var i = 0; i < source.Count; i += size) + { ret.Add(source.GetRange(i, Math.Min(size, source.Count - i))); } + return ret; + } + } +} diff --git a/Assets/ECSModules/AStarPathfinding/Extensions/ListExtensions.cs.meta b/Assets/ECSModules/AStarPathfinding/Extensions/ListExtensions.cs.meta new file mode 100644 index 0000000..658158f --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Extensions/ListExtensions.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 555a61de25de58a43ac322cb22aa77e3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Extensions/PathExtensions.cs b/Assets/ECSModules/AStarPathfinding/Extensions/PathExtensions.cs new file mode 100644 index 0000000..2f5f1cc --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Extensions/PathExtensions.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using Pathfinding; +using UnityEngine; + +namespace ECSModules.AStarPathfinding +{ + public static class PathExtensions + { + public static Path DuplicatePath(this Path pathToClone) + { + return new ABPath + { + duration = pathToClone.duration, + heuristicScale = pathToClone.heuristicScale, + enabledTags = pathToClone.enabledTags, + searchedNodes = pathToClone.searchedNodes, + searchIterations = pathToClone.searchIterations, + recycled = pathToClone.recycled, + nnConstraint = pathToClone.nnConstraint, + path = pathToClone.path, + vectorPath = pathToClone.vectorPath + }; + } + + public static Path ReversePath(this Path pathToReverse) + { + var duplicatePath = pathToReverse.DuplicatePath(); + duplicatePath.vectorPath.Reverse(); + duplicatePath.path.Reverse(); + return duplicatePath; + } + + public static IList SplitPath(this Path pathToSplit, int chunkSizes) + { + var splitVectorPath = pathToSplit.vectorPath.Split(chunkSizes); + var splitNodePath = pathToSplit.path.Split(chunkSizes); + var chunkedPaths = new List(); + for (var i = 0; i < splitVectorPath.Count; i++) + { + var chunkedPath = pathToSplit.DuplicatePath(); + chunkedPath.vectorPath = splitVectorPath[0]; + chunkedPath.path = splitNodePath[0]; + chunkedPaths.Add(chunkedPath); + } + return chunkedPaths; + } + + public static int FindClosestIndexTo(this Path path, Vector3 position) + { + var closestDistance = float.MaxValue; + var closestIndex = 0; + for (var i = 0; i < path.vectorPath.Count; i++) + { + var distance = Vector3.Distance(position, path.vectorPath[i]); + if (distance < closestDistance) + { + closestIndex = i; + closestDistance = distance; + } + } + return closestIndex; + } + + public static GraphNode FindClosestNodeTo(this Path path, Vector3 position) + { + var closestIndex = FindClosestIndexTo(path, position); + return path.path[closestIndex]; + } + + public static Vector3 FindClosestPositionTo(this Path path, Vector3 position) + { + var closestIndex = FindClosestIndexTo(path, position); + return path.vectorPath[closestIndex]; + } + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Extensions/PathExtensions.cs.meta b/Assets/ECSModules/AStarPathfinding/Extensions/PathExtensions.cs.meta new file mode 100644 index 0000000..b1eeab8 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Extensions/PathExtensions.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dedaf092816a4ae4ba09d2157de4138d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills.meta b/Assets/ECSModules/AStarPathfinding/Polyfills.meta new file mode 100644 index 0000000..b60bf7d --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ce7727174a410ea46b43552f636a9ac3 +folderAsset: yes +timeCreated: 1442824561 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/ConstantPath.cs b/Assets/ECSModules/AStarPathfinding/Polyfills/ConstantPath.cs new file mode 100644 index 0000000..5fae477 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/ConstantPath.cs @@ -0,0 +1,35 @@ +//#define IS_ASTAR_FREE + + +#if IS_ASTAR_FREE +namespace Pathfinding +{ + public class ConstantPath : Path + { + public static ConstantPath Construct (Vector3 start, int maxGScore, OnPathDelegate callback) + { return null; } + + public List allNodes; + + protected override void Recycle() + { + throw new System.NotImplementedException(); + } + + public override void Prepare() + { + throw new System.NotImplementedException(); + } + + public override void Initialize() + { + throw new System.NotImplementedException(); + } + + public override void CalculateStep(long targetTick) + { + throw new System.NotImplementedException(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/ConstantPath.cs.meta b/Assets/ECSModules/AStarPathfinding/Polyfills/ConstantPath.cs.meta new file mode 100644 index 0000000..8c6dcfe --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/ConstantPath.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 88799d2bc88f59e4881cb3a3e75df19c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/FleePath.cs b/Assets/ECSModules/AStarPathfinding/Polyfills/FleePath.cs new file mode 100644 index 0000000..f1da9da --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/FleePath.cs @@ -0,0 +1,33 @@ +//#define IS_ASTAR_FREE + + +#if IS_ASTAR_FREE +namespace Pathfinding +{ + public class FleePath : Path + { + public static FleePath Construct (Vector3 position , Vector3 avoid , int searchLength, OnPathDelegate callback) + { return null; } + + protected override void Recycle() + { + throw new System.NotImplementedException(); + } + + public override void Prepare() + { + throw new System.NotImplementedException(); + } + + public override void Initialize() + { + throw new System.NotImplementedException(); + } + + public override void CalculateStep(long targetTick) + { + throw new System.NotImplementedException(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/FleePath.cs.meta b/Assets/ECSModules/AStarPathfinding/Polyfills/FleePath.cs.meta new file mode 100644 index 0000000..5adadef --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/FleePath.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 71b04d52294f8344d8fbff1089fa6fb6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPath.cs b/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPath.cs new file mode 100644 index 0000000..14d37de --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPath.cs @@ -0,0 +1,33 @@ +//#define IS_ASTAR_FREE + + +#if IS_ASTAR_FREE +namespace Pathfinding +{ + public class FloodPath : Path + { + public static FloodPath Construct (Vector3 position, OnPathDelegate callback) + { return null; } + + protected override void Recycle() + { + throw new System.NotImplementedException(); + } + + public override void Prepare() + { + throw new System.NotImplementedException(); + } + + public override void Initialize() + { + throw new System.NotImplementedException(); + } + + public override void CalculateStep(long targetTick) + { + throw new System.NotImplementedException(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPath.cs.meta b/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPath.cs.meta new file mode 100644 index 0000000..b9587fc --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPath.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 98a4dc20769b65b4e818ba0fb89d6750 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPathTracer.cs b/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPathTracer.cs new file mode 100644 index 0000000..95a80bc --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPathTracer.cs @@ -0,0 +1,33 @@ +//#define IS_ASTAR_FREE + + +#if IS_ASTAR_FREE +namespace Pathfinding +{ + public class FloodPathTracer : Path + { + public static FloodPathTracer Construct (Vector3 position , FloodPath floodPath , OnPathDelegate callback) + { return null; } + + protected override void Recycle() + { + throw new System.NotImplementedException(); + } + + public override void Prepare() + { + throw new System.NotImplementedException(); + } + + public override void Initialize() + { + throw new System.NotImplementedException(); + } + + public override void CalculateStep(long targetTick) + { + throw new System.NotImplementedException(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPathTracer.cs.meta b/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPathTracer.cs.meta new file mode 100644 index 0000000..bc6d6da --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/FloodPathTracer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d044f8a2af3ca904cbf28948849fc0a3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/MultiTargetPath.cs b/Assets/ECSModules/AStarPathfinding/Polyfills/MultiTargetPath.cs new file mode 100644 index 0000000..abc24b7 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/MultiTargetPath.cs @@ -0,0 +1,36 @@ +//#define IS_ASTAR_FREE + + +#if IS_ASTAR_FREE +namespace Pathfinding +{ + public class MultiTargetPath : Path + { + public static MultiTargetPath Construct(Vector3[] startPoints, Vector3 target, OnPathDelegate[] callbackDelegates, OnPathDelegate callback) + { return null; } + + public static MultiTargetPath Construct (Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, OnPathDelegate callback) + { return null; } + + protected override void Recycle() + { + throw new System.NotImplementedException(); + } + + public override void Prepare() + { + throw new System.NotImplementedException(); + } + + public override void Initialize() + { + throw new System.NotImplementedException(); + } + + public override void CalculateStep(long targetTick) + { + throw new System.NotImplementedException(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/MultiTargetPath.cs.meta b/Assets/ECSModules/AStarPathfinding/Polyfills/MultiTargetPath.cs.meta new file mode 100644 index 0000000..fe3ff66 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/MultiTargetPath.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 13c631048108b344fb637cc74d0c4a46 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/RandomPath.cs b/Assets/ECSModules/AStarPathfinding/Polyfills/RandomPath.cs new file mode 100644 index 0000000..9418d0f --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/RandomPath.cs @@ -0,0 +1,33 @@ +//#define IS_ASTAR_FREE + + +#if IS_ASTAR_FREE +namespace Pathfinding +{ + public class RandomPath : Path + { + public static RandomPath Construct(Vector3 position, int length, OnPathDelegate callback) + {return null;} + + protected override void Recycle() + { + throw new System.NotImplementedException(); + } + + public override void Prepare() + { + throw new System.NotImplementedException(); + } + + public override void Initialize() + { + throw new System.NotImplementedException(); + } + + public override void CalculateStep(long targetTick) + { + throw new System.NotImplementedException(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Polyfills/RandomPath.cs.meta b/Assets/ECSModules/AStarPathfinding/Polyfills/RandomPath.cs.meta new file mode 100644 index 0000000..0dbcfca --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Polyfills/RandomPath.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cab6fa499a3b44a4f8bce9708d1a7812 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ECSModules/AStarPathfinding/Types.meta b/Assets/ECSModules/AStarPathfinding/Types.meta new file mode 100644 index 0000000..d9c41c5 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Types.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 454dff5163d9eec47ac0655f9943a217 +folderAsset: yes +timeCreated: 1442833944 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ECSModules/AStarPathfinding/Types/PredicateTypes.cs b/Assets/ECSModules/AStarPathfinding/Types/PredicateTypes.cs new file mode 100644 index 0000000..455e111 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Types/PredicateTypes.cs @@ -0,0 +1,11 @@ +namespace ECSModules.AStarPathfinding +{ + public enum PredicateTypes + { + EqualTo, + GreaterThan, + GreaterThanOrEqualTo, + LessThan, + LessThanOrEqualTo + } +} \ No newline at end of file diff --git a/Assets/ECSModules/AStarPathfinding/Types/PredicateTypes.cs.meta b/Assets/ECSModules/AStarPathfinding/Types/PredicateTypes.cs.meta new file mode 100644 index 0000000..c579d39 --- /dev/null +++ b/Assets/ECSModules/AStarPathfinding/Types/PredicateTypes.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf1c101bc310f6243b8f7eac1b6c61bb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta new file mode 100644 index 0000000..86f8d62 --- /dev/null +++ b/Assets/Plugins.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 96c1decd88c4a7e4881885711e64fb27 +folderAsset: yes +timeCreated: 1442114557 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Dist/ecs.astarpathfinding-1.0.0.unitypackage b/Dist/ecs.astarpathfinding-1.0.0.unitypackage new file mode 100644 index 0000000..887d691 Binary files /dev/null and b/Dist/ecs.astarpathfinding-1.0.0.unitypackage differ diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset new file mode 100644 index 0000000..6eae5ce Binary files /dev/null and b/ProjectSettings/AudioManager.asset differ diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset new file mode 100644 index 0000000..cac8c34 Binary files /dev/null and b/ProjectSettings/DynamicsManager.asset differ diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 0000000..4f27c1e Binary files /dev/null and b/ProjectSettings/EditorBuildSettings.asset differ diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset new file mode 100644 index 0000000..4441fd7 Binary files /dev/null and b/ProjectSettings/EditorSettings.asset differ diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 0000000..f0b6b9b Binary files /dev/null and b/ProjectSettings/GraphicsSettings.asset differ diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset new file mode 100644 index 0000000..56f6e26 Binary files /dev/null and b/ProjectSettings/InputManager.asset differ diff --git a/ProjectSettings/NavMeshAreas.asset b/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 0000000..3ef01bf Binary files /dev/null and b/ProjectSettings/NavMeshAreas.asset differ diff --git a/ProjectSettings/NetworkManager.asset b/ProjectSettings/NetworkManager.asset new file mode 100644 index 0000000..affeb26 Binary files /dev/null and b/ProjectSettings/NetworkManager.asset differ diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 0000000..475bb09 Binary files /dev/null and b/ProjectSettings/Physics2DSettings.asset differ diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset new file mode 100644 index 0000000..3d43d6e Binary files /dev/null and b/ProjectSettings/ProjectSettings.asset differ diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt new file mode 100644 index 0000000..2a285eb --- /dev/null +++ b/ProjectSettings/ProjectVersion.txt @@ -0,0 +1,2 @@ +m_EditorVersion: 5.1.0f3 +m_StandardAssetsVersion: 0 diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset new file mode 100644 index 0000000..9c564fd Binary files /dev/null and b/ProjectSettings/QualitySettings.asset differ diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset new file mode 100644 index 0000000..7134375 Binary files /dev/null and b/ProjectSettings/TagManager.asset differ diff --git a/ProjectSettings/TimeManager.asset b/ProjectSettings/TimeManager.asset new file mode 100644 index 0000000..b3e5ca9 Binary files /dev/null and b/ProjectSettings/TimeManager.asset differ diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..b1d6115 --- /dev/null +++ b/Readme.md @@ -0,0 +1,33 @@ +# A* Pathfinding Actions for uFrame ECS + +A set of actions to expose A* pathfinding functionality directly to the ECS handlers. + +## Targeted Versions + +- uFrame ECS (beta2) +- A* Free/Pro (3.7) + +## Installation + +- Make sure you have added this package with at least the AStarPathfinding folder +- Make sure you have A* Pathfinding (Aron Granberg) free or pro installed +- Make sure you have uFrame ECS installed + +We have a `dist` folder to allow you to just take the `.unitypackage`, although you can download the source if you wish to make a custom version of the actions. + +## Using Actions & Conditions +You should now notice that you have a new category in your actions and conditions called A* Pathfinding +and A* Pathfinding Pro. You can then put the actions into your project and use them rather than +interacting progmatically. + +## Using A* Free Version + +If you are using the free version then you will need to enable polyfills or you will get errors +within the project, to enable polyfills go to the "polyfills" folder and you should see a list +of files within there. The top line will have a commented out bit of code which looks like: + +`//#define IS_ASTAR_FREE` + +If you remove the `//` (uncomment) that line in each polyfill then your actions will work correctly. +This unfortunately is the only way in which we can support both pro and free versions with a +single package. \ No newline at end of file