示例#1
0
    public PathRequest CreatePathRequest(IPathFindableCell source, IPathFindableCell target, Mobility mobility)
    {
        var request = new PathRequest(source, target, mobility);

        _pathQueue.Enqueue(request);
        return(request);
    }
示例#2
0
        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));
        }
示例#3
0
        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;
        }
示例#4
0
        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--;
        }
示例#5
0
 public PathRequest(IPathFindableCell from, IPathFindableCell to, Mobility mobility)
 {
     From     = from;
     To       = to;
     Mobility = mobility;
 }
示例#6
0
 public PathRequest(IPathFindableCell from, IPathFindableCell to)
 {
     From = from;
     To   = to;
 }