From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 23 May 2024 10:08:29 +0800 Subject: + astar project --- .../Core/Misc/GraphSnapshot.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/GraphSnapshot.cs (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/GraphSnapshot.cs') diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/GraphSnapshot.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/GraphSnapshot.cs new file mode 100644 index 0000000..4b21d17 --- /dev/null +++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Core/Misc/GraphSnapshot.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using UnityEngine.Profiling; + +namespace Pathfinding.Util { + public interface IGraphSnapshot : System.IDisposable { + /// + /// Restores the graph data to the state it had when the snapshot was taken, in the bounding box that the snapshot captured. + /// + /// You can get the context from the callback provided to the method. + /// + void Restore(IGraphUpdateContext ctx); + } + + /// + /// A snapshot of parts of graphs. + /// + /// See: + /// + public struct GraphSnapshot : IGraphSnapshot { + List inner; + + internal GraphSnapshot (List inner) { + this.inner = inner; + } + + /// \copydocref{IGraphSnapshot.Restore} + public void Restore (IGraphUpdateContext ctx) { + Profiler.BeginSample("Restoring Graph Snapshot"); + for (int i = 0; i < inner.Count; i++) { + inner[i].Restore(ctx); + } + Profiler.EndSample(); + } + + public void Dispose () { + if (inner != null) { + for (int i = 0; i < inner.Count; i++) { + inner[i].Dispose(); + } + inner = null; + } + } + } +} -- cgit v1.1-26-g67d0