public PathData(PathData pathData, ConnectionAsset connection, float gScore, float hScore) { this.path = new ArrayList(pathData.Path); this.path.Add(connection); this.gScore = pathData.GScore + gScore; this.hScore = pathData.HScore + hScore; }
public PathData(ConnectionAsset connection, float gScore, float hScore) { this.path = new ArrayList(); this.path.Add(connection); this.gScore = gScore; this.hScore = hScore; }
public void OnDisabled(ConnectionAsset connection) { if (autoRecalculate) { RecalculateConnection(connection); } }
public bool RemoveConnection(ConnectionAsset connection) { bool found; ConnectionAsset[] newConnections; found = false; newConnections = new ConnectionAsset[connections.Length - 1]; for (int i = 0; i < newConnections.Length; i++) { if (connections[i] == connection) { found = true; } newConnections[i] = connections[i + ((found) ? 1 : 0)]; } found = (connections[newConnections.Length] == connection) ? true : found; if (!found) { return(false); } connections = newConnections; return(true); }
public bool DoesUse(ConnectionAsset connection) { foreach (ConnectionAsset connectionAsset in Solution) { if (connectionAsset == connection) { return(true); } } return(false); }
public bool ValidConnection(ConnectionAsset connection) { if (!connection.Enabled || // Connection is disabled? !connection.To.Enabled || // Target is disabled? connection.Width < radius * 2.0f || // Seeker doesn't fit? !Valid(connection) || // Tags of connection don't fit our seeker? !Valid(connection.To) // Tags of target don't fit our seeker? ) { return(false); } return(true); }
public void AddConnection(ConnectionAsset connection) { ConnectionAsset[] newConnections; if (ConnectsTo(connection.To as NetworkNodeAsset)) { return; } newConnections = new ConnectionAsset[connections.Length + 1]; for (int i = 0; i < connections.Length; i++) { newConnections[i] = connections[i]; } newConnections[connections.Length] = connection; connections = newConnections; }
public void RecalculateConnection(ConnectionAsset connection) { 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(connection)) { cachedSeekers.Remove(cache); } else { i++; } } for (int i = 0; i < usedSeekers.Count;) { seeker = ( Seeker )usedSeekers[i]; if (seeker.DoesUse(connection)) { usedSeekers.Remove(seeker); seeker.Invalidate(); } else { i++; } } }
public void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection, bool onlySelectedConnection) { if (!onlySelectedConnection) { Gizmos.color = (!networkSelected) ? Color.yellow : (nodeSelected) ? Color.white : Color.green; Gizmos.DrawWireSphere(Position + transform.position + offset, radius); } foreach (ConnectionAsset connection in Connections) { Vector3 from, to, vector, fromOffsetA, fromOffsetB, toOffsetA, toOffsetB; if (onlySelectedConnection && selectedConnection != connection) { continue; } from = Position + transform.position + offset; to = connection.To.Position + transform.position + offset; vector = to - from; fromOffsetA = from + vector.normalized * (connection.From as WaypointAsset).Radius + Vector3.Cross(vector, Vector3.up).normalized * -(connection.Width / 2.0f); fromOffsetB = from + vector.normalized * (connection.From as WaypointAsset).Radius + Vector3.Cross(vector, Vector3.up).normalized *(connection.Width / 2.0f); toOffsetA = to - vector.normalized * (connection.To as WaypointAsset).Radius + Vector3.Cross(vector, Vector3.up).normalized * -(connection.Width / 2.0f); toOffsetB = to - vector.normalized * (connection.To as WaypointAsset).Radius + Vector3.Cross(vector, Vector3.up).normalized *(connection.Width / 2.0f); Gizmos.color = (!networkSelected) ? Color.yellow : (selectedConnection == connection) ? Color.white : Color.green; Gizmos.DrawLine(fromOffsetA, toOffsetA); Gizmos.DrawLine(fromOffsetB, toOffsetB); } }
public void AddConnection( ConnectionAsset connection ) { ConnectionAsset[] newConnections; if( ConnectsTo( connection.To as NetworkNodeAsset ) ) { return; } newConnections = new ConnectionAsset[ connections.Length + 1 ]; for( int i = 0; i < connections.Length; i++ ) { newConnections[ i ] = connections[ i ]; } newConnections[ connections.Length ] = connection; connections = newConnections; }
public virtual void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection) { Gizmos.color = (!networkSelected) ? Color.yellow : (nodeSelected) ? Color.white : Color.green; Gizmos.DrawWireSphere(Position + transform.position + offset, standardMarkerSize); foreach (ConnectionAsset connection in Connections) { Vector3 from, to, vector; from = Position + transform.position + offset; to = connection.To.Position + transform.position + offset; vector = to - from; Gizmos.color = (!networkSelected) ? Color.yellow : (selectedConnection == connection) ? Color.white : Color.green; Gizmos.DrawLine(from + vector.normalized /* * waypoint.Radius*/, to - vector.normalized /* * ( connection.To as WaypointAsset ).Radius */); Gizmos.DrawLine(to - vector.normalized /* * ( connection.To as WaypointAsset ).Radius*/, to - vector.normalized * (/*( connection.To as WaypointAsset ).Radius*/ 1.0f + connection.Width / 2.0f) + Vector3.Lerp((Vector3.Cross(vector, Vector3.up).normalized), vector.normalized, 0.5f) * connection.Width / 2.0f); Gizmos.DrawLine(to - vector.normalized /* * ( connection.To as WaypointAsset ).Radius*/, to - vector.normalized * (/*( connection.To as WaypointAsset ).Radius*/ 1.0f + connection.Width / 2.0f) + Vector3.Lerp((Vector3.Cross(vector, Vector3.up).normalized * -1.0f), vector.normalized, 0.5f) * connection.Width / 2.0f); } }
public PathData( PathData pathData, ConnectionAsset connection, float gScore, float hScore ) { this.path = new ArrayList( pathData.Path ); this.path.Add( connection ); this.gScore = pathData.GScore + gScore; this.hScore = pathData.HScore + hScore; }
public bool RemoveConnection( ConnectionAsset connection ) { bool found; ConnectionAsset[] newConnections; found = false; newConnections = new ConnectionAsset[ connections.Length - 1 ]; for( int i = 0; i < newConnections.Length; i++ ) { if( connections[ i ] == connection ) { found = true; } newConnections[ i ] = connections[ i + ( ( found ) ? 1 : 0 ) ]; } found = ( connections[ newConnections.Length ] == connection ) ? true : found; if( !found ) { return false; } connections = newConnections; return true; }
private float GScore(ConnectionAsset connection) { return(connection.Cost); }
public PathData( ConnectionAsset connection, float gScore, float hScore ) { this.path = new ArrayList(); this.path.Add( connection ); this.gScore = gScore; this.hScore = hScore; }
public virtual void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection ) { Gizmos.color = ( !networkSelected ) ? Color.yellow : ( nodeSelected ) ? Color.white : Color.green; Gizmos.DrawWireSphere( Position + transform.position + offset, standardMarkerSize ); foreach( ConnectionAsset connection in Connections ) { Vector3 from, to, vector; from = Position + transform.position + offset; to = connection.To.Position + transform.position + offset; vector = to - from; Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green; Gizmos.DrawLine( from + vector.normalized/* * waypoint.Radius*/, to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius */); Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius*/, to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius*/1.0f + connection.Width / 2.0f ) + Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized ), vector.normalized, 0.5f ) * connection.Width / 2.0f ); Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius*/, to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius*/1.0f + connection.Width / 2.0f ) + Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized * -1.0f ), vector.normalized, 0.5f ) * connection.Width / 2.0f ); } }
private float GScore( ConnectionAsset connection ) { return connection.Cost; }
public void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection, bool onlySelectedConnection ) { if( target == null ) { return; } if( networkSelected ) { if( target is WaypointAsset ) { ( ( WaypointAsset )target ).OnRenderGizmos( transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection, true ); } else { target.OnRenderGizmos( transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection ); } } Gizmos.color = Color.red; Gizmos.DrawWireSphere( transform.position + offset + Position, standardMarkerSize ); foreach( ConnectionAsset connection in Connections ) { Vector3 from, to, vector, fromOffsetA, fromOffsetB, toOffsetA, toOffsetB; if( onlySelectedConnection && selectedConnection != connection ) { continue; } from = Position + transform.position + Target.Network.Position; to = connection.To.Position + transform.position + ( ( GridNodeAsset )connection.To ).Target.Network.Position; vector = to - from; fromOffsetA = from + vector.normalized + Vector3.Cross( vector, Vector3.up ).normalized * -( connection.Width / 2.0f ); fromOffsetB = from + vector.normalized + Vector3.Cross( vector, Vector3.up ).normalized * ( connection.Width / 2.0f ); toOffsetA = to - vector.normalized + Vector3.Cross( vector, Vector3.up ).normalized * -( connection.Width / 2.0f ); toOffsetB = to - vector.normalized + Vector3.Cross( vector, Vector3.up ).normalized * ( connection.Width / 2.0f ); Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green; Gizmos.DrawLine( fromOffsetA, toOffsetA ); Gizmos.DrawLine( fromOffsetB, toOffsetB ); } }
public void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection, bool onlySelectedConnection) { if (target == null) { return; } if (networkSelected) { if (target is WaypointAsset) { (( WaypointAsset )target).OnRenderGizmos(transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection, true); } else { target.OnRenderGizmos(transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection); } } Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position + offset + Position, standardMarkerSize); foreach (ConnectionAsset connection in Connections) { Vector3 from, to, vector, fromOffsetA, fromOffsetB, toOffsetA, toOffsetB; if (onlySelectedConnection && selectedConnection != connection) { continue; } from = Position + transform.position + Target.Network.Position; to = connection.To.Position + transform.position + (( GridNodeAsset )connection.To).Target.Network.Position; vector = to - from; fromOffsetA = from + vector.normalized + Vector3.Cross(vector, Vector3.up).normalized * -(connection.Width / 2.0f); fromOffsetB = from + vector.normalized + Vector3.Cross(vector, Vector3.up).normalized *(connection.Width / 2.0f); toOffsetA = to - vector.normalized + Vector3.Cross(vector, Vector3.up).normalized * -(connection.Width / 2.0f); toOffsetB = to - vector.normalized + Vector3.Cross(vector, Vector3.up).normalized *(connection.Width / 2.0f); Gizmos.color = (!networkSelected) ? Color.yellow : (selectedConnection == connection) ? Color.white : Color.green; Gizmos.DrawLine(fromOffsetA, toOffsetA); Gizmos.DrawLine(fromOffsetB, toOffsetB); } }
public override void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection ) { Gizmos.color = ( !networkSelected ) ? Color.yellow : ( nodeSelected ) ? Color.white : Color.green; Gizmos.DrawWireSphere( Position + transform.position + offset, standardMarkerSize ); foreach( TriangleAsset triangle in triangles ) { Gizmos.DrawLine( triangle.Points[ 0 ] + transform.position + offset, triangle.Points[ 1 ] + transform.position + offset ); Gizmos.DrawLine( triangle.Points[ 1 ] + transform.position + offset, triangle.Points[ 2 ] + transform.position + offset ); Gizmos.DrawLine( triangle.Points[ 2 ] + transform.position + offset, triangle.Points[ 0 ] + transform.position + offset ); } // TODO: Draw polygon border // [17:47] <AngryAnt> Ah right. I'm just thinking in vertices because thats the info I have available. So in that context it becomes: If only one triangle contains both vertices of an edge then the edge is on the border of the polygon? /*foreach( ConnectionAsset connection in Connections ) { Vector3 from, to, vector; from = Position + transform.position + offset; to = connection.To.Position + transform.position + offset; vector = to - from; Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green; Gizmos.DrawLine( from + vector.normalized/* * waypoint.Radius* /, to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius * /); Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius* /, to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius* /1.0f + /*connection.Width* /1.0f / 2.0f ) + Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized ), vector.normalized, 0.5f ) * /*connection.Width* /1.0f / 2.0f ); Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius* /, to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius* /1.0f + /*connection.Width* /1.0f / 2.0f ) + Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized * -1.0f ), vector.normalized, 0.5f ) * /*connection.Width* /1.0f / 2.0f ); }*/ }
public void RecalculateConnection( ConnectionAsset connection ) { 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( connection ) ) { cachedSeekers.Remove( cache ); } else { i++; } } for( int i = 0; i < usedSeekers.Count; ) { seeker = ( Seeker )usedSeekers[ i ]; if( seeker.DoesUse( connection ) ) { usedSeekers.Remove( seeker ); seeker.Invalidate(); } else { i++; } } }
private float HScore(ConnectionAsset connection) { return(Vector3.Distance(connection.To.Position, End.Position)); }
public void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection, bool onlySelectedConnection ) { if( !onlySelectedConnection ) { Gizmos.color = ( !networkSelected ) ? Color.yellow : ( nodeSelected ) ? Color.white : Color.green; Gizmos.DrawWireSphere( Position + transform.position + offset, radius ); } foreach( ConnectionAsset connection in Connections ) { Vector3 from, to, vector, fromOffsetA, fromOffsetB, toOffsetA, toOffsetB; if( onlySelectedConnection && selectedConnection != connection ) { continue; } from = Position + transform.position + offset; to = connection.To.Position + transform.position + offset; vector = to - from; fromOffsetA = from + vector.normalized * ( connection.From as WaypointAsset ).Radius + Vector3.Cross( vector, Vector3.up ).normalized * -( connection.Width / 2.0f ); fromOffsetB = from + vector.normalized * ( connection.From as WaypointAsset ).Radius + Vector3.Cross( vector, Vector3.up ).normalized * ( connection.Width / 2.0f ); toOffsetA = to - vector.normalized * ( connection.To as WaypointAsset ).Radius + Vector3.Cross( vector, Vector3.up ).normalized * -( connection.Width / 2.0f ); toOffsetB = to - vector.normalized * ( connection.To as WaypointAsset ).Radius + Vector3.Cross( vector, Vector3.up ).normalized * ( connection.Width / 2.0f ); Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green; Gizmos.DrawLine( fromOffsetA, toOffsetA ); Gizmos.DrawLine( fromOffsetB, toOffsetB ); } }
private float HScore( ConnectionAsset connection ) { return Vector3.Distance( connection.To.Position, End.Position ); }
public override void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection ) { OnRenderGizmos( transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection, false ); }
public void OnDisabled( ConnectionAsset connection ) { if( autoRecalculate ) { RecalculateConnection( connection ); } }
public override void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection) { OnRenderGizmos(transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection, false); }
public bool DoesUse( ConnectionAsset connection ) { foreach( ConnectionAsset connectionAsset in Solution ) { if( connectionAsset == connection ) { return true; } } return false; }
public override void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection) { Gizmos.color = (!networkSelected) ? Color.yellow : (nodeSelected) ? Color.white : Color.green; Gizmos.DrawWireSphere(Position + transform.position + offset, standardMarkerSize); foreach (TriangleAsset triangle in triangles) { Gizmos.DrawLine(triangle.Points[0] + transform.position + offset, triangle.Points[1] + transform.position + offset); Gizmos.DrawLine(triangle.Points[1] + transform.position + offset, triangle.Points[2] + transform.position + offset); Gizmos.DrawLine(triangle.Points[2] + transform.position + offset, triangle.Points[0] + transform.position + offset); } // TODO: Draw polygon border // [17:47] <AngryAnt> Ah right. I'm just thinking in vertices because thats the info I have available. So in that context it becomes: If only one triangle contains both vertices of an edge then the edge is on the border of the polygon? /*foreach( ConnectionAsset connection in Connections ) * { * Vector3 from, to, vector; * * from = Position + transform.position + offset; * to = connection.To.Position + transform.position + offset; * vector = to - from; * * Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green; * * Gizmos.DrawLine( from + vector.normalized/* * waypoint.Radius* /, * to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius * /); * * Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius* /, * to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius* /1.0f + /*connection.Width* /1.0f / 2.0f ) + * Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized ), * vector.normalized, 0.5f ) * /*connection.Width* /1.0f / 2.0f ); * * Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius* /, * to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius* /1.0f + /*connection.Width* /1.0f / 2.0f ) + * Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized * -1.0f ), * vector.normalized, 0.5f ) * /*connection.Width* /1.0f / 2.0f ); * }*/ }
public bool ValidConnection( ConnectionAsset connection ) { if( !connection.Enabled || // Connection is disabled? !connection.To.Enabled || // Target is disabled? connection.Width < radius * 2.0f || // Seeker doesn't fit? !Valid( connection ) || // Tags of connection don't fit our seeker? !Valid( connection.To ) // Tags of target don't fit our seeker? ) { return false; } return true; }