private static IEnumerator ChunkDisconnection() { TemplateChunkDisconnection d_t = null; while (true) { //if (_activeCreationWorks > 0) // Debug.LogFormat("TemplateChunkDisconnection is blocked by _activeCreationWorks > 0, tasks: {0}", _disconnectionQueue.Count); if (_activeCreationWorks > 0) { goto next; } d_t = _disconnectionQueue.Count > 0 ? _disconnectionQueue.Dequeue() : null; if (d_t == null) { goto next; } d_t.Work(); goto next; next: { yield return(new WaitForEndOfFrame()); continue; } } }
//remove graph //function to remove graph at some space //IMPORTANT: if bool createNewGraphAfter == true then pathfinder are also add this graph to generation queue after it was removed public static void RemoveGraph(XZPosInt pos, AgentProperties properties, bool createNewGraphAfter = true) { Init(); if (_acceptingWork == false) { return; } lock (_allTemplatesDestructive) { if (_allTemplatesDestructive.Exists(x => x.Match(pos, properties))) { return; //already in progress } } Graph graph; if (TryGetGraph(pos, properties, out graph)) { TemplateChunkDisconnection template = new TemplateChunkDisconnection(graph); _allTemplatesDestructive.Add(template); template.SetCallBack(() => { #if UNITY_EDITOR Debuger_K.UpdateSceneImportantThings(); Debuger_K.ClearChunksDebug(pos.x, pos.z, properties); #endif lock (_chunkData) { _chunkData.Remove(new GeneralXZData(pos, properties)); } _allTemplatesDestructive.Remove(template); if (createNewGraphAfter) { QueueNavMeshTemplateToPopulation(pos, properties); } }); _disconnectionQueue.Enqueue(template); } }