Exemple #1
0
 public void OnDisabled(NetworkAsset network)
 {
     if (autoRecalculate)
     {
         RecalculateNetwork(network);
     }
 }
Exemple #2
0
 public WaypointAsset(string name, Vector3 position, float radius, NetworkAsset network, CollectionAsset collection) : base(network, collection)
 {
     this.Name      = name;
     this.Position  = position;
     this.radius    = radius;
     disableRuntime = true;
 }
Exemple #3
0
		public NetworkNodeAsset( NetworkAsset network, CollectionAsset collection ) : base( collection )
		{
			x = y = z = 0.0f;
			connections = new ConnectionAsset[ 0 ];
			enabled = true;
			this.network = network;
		}
Exemple #4
0
        public bool Remove(NetworkAsset network)
        {
            NetworkAsset[] newNetworks;
            bool           found;

            newNetworks = new NetworkAsset[networks.Length - 1];
            found       = false;

            for (int i = 0; i < newNetworks.Length; i++)
            {
                if (networks[i] == network)
                {
                    found = true;
                }

                newNetworks[i] = networks[i + ((found) ? 1 : 0)];
            }

            found = (networks[newNetworks.Length] == network) ? true : found;

            if (!found)
            {
                return(false);
            }

            networks = newNetworks;

            return(true);
        }
Exemple #5
0
		public WaypointAsset( string name, Vector3 position, float radius, NetworkAsset network, CollectionAsset collection ) : base( network, collection )
		{
			this.Name = name;
			this.Position = position;
			this.radius = radius;
			disableRuntime = true;
		}
Exemple #6
0
 public NetworkNodeAsset(NetworkAsset network, CollectionAsset collection) : base(collection)
 {
     x            = y = z = 0.0f;
     connections  = new ConnectionAsset[0];
     enabled      = true;
     this.network = network;
 }
Exemple #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 ];
			}
		}
Exemple #8
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];
            }
        }
Exemple #9
0
		public WaypointAsset( WaypointAsset original, NetworkAsset network ) : base( network, original.Collection )
		{
			this.Name = original.Name;
			this.Position = original.Position;
			this.radius = original.Radius;
			this.disableRuntime = original.DisableRuntime;
			
			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 ];
			}
		}
Exemple #10
0
        public WaypointAsset(WaypointAsset original, NetworkAsset network) : base(network, original.Collection)
        {
            this.Name           = original.Name;
            this.Position       = original.Position;
            this.radius         = original.Radius;
            this.disableRuntime = original.DisableRuntime;

            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];
            }
        }
Exemple #11
0
        public NetworkAsset Add(NetworkAsset network)
        {
            NetworkAsset[] newNetworks;
            newNetworks = new NetworkAsset[networks.Length + 1];

            for (int i = 0; i < networks.Length; i++)
            {
                newNetworks[i] = networks[i];
            }

            newNetworks[networks.Length] = network;
            networks = newNetworks;

            return(network);
        }
Exemple #12
0
        public bool DoesUse(NetworkAsset network)
        {
            if (end.Network == network)
            {
                return(true);
            }

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

            return(false);
        }
Exemple #13
0
        public CellAsset(CellAsset original, NetworkAsset network) : base(network, original.Collection)
        {
            this.Name     = original.Name;
            this.Position = original.Position;

            this.triangles = new TriangleAsset[original.Triangles.Length];
            for (int i = 0; i < original.Triangles.Length; i++)
            {
                this.triangles[i] = new TriangleAsset(original.Triangles[i], this);
            }

            this.Tags = new int[original.Tags.Length];
            for (int i = 0; i < original.Tags.Length; i++)
            {
                this.Tags[i] = original.Tags[i];
            }
        }
Exemple #14
0
		//private Edge[] border;
		
		
		
		public CellAsset( string name, Vector3 position, TriangleAsset[] triangles, NetworkAsset network, CollectionAsset collection ) : base( network, collection )
		{
			this.Name = name;
			this.Position = position;
			
			foreach( TriangleAsset triangle in triangles )
			{
				triangle.Cell = this;
			}
			
			this.triangles = triangles;
			
			// TODO: Calculate border and position from triangles
			
			/*ArrayList edges, uses;
			Edge edge, existingEdge;
			
			edges = new ArrayList();
			uses = new ArrayList();
			
			foreach( TriangleAsset triangle in triangles )
			{
				for( int i = 0; i < 3; i++ )
				{
					edge = 	( i == 0 ) ? new Edge( triangle.Points[ 0 ], triangles.Points[ 1 ] ) :
							( i == 1 ) ? new Edge( triangle.Points[ 1 ], triangles.Points[ 2 ] ) :
							new Edge( triangle.Points[ 2 ], triangles.Points[ 0 ] );
							
					for( int j = 0; j < edges.Count; j++ )
					{
						existingEdge = edges[ j ];
						
						if( edge.Equals( existingEdge ) )
						{
							uses[ edges.IndexOf( existingEdge ) ]++;
						}
					}
				}
			}*/
		}
