示例#1
0
 public void DeserializeGraphsPart(AstarSerializer sr)
 {
     PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(false);
     this.ClearGraphs();
     this.DeserializeGraphsPartAdditive(sr);
     graphUpdateLock.Release();
 }
示例#2
0
        private void AddGraph(NavGraph graph)
        {
            PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(true);
            bool flag = false;

            for (int i = 0; i < this.graphs.Length; i++)
            {
                if (this.graphs[i] == null)
                {
                    this.graphs[i]   = graph;
                    graph.graphIndex = (uint)i;
                    flag             = true;
                    break;
                }
            }
            if (!flag)
            {
                if (this.graphs != null && (long)this.graphs.Length >= 255L)
                {
                    throw new Exception("Graph Count Limit Reached. You cannot have more than " + 255u + " graphs.");
                }
                this.graphs = new List <NavGraph>(this.graphs ?? new NavGraph[0])
                {
                    graph
                }.ToArray();
                graph.graphIndex = (uint)(this.graphs.Length - 1);
            }
            this.UpdateShortcuts();
            graph.active = AstarData.active;
            graphUpdateLock.Release();
        }
示例#3
0
 public void DeserializeGraphsAdditive(byte[] bytes)
 {
     PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(false);
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("bytes");
         }
         AstarSerializer astarSerializer = new AstarSerializer(this);
         if (astarSerializer.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPartAdditive(astarSerializer);
             astarSerializer.CloseDeserialize();
         }
         else
         {
             Debug.Log("Invalid data file (cannot read zip).\nThe data is either corrupt or it was saved using a 3.0.x or earlier version of the system");
         }
         AstarData.active.VerifyIntegrity();
     }
     catch (Exception arg)
     {
         Debug.LogError("Caught exception while deserializing data.\n" + arg);
         this.graphs      = new NavGraph[0];
         this.data_backup = bytes;
     }
     this.UpdateShortcuts();
     graphUpdateLock.Release();
 }
示例#4
0
 public void DeserializeGraphs(byte[] bytes)
 {
     PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(false);
     this.ClearGraphs();
     this.DeserializeGraphsAdditive(bytes);
     graphUpdateLock.Release();
 }
示例#5
0
        // Token: 0x06002745 RID: 10053 RVA: 0x001AD344 File Offset: 0x001AB544
        public static bool UpdateGraphsNoBlock(GraphUpdateObject guo, List <GraphNode> nodes, bool alwaysRevert = false)
        {
            for (int i = 0; i < nodes.Count; i++)
            {
                if (!nodes[i].Walkable)
                {
                    return(false);
                }
            }
            guo.trackChangedNodes = true;
            PathProcessor.GraphUpdateLock graphUpdateLock = AstarPath.active.PausePathfinding();
            bool flag;

            try
            {
                AstarPath.active.UpdateGraphs(guo);
                AstarPath.active.FlushGraphUpdates();
                flag = PathUtilities.IsPathPossible(nodes);
                if (!flag || alwaysRevert)
                {
                    guo.RevertFromBackup();
                    AstarPath.active.FloodFill();
                }
            }
            finally
            {
                graphUpdateLock.Release();
            }
            guo.trackChangedNodes = false;
            return(flag);
        }
示例#6
0
        public byte[] SerializeGraphs(SerializeSettings settings, out uint checksum)
        {
            PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(false);
            AstarSerializer astarSerializer = new AstarSerializer(this, settings);

            astarSerializer.OpenSerialize();
            this.SerializeGraphsPart(astarSerializer);
            byte[] result = astarSerializer.CloseSerialize();
            checksum = astarSerializer.GetChecksum();
            graphUpdateLock.Release();
            return(result);
        }
示例#7
0
        public bool RemoveGraph(NavGraph graph)
        {
            PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(false);
            graph.OnDestroy();
            graph.active = null;
            int num = Array.IndexOf <NavGraph>(this.graphs, graph);

            if (num != -1)
            {
                this.graphs[num] = null;
            }
            this.UpdateShortcuts();
            graphUpdateLock.Release();
            return(num != -1);
        }
示例#8
0
 public void LoadFromCache()
 {
     PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(false);
     if (this.file_cachedStartup != null)
     {
         byte[] bytes = this.file_cachedStartup.bytes;
         this.DeserializeGraphs(bytes);
         GraphModifier.TriggerEvent(GraphModifier.EventType.PostCacheLoad);
     }
     else
     {
         Debug.LogError("Can't load from cache since the cache is empty");
     }
     graphUpdateLock.Release();
 }