OnDestroy() public method

public OnDestroy ( ) : void
return void
Ejemplo n.º 1
0
        /** Removes the specified graph from the #graphs array and Destroys it in a safe manner.
         * To avoid changing graph indices for the other graphs, the graph is simply nulled in the array instead
         * of actually removing it from the array.
         * The empty position will be reused if a new graph is added.
         *
         * \returns True if the graph was sucessfully removed (i.e it did exist in the #graphs array). False otherwise.
         *
         *
         * \version Changed in 3.2.5 to call SafeOnDestroy before removing
         * and nulling it in the array instead of removing the element completely in the #graphs array.
         *
         */
        public bool RemoveGraph(NavGraph graph)
        {
            // Make sure all graph updates and other callbacks are done
            active.FlushWorkItems(false, true);

            // Make sure the pathfinding threads are stopped
            active.BlockUntilPathQueueBlocked();

            // //Safe OnDestroy is called since there is a risk that the pathfinding is searching through the graph right now,
            // //and if we don't wait until the search has completed we could end up with evil NullReferenceExceptions
            graph.OnDestroy();

            int i = System.Array.IndexOf(graphs, graph);

            if (i == -1)
            {
                return(false);
            }

            graphs[i] = null;

            UpdateShortcuts();

            return(true);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public bool RemoveGraph(NavGraph graph)
        {
            AstarData.active.FlushWorkItems(false, true);
            AstarData.active.BlockUntilPathQueueBlocked();
            graph.OnDestroy();
            int num = Array.IndexOf <NavGraph>(this.graphs, graph);

            if (num == -1)
            {
                return(false);
            }
            this.graphs[num] = null;
            this.UpdateShortcuts();
            return(true);
        }
Ejemplo n.º 4
0
        /** Removes the specified graph from the #graphs array and Destroys it in a safe manner.
         * To avoid changing graph indices for the other graphs, the graph is simply nulled in the array instead
         * of actually removing it from the array.
         * The empty position will be reused if a new graph is added.
         *
         * \returns True if the graph was sucessfully removed (i.e it did exist in the #graphs array). False otherwise.
         *
         * \version Changed in 3.2.5 to call SafeOnDestroy before removing
         * and nulling it in the array instead of removing the element completely in the #graphs array.
         */
        public bool RemoveGraph(NavGraph graph)
        {
            // Make sure the pathfinding threads are stopped
            // If we don't wait until pathfinding that is potentially running on
            // this graph right now we could end up with NullReferenceExceptions
            var graphLock = AssertSafe();

            graph.OnDestroy();
            graph.active = null;

            int i = System.Array.IndexOf(graphs, graph);

            if (i != -1)
            {
                graphs[i] = null;
            }

            UpdateShortcuts();
            graphLock.Release();
            return(i != -1);
        }
Ejemplo n.º 5
0
        /** Removes the specified graph from the #graphs array and Destroys it in a safe manner.
         * To avoid changing graph indices for the other graphs, the graph is simply nulled in the array instead
         * of actually removing it from the array.
         * The empty position will be reused if a new graph is added.
         *
         * \returns True if the graph was sucessfully removed (i.e it did exist in the #graphs array). False otherwise.
         *
         * \version Changed in 3.2.5 to call SafeOnDestroy before removing
         * and nulling it in the array instead of removing the element completely in the #graphs array.
         */
        public bool RemoveGraph(NavGraph graph)
        {
            // Make sure the pathfinding threads are stopped
            // If we don't wait until pathfinding that is potentially running on
            // this graph right now we could end up with NullReferenceExceptions
            var graphLock = active.PausePathfinding();

            // Make sure all graph updates and other callbacks are done
            active.FlushWorkItems();

            graph.OnDestroy();

            int i = System.Array.IndexOf(graphs, graph);

            if (i != -1)
            {
                graphs[i] = null;
            }

            UpdateShortcuts();
            graphLock.Release();
            return(i != -1);
        }
Ejemplo n.º 6
0
        /** Removes the specified graph from the #graphs array and Destroys it in a safe manner.
         * To avoid changing graph indices for the other graphs, the graph is simply nulled in the array instead
         * of actually removing it from the array.
         * The empty position will be reused if a new graph is added.
         *
         * \returns True if the graph was sucessfully removed (i.e it did exist in the #graphs array). False otherwise.
         *
         * \version Changed in 3.2.5 to call SafeOnDestroy before removing
         * and nulling it in the array instead of removing the element completely in the #graphs array.
         */
        public bool RemoveGraph(NavGraph graph)
        {
            // Make sure all graph updates and other callbacks are done
            active.FlushWorkItemsInternal(false);

            // Make sure the pathfinding threads are stopped
            // If we don't wait until pathfinding that is potentially running on
            // this graph right now we could end up with NullReferenceExceptions
            active.BlockUntilPathQueueBlocked();

            graph.OnDestroy();

            int i = System.Array.IndexOf(graphs, graph);

            if (i == -1)
            {
                return(false);
            }

            graphs[i] = null;
            UpdateShortcuts();
            return(true);
        }
Ejemplo n.º 7
0
		/** Removes the specified graph from the #graphs array and Destroys it in a safe manner.
		 * To avoid changing graph indices for the other graphs, the graph is simply nulled in the array instead
		 * of actually removing it from the array.
		 * The empty position will be reused if a new graph is added.
		 * 
		 * \returns True if the graph was sucessfully removed (i.e it did exist in the #graphs array). False otherwise.
		 * 
		 * 
		 * \version Changed in 3.2.5 to call SafeOnDestroy before removing
		 * and nulling it in the array instead of removing the element completely in the #graphs array.
		 * 
		 */
		public bool RemoveGraph (NavGraph graph) {

			// Make sure all graph updates and other callbacks are done
			active.FlushWorkItems (false, true);

			// Make sure the pathfinding threads are stopped
			active.BlockUntilPathQueueBlocked ();

			// //Safe OnDestroy is called since there is a risk that the pathfinding is searching through the graph right now,
			// //and if we don't wait until the search has completed we could end up with evil NullReferenceExceptions
			graph.OnDestroy ();

			int i = System.Array.IndexOf (graphs, graph);

			if (i == -1) {
				return false;
			}
			
			graphs[i] = null;
			
			UpdateShortcuts ();
			
			return true;
		}