Exemplo n.º 1
0
 public void OnDisabled(NetworkNodeAsset node)
 {
     if (autoRecalculate)
     {
         RecalculateNode(node);
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
            public CachedSeeker(Seeker seeker)
            {
                this.start    = seeker.Start;
                this.end      = seeker.End;
                this.solution = new ArrayList(seeker.Solution);

                Restart(seeker.CacheLifespan);
            }
Exemplo n.º 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;
		}
Exemplo n.º 5
0
			public CachedSeeker( Seeker seeker )
			{
				this.start = seeker.Start;
				this.end = seeker.End;
				this.solution = new ArrayList( seeker.Solution );
				
				Restart( seeker.CacheLifespan );
			}
Exemplo n.º 6
0
        public bool ConnectTo(NetworkNodeAsset destination, float width)
        {
            if (ConnectsTo(destination))
            {
                return(false);
            }

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

            return(true);
        }
Exemplo n.º 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 ];
			}
		}
Exemplo n.º 8
0
        public ConnectionAsset GetConnection(NetworkNodeAsset destination)
        {
            foreach (ConnectionAsset connection in connections)
            {
                if (connection.To == destination)
                {
                    return(connection);
                }
            }

            return(null);
        }
Exemplo n.º 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];
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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 );
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
                    }
                }
            }
        }
Exemplo n.º 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++;
                }
            }
        }
Exemplo n.º 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;
					}
				}
			}
		}
Exemplo n.º 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;
        }
Exemplo n.º 20
0
		public Vector3 WorldPosition( NetworkNodeAsset node )
		{
			return node.Position + node.Network.Position + Owner.transform.position;
		}
Exemplo n.º 21
0
		public ConnectionAsset GetConnection( NetworkNodeAsset destination )
		{
			foreach( ConnectionAsset connection in connections )
			{
				if( connection.To == destination )
				{
					return connection;
				}
			}
			
			return null;
		}
Exemplo n.º 22
0
		public bool ConnectTo( NetworkNodeAsset destination, float width )
		{
			if( ConnectsTo( destination ) )
			{
				return false;
			}
			
			AddConnection( new ConnectionAsset( this, destination, width, Collection ) );
			
			return true;
		}
Exemplo n.º 23
0
		public bool ConnectsTo( NetworkNodeAsset destination )
		{
			return GetConnection( destination ) != null;
		}
Exemplo n.º 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;
		}
Exemplo n.º 25
0
 public bool ConnectsTo(NetworkNodeAsset destination)
 {
     return(GetConnection(destination) != null);
 }
Exemplo n.º 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++;
				}
			}
		}
Exemplo n.º 27
0
		public void OnDisabled( NetworkNodeAsset node )
		{
			if( autoRecalculate )
			{
				RecalculateNode( node );
			}
		}
Exemplo n.º 28
0
 public Vector3 WorldPosition(NetworkNodeAsset node)
 {
     return(node.Position + node.Network.Position + Owner.transform.position);
 }
Exemplo n.º 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;
		}
Exemplo n.º 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 );
		}