Exemple #15
0
        //private Edge[] border;



        public CellAsset(string name, Vector3 position, TriangleAsset[] triangles, NetworkAsset network, CollectionAsset collection) : base(network, collection)
        {
            this.Name     = name;
            this.Position = position;

            foreach (TriangleAsset triangle in triangles)
            {
                triangle.Cell = this;
            }

            this.triangles = triangles;

            // TODO: Calculate border and position from triangles

            /*ArrayList edges, uses;
             * Edge edge, existingEdge;
             *
             * edges = new ArrayList();
             * uses = new ArrayList();
             *
             * foreach( TriangleAsset triangle in triangles )
             * {
             *      for( int i = 0; i < 3; i++ )
             *      {
             *              edge =  ( i == 0 ) ? new Edge( triangle.Points[ 0 ], triangles.Points[ 1 ] ) :
             *                              ( i == 1 ) ? new Edge( triangle.Points[ 1 ], triangles.Points[ 2 ] ) :
             *                              new Edge( triangle.Points[ 2 ], triangles.Points[ 0 ] );
             *
             *              for( int j = 0; j < edges.Count; j++ )
             *              {
             *                      existingEdge = edges[ j ];
             *
             *                      if( edge.Equals( existingEdge ) )
             *                      {
             *                              uses[ edges.IndexOf( existingEdge ) ]++;
             *                      }
             *              }
             *      }
             * }*/
        }
Exemple #16
0
        public void RecalculateNetwork(NetworkAsset network)
        {
            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(network))
                {
                    cachedSeekers.Remove(cache);
                }
                else
                {
                    i++;
                }
            }

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

                if (seeker.DoesUse(network))
                {
                    usedSeekers.Remove(seeker);
                    seeker.Invalidate();
                }
                else
                {
                    i++;
                }
            }
        }
Exemple #17
0
		public NetworkAsset Add( NetworkAsset network )
		{
			NetworkAsset[] newNetworks;
			newNetworks = new NetworkAsset[ networks.Length + 1 ];
			
			for( int i = 0; i < networks.Length; i++ )
			{
				newNetworks[ i ] = networks[ i ];
			}
			
			newNetworks[ networks.Length ] = network;
			networks = newNetworks;
			
			return network;
		}
Exemple #18
0
		public bool Remove( NetworkAsset network )
		{
			NetworkAsset[] newNetworks;
			bool found;
			
			newNetworks = new NetworkAsset[ networks.Length - 1 ];
			found = false;
			
			for( int i = 0; i < newNetworks.Length; i++ )
			{
				if( networks[ i ] == network )
				{
					found = true;
				}

				newNetworks[ i ] = networks[ i + ( ( found ) ? 1 : 0 ) ];
			}
			
			found = ( networks[ newNetworks.Length ] == network ) ? true : found;
			
			if( !found )
			{
				return false;
			}
			
			networks = newNetworks;

			return true;
		}
Exemple #19
0
		public CellAsset( CellAsset original, NetworkAsset network ) : base( network, original.Collection )
		{
			this.Name = original.Name;
			this.Position = original.Position;
			
			this.triangles = new TriangleAsset[ original.Triangles.Length ];
			for( int i = 0; i < original.Triangles.Length; i++ )
			{
				this.triangles[ i ] = new TriangleAsset( original.Triangles[ i ], this );
			}
			
			this.Tags = new int[ original.Tags.Length ];
			for( int i = 0; i < original.Tags.Length; i++ )
			{
				this.Tags[ i ] = original.Tags[ i ];
			}
		}
Exemple #20
0
		public void RecalculateNetwork( NetworkAsset network )
		{
			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( network ) )
				{
					cachedSeekers.Remove( cache );
				}
				else
				{
					i++;
				}
			}
			
			for( int i = 0; i < usedSeekers.Count; )
			{
				seeker = ( Seeker )usedSeekers[ i ];
				
				if( seeker.DoesUse( network ) )
				{
					usedSeekers.Remove( seeker );
					seeker.Invalidate();
				}
				else
				{
					i++;
				}
			}
		}
Exemple #21
0
		public void OnDisabled( NetworkAsset network )
		{
			if( autoRecalculate )
			{
				RecalculateNetwork( network );
			}
		}
Exemple #22
0
        public bool DoesUse( NetworkAsset network )
        {
            if( end.Network == network )
            {
                return true;
            }

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

            return false;
        }
Exemple #23
0
 public bool Remove( NetworkAsset network )
 {
     bool found = false;
     int index = System.Array.IndexOf(networks, network);
     if (index != -1)
     {
         NetworkAsset[] newNetworks = new NetworkAsset[ networks.Length - 1 ];
         if (newNetworks.Length > 0)
         {
             System.Array.ConstrainedCopy(networks, 0, newNetworks, 0, index);
             int length = networks.Length-index-1;
             if (length > 0)
                 System.Array.ConstrainedCopy(networks, index+1, newNetworks, index, length);
         }
         networks = newNetworks;
         found = true;
     }
     return found;
 }