public override void Initialize(Vector2 position) { navigator = Pathfinding2D.GetInstance().GetPathNavigatorToDestination( position, destination ); }
private void GrowPathNode(PathNode2D node) { Vector2 position = node.GetPlanarPosition(); float radius = node.GetRadius() + 0.01f; foreach (Vector2 direction in directions) { Vector2 edge_position = position + direction * radius; float new_radius = Pathfinding2D.GetInstance().GetPotentialFixedEdgeClearingRadius(edge_position, direction, true); Seed(edge_position + direction * new_radius, new_radius); } }
public bool Update(Vector2 position) { if (waypoint_index < waypoints.Count) { if (Pathfinding2D.GetInstance().IsPotentialConnection(position, GetNextTargetPosition())) { waypoint_index++; } return(true); } return(false); }
protected override void GenerateInternal(Rect r) { rect = r; directions = directions = Vector2s.RadialFromDegrees( Floats.Line(0.0f, 360.0f, max_number_branches, false) ).ToList(); active_nodes = new Queue <PathNode2D>(); Seed(origin, Pathfinding2D.GetInstance().GetPotentialClearingRadius(origin)); while (active_nodes.IsNotEmpty()) { GrowPathNode(active_nodes.Dequeue()); } }
public bool TryAlterDestination(Vector2 destination) { int final_index; Pathfinding2D pathfinding = Pathfinding2D.GetInstance(); if (waypoints.Offset(waypoint_index).TryApproximateEarliestEdge( p => pathfinding.IsConnection(p, destination), out final_index) ) { waypoints.RemoveEnding(waypoint_index + final_index + 1); waypoints.Add(destination); return(true); } return(false); }
private void GenerateQuadTree(Rect rect, int depth) { Vector2 position = rect.GetCenterPoint(); float maximum_radius = rect.GetSize().GetMaxComponent(); float acceptable_radius = maximum_radius * target_utilization; float radius = Pathfinding2D.GetInstance().GetPotentialClearingRadius(position).BindBelow(maximum_radius * 2.0f); if (radius < acceptable_radius && depth < max_depth) { rect.SplitIntoQuarters().Process(r => GenerateQuadTree(r, depth + 1)); } else { if (radius >= minimum_radius) { AddPathNode(position, radius); } } }
public IEnumerable <PathNode2D> CalculatePotentialConnections() { return(Pathfinding2D.GetInstance().GetPotentialConnections(this.GetPlanarPosition(), radius) .Skip(this)); }
public bool IsPotentialConnection(Vector2 position) { return(Pathfinding2D.GetInstance().IsPotentialConnection(this, position)); }
private void InitializePathNode() { this.SetLayer(Pathfinding2D.GetInstance().GetNodeLayer()); }