Ejemplo n.º 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>();
        }
Ejemplo n.º 2
0
 public void AddCreature(Living l)
 {
     _creatures.Add(l);
     if (l.GetType().IsSubclassOf(typeof(Minion)))
     {
         _minions.Add((Minion)l);
     }
     if (l.Type == LivingType.Dwarf)
     {
         SimulationWorld.Instance.OnNewDwarfAdded();
     }
 }
Ejemplo n.º 3
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();
 }