Beispiel #1
0
        // Used to retrieve paths that have been calculated
        public static List<PathfindingResult> GetFinishedPathsWithData(Living d)
        {
            _pathFinishedMutex.WaitOne();
            if (_finishedPaths.ContainsKey(d.Id) && _finishedPaths[d.Id].Count > 0)
            {
                List<PathfindingResult> finished = new List<PathfindingResult>();

                foreach (PathfindingResult p in _finishedPaths[d.Id])
                {
                    finished.Add(p);
                }
                _finishedPaths[d.Id].Clear();
                _pathFinishedMutex.ReleaseMutex();
                return finished;
            }
            _pathFinishedMutex.ReleaseMutex();
            return new List<PathfindingResult>();
        }
Beispiel #2
0
 public static void RequestPathfinding(Living d, Point start, Point goal, Object data)
 {
     _pathfindingRequestMutex.WaitOne();
     if (_requestedPathfinding.ContainsKey(d.Id) == false)
     {
         _requestedPathfinding.Add(d.Id, new List<PathfindingRequest>());
         _finishedPaths.Add(d.Id, new List<PathfindingResult>());
     }
     _requestedPathfinding[d.Id].Add(new PathfindingRequest() { Dwarf = d, Start = start, Goal = goal, Data = data });
     _pathfindingRequestMutex.ReleaseMutex();
 }