public PathRequest CreatePathRequest(IPathFindableCell source, IPathFindableCell target, Mobility mobility) { var request = new PathRequest(source, target, mobility); _pathQueue.Enqueue(request); return(request); }
public int DistanceTo(IPathFindableCell other) { // to handle cases where a diagonal does not count as adjecent if (Neighbors.Contains(other)) { return(1); } return((X < other.X ? other.X - X : X - other.X) + (Z < other.Z ? other.Z - Z : Z - other.Z)); }
public void Enqueue(IPathFindableCell cell) { Count++; var priority = cell.SearchPriority; if (priority < minimum) { minimum = priority; } while (priority >= list.Count) { list.Add(null); } cell.NextWithSamePriority = list[priority]; list[priority] = cell; }
public void Change(IPathFindableCell cell, int oldPriority) { var current = list[oldPriority]; var next = current.NextWithSamePriority; if (current == cell) { list[oldPriority] = next; } else { while (next != cell) { current = next; next = current.NextWithSamePriority; } current.NextWithSamePriority = cell.NextWithSamePriority; } Enqueue(cell); Count--; }
public PathRequest(IPathFindableCell from, IPathFindableCell to, Mobility mobility) { From = from; To = to; Mobility = mobility; }
public PathRequest(IPathFindableCell from, IPathFindableCell to) { From = from; To = to; }