Пример #1
0
 public void OnDisabled(NetworkNodeAsset node)
 {
     if (autoRecalculate)
     {
         RecalculateNode(node);
     }
 }
Пример #2
0
 public ConnectionAsset(NetworkNodeAsset from, NetworkNodeAsset to, float width, CollectionAsset collection) : base(collection)
 {
     this.from         = from;
     this.to           = to;
     this.width        = width;
     this.enabled      = true;
     this.weightFactor = 1.0f;
 }
Пример #3
0
            public CachedSeeker(Seeker seeker)
            {
                this.start    = seeker.Start;
                this.end      = seeker.End;
                this.solution = new ArrayList(seeker.Solution);

                Restart(seeker.CacheLifespan);
            }
Пример #4
0
		public ConnectionAsset( NetworkNodeAsset from, NetworkNodeAsset to, float width, CollectionAsset collection ) : base( collection )
		{
			this.from = from;
			this.to = to;
			this.width = width;
			this.enabled = true;
			this.weightFactor = 1.0f;
		}
Пример #5
0
			public CachedSeeker( Seeker seeker )
			{
				this.start = seeker.Start;
				this.end = seeker.End;
				this.solution = new ArrayList( seeker.Solution );
				
				Restart( seeker.CacheLifespan );
			}
Пример #6
0
        public bool ConnectTo(NetworkNodeAsset destination, float width)
        {
            if (ConnectsTo(destination))
            {
                return(false);
            }

            AddConnection(new ConnectionAsset(this, destination, width, Collection));

            return(true);
        }
Пример #7
0
		public GridNodeAsset( GridNodeAsset original, NetworkAsset network ) : base( network, original.Collection )
		{
			this.Name = original.Name;
			target = original.Target;
			
			this.Tags = new int[ original.Tags.Length ];
			for( int i = 0; i < original.Tags.Length; i++ )
			// Copy the tag indexes
			{
				this.Tags[ i ] = original.Tags[ i ];
			}
		}
Пример #8
0
        public ConnectionAsset GetConnection(NetworkNodeAsset destination)
        {
            foreach (ConnectionAsset connection in connections)
            {
                if (connection.To == destination)
                {
                    return(connection);
                }
            }

            return(null);
        }
Пример #9
0
        public GridNodeAsset(GridNodeAsset original, NetworkAsset network) : base(network, original.Collection)
        {
            this.Name = original.Name;
            target    = original.Target;

            this.Tags = new int[original.Tags.Length];
            for (int i = 0; i < original.Tags.Length; i++)
            // Copy the tag indexes
            {
                this.Tags[i] = original.Tags[i];
            }
        }
Пример #10
0
        public void ReplaceConnections(ArrayList nodes, NetworkNodeAsset newNode)
        {
            NetworkNodeAsset[] theNodes;

            theNodes = new CellAsset[nodes.Count];

            for (int i = 0; i < nodes.Count; i++)
            {
                theNodes[i] = ( NetworkNodeAsset )nodes[i];
            }

            ReplaceConnections(theNodes, newNode);
        }
Пример #11
0
        public ArrayList GetConnections(NetworkNodeAsset destination)
        {
            ArrayList result;

            result = new ArrayList();
            foreach (ConnectionAsset connection in connections)
            {
                if (connection.To == destination)
                {
                    result.Add(connection);
                }
            }

            return(result);
        }
