public void OnDisabled(NetworkNodeAsset node) { if (autoRecalculate) { RecalculateNode(node); } }
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; }
public CachedSeeker(Seeker seeker) { this.start = seeker.Start; this.end = seeker.End; this.solution = new ArrayList(seeker.Solution); Restart(seeker.CacheLifespan); }
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; }
public CachedSeeker( Seeker seeker ) { this.start = seeker.Start; this.end = seeker.End; this.solution = new ArrayList( seeker.Solution ); Restart( seeker.CacheLifespan ); }
public bool ConnectTo(NetworkNodeAsset destination, float width) { if (ConnectsTo(destination)) { return(false); } AddConnection(new ConnectionAsset(this, destination, width, Collection)); return(true); }
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 ]; } }
public ConnectionAsset GetConnection(NetworkNodeAsset destination) { foreach (ConnectionAsset connection in connections) { if (connection.To == destination) { return(connection); } } return(null); }
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]; } }
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); }
public ArrayList GetConnections(NetworkNodeAsset destination) { ArrayList result; result = new ArrayList(); foreach (ConnectionAsset connection in connections) { if (connection.To == destination) { result.Add(connection); } } return(result); }
public bool DoesUse(NetworkNodeAsset node) { if (end == node) { return(true); } foreach (ConnectionAsset connection in Solution) { if (connection.From == node) { return(true); } } return(false); }
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); }
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 ); }
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); }
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; } } } }
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++; } } }
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; } } } }
public bool DoesUse( NetworkNodeAsset node ) { if( end == node ) { return true; } foreach( ConnectionAsset connection in Solution ) { if( connection.From == node ) { return true; } } return false; }
public Vector3 WorldPosition( NetworkNodeAsset node ) { return node.Position + node.Network.Position + Owner.transform.position; }
public ConnectionAsset GetConnection( NetworkNodeAsset destination ) { foreach( ConnectionAsset connection in connections ) { if( connection.To == destination ) { return connection; } } return null; }
public bool ConnectTo( NetworkNodeAsset destination, float width ) { if( ConnectsTo( destination ) ) { return false; } AddConnection( new ConnectionAsset( this, destination, width, Collection ) ); return true; }
public bool ConnectsTo( NetworkNodeAsset destination ) { return GetConnection( destination ) != null; }
public ArrayList GetConnections( NetworkNodeAsset destination ) { ArrayList result; result = new ArrayList(); foreach( ConnectionAsset connection in connections ) { if( connection.To == destination ) { result.Add( connection ); } } return result; }
public bool ConnectsTo(NetworkNodeAsset destination) { return(GetConnection(destination) != null); }
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++; } } }
public void OnDisabled( NetworkNodeAsset node ) { if( autoRecalculate ) { RecalculateNode( node ); } }
public Vector3 WorldPosition(NetworkNodeAsset node) { return(node.Position + node.Network.Position + Owner.transform.position); }
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; }
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 ); }