Пример #12
0
        public bool DoesUse(NetworkNodeAsset node)
        {
            if (end == node)
            {
                return(true);
            }

            foreach (ConnectionAsset connection in Solution)
            {
                if (connection.From == node)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #13
0
        public ArrayList GetGridNodes(NetworkNodeAsset node)
        {
            ArrayList result;

            result = new ArrayList();
            foreach (GridNetworkAsset network in GridNetworks)
            {
                foreach (GridNodeAsset gridNode in network.Nodes)
                {
                    if (gridNode.Target == node)
                    {
                        result.Add(gridNode);
                    }
                }
            }

            return(result);
        }
Пример #14
0
        public Seeker( Vector3 from, Vector3 to, float maxFrameTime, float radius, object data )
        {
            this.from = from;
            this.to = to;
            this.maxFrameTime = maxFrameTime;
            this.radius = radius;
            this.data = data;
            requiredTags = new string[ 0 ];
            excludedTags = new string[ 0 ];
            validateNetworks = false;

            start = Control.Instance.NearestNode( from, this );
            end = Control.Instance.NearestNode( to, this );
            monitors = new ArrayList();
            solution = new ArrayList();
            seeking = false;

            cacheLifespan = Control.NoCache;

            Control.Instance.RegisterSeeker( this );
        }
Пример #15
0
        public Seeker(Vector3 from, Vector3 to, float maxFrameTime, float radius, object data)
        {
            this.from         = from;
            this.to           = to;
            this.maxFrameTime = maxFrameTime;
            this.radius       = radius;
            this.data         = data;
            requiredTags      = new string[0];
            excludedTags      = new string[0];
            validateNetworks  = false;

            start    = Control.Instance.NearestNode(from, this);
            end      = Control.Instance.NearestNode(to, this);
            monitors = new ArrayList();
            solution = new ArrayList();
            seeking  = false;

            cacheLifespan = Control.NoCache;

            Control.Instance.RegisterSeeker(this);
        }
Пример #16
0
        public void ReplaceConnections(NetworkNodeAsset[] nodes, NetworkNodeAsset newNode)
        // TODO: Move to parent
        {
            ConnectionAsset connection;

            foreach (NetworkNodeAsset node in nodes)
            {
                foreach (ConnectionAsset existingConnection in node.Connections)
                {
                    if (Array.IndexOf(nodes, existingConnection.To) != -1)
                    {
                        existingConnection.To = null;
                        continue;
                    }

                    existingConnection.From = newNode;
                    newNode.AddConnection(existingConnection);
                }
            }

            foreach (NetworkNodeAsset node in Nodes)
            {
                if (Array.IndexOf(nodes, node) != -1)
                {
                    continue;
                }

                foreach (NetworkNodeAsset targetNode in nodes)
                {
                    while (node.ConnectsTo(targetNode))
                    {
                        connection    = node.GetConnection(targetNode);
                        connection.To = newNode;
                    }
                }
            }
        }
Пример #17
0
        public void RecalculateNode(NetworkNodeAsset node)
        {
            CachedSeeker cache;
            Seeker       seeker;

            // TODO: Implement for active seekers as well (we need to get out of the seeker coroutine without doing OnCompleted/OnFailed)

            for (int i = 0; i < cachedSeekers.Count;)
            {
                cache = ( CachedSeeker )cachedSeekers[i];

                if (cache.DoesUse(node))
                {
                    cachedSeekers.Remove(cache);
                }
                else
                {
                    i++;
                }
            }

            for (int i = 0; i < usedSeekers.Count;)
            {
                seeker = ( Seeker )usedSeekers[i];

                if (seeker.DoesUse(node))
                {
                    usedSeekers.Remove(seeker);
                    seeker.Invalidate();
                }
                else
                {
                    i++;
                }
            }
        }
Пример #18
0
		public void ReplaceConnections( NetworkNodeAsset[] nodes, NetworkNodeAsset newNode )
		// TODO: Move to parent
		{
			ConnectionAsset connection;			
					
			foreach( NetworkNodeAsset node in nodes )
			{
				foreach( ConnectionAsset existingConnection in node.Connections )
				{
					if( Array.IndexOf( nodes, existingConnection.To ) != -1 )
					{
						existingConnection.To = null;
						continue;
					}
					
					existingConnection.From = newNode;
					newNode.AddConnection( existingConnection );
				}
			}
			
			foreach( NetworkNodeAsset node in Nodes )
			{
				if( Array.IndexOf( nodes, node ) != -1 )
				{
					continue;
				}
				
				foreach( NetworkNodeAsset targetNode in nodes )
				{
					while( node.ConnectsTo( targetNode ) )
					{
						connection = node.GetConnection( targetNode );
						connection.To = newNode;
					}
				}
			}
		}
Пример #19
0
        public bool DoesUse( NetworkNodeAsset node )
        {
            if( end == node )
            {
                return true;
            }

            foreach( ConnectionAsset connection in Solution )
            {
                if( connection.From == node )
                {
                    return true;
                }
            }

            return false;
        }
Пример #20
0
		public Vector3 WorldPosition( NetworkNodeAsset node )
		{
			return node.Position + node.Network.Position + Owner.transform.position;
		}
Пример #21
0
		public ConnectionAsset GetConnection( NetworkNodeAsset destination )
		{
			foreach( ConnectionAsset connection in connections )
			{
				if( connection.To == destination )
				{
					return connection;
				}
			}
			
			return null;
		}
Пример #22
0
		public bool ConnectTo( NetworkNodeAsset destination, float width )
		{
			if( ConnectsTo( destination ) )
			{
				return false;
			}
			
			AddConnection( new ConnectionAsset( this, destination, width, Collection ) );
			
			return true;
		}
Пример #23
0
		public bool ConnectsTo( NetworkNodeAsset destination )
		{
			return GetConnection( destination ) != null;
		}
Пример #24
0
		public ArrayList GetConnections( NetworkNodeAsset destination )
		{
			ArrayList result;
			
			result = new ArrayList();
			foreach( ConnectionAsset connection in connections )
			{
				if( connection.To == destination )
				{
					result.Add( connection );
				}
			}
			
			return result;
		}
Пример #25
0
 public bool ConnectsTo(NetworkNodeAsset destination)
 {
     return(GetConnection(destination) != null);
 }
Пример #26
0
		public void RecalculateNode( NetworkNodeAsset node )
		{
			CachedSeeker cache;
			Seeker seeker;

			// TODO: Implement for active seekers as well (we need to get out of the seeker coroutine without doing OnCompleted/OnFailed)
			
			for( int i = 0; i < cachedSeekers.Count; )
			{
				cache = ( CachedSeeker )cachedSeekers[ i ];
				
				if( cache.DoesUse( node ) )
				{
					cachedSeekers.Remove( cache );
				}
				else
				{
					i++;
				}
			}
			
			for( int i = 0; i < usedSeekers.Count; )
			{
				seeker = ( Seeker )usedSeekers[ i ];
				
				if( seeker.DoesUse( node ) )
				{
					usedSeekers.Remove( seeker );
					seeker.Invalidate();
				}
				else
				{
					i++;
				}
			}
		}
Пример #27
0
		public void OnDisabled( NetworkNodeAsset node )
		{
			if( autoRecalculate )
			{
				RecalculateNode( node );
			}
		}
Пример #28
0
 public Vector3 WorldPosition(NetworkNodeAsset node)
 {
     return(node.Position + node.Network.Position + Owner.transform.position);
 }
Пример #29
0
		public ArrayList GetGridNodes( NetworkNodeAsset node )
		{
			ArrayList result;
			
			result = new ArrayList();
			foreach( GridNetworkAsset network in GridNetworks )
			{
				foreach( GridNodeAsset gridNode in network.Nodes )
				{
					if( gridNode.Target == node )
					{
						result.Add( gridNode );
					}
				}
			}
			
			return result;
		}
Пример #30
0
		public void ReplaceConnections( ArrayList nodes, NetworkNodeAsset newNode )
		{
			NetworkNodeAsset[] theNodes;
			
			theNodes = new CellAsset[ nodes.Count ];
			
			for( int i = 0; i < nodes.Count; i++ )
			{
				theNodes[ i ] = ( NetworkNodeAsset )nodes[ i ];
			}
			
			ReplaceConnections( theNodes, newNode );
		}