예제 #1
0
 internal bool <> m__1(Region r)
 {
     HaulAIUtility.candidates.Clear();
     HaulAIUtility.candidates.AddRange(r.Cells);
     HaulAIUtility.candidates.Sort((IntVec3 a, IntVec3 b) => a.DistanceToSquared(this.center).CompareTo(b.DistanceToSquared(this.center)));
     for (int i = 0; i < HaulAIUtility.candidates.Count; i++)
     {
         IntVec3 c = HaulAIUtility.candidates[i];
         if (HaulAIUtility.HaulablePlaceValidator(this.haulable, this.worker, c))
         {
             this.foundCell = c;
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
        private static bool TryFindSpotToPlaceHaulableCloseTo(Thing haulable, Pawn worker, IntVec3 center, out IntVec3 spot)
        {
            Region region = center.GetRegion(worker.Map, RegionType.Set_Passable);
            bool   result;

            if (region == null)
            {
                spot   = center;
                result = false;
            }
            else
            {
                TraverseParms traverseParms = TraverseParms.For(worker, Danger.Deadly, TraverseMode.ByPawn, false);
                IntVec3       foundCell     = IntVec3.Invalid;
                RegionTraverser.BreadthFirstTraverse(region, (Region from, Region r) => r.Allows(traverseParms, false), delegate(Region r)
                {
                    HaulAIUtility.candidates.Clear();
                    HaulAIUtility.candidates.AddRange(r.Cells);
                    HaulAIUtility.candidates.Sort((IntVec3 a, IntVec3 b) => a.DistanceToSquared(center).CompareTo(b.DistanceToSquared(center)));
                    for (int i = 0; i < HaulAIUtility.candidates.Count; i++)
                    {
                        IntVec3 intVec = HaulAIUtility.candidates[i];
                        if (HaulAIUtility.HaulablePlaceValidator(haulable, worker, intVec))
                        {
                            foundCell = intVec;
                            return(true);
                        }
                    }
                    return(false);
                }, 100, RegionType.Set_Passable);
                if (foundCell.IsValid)
                {
                    spot   = foundCell;
                    result = true;
                }
                else
                {
                    spot   = center;
                    result = false;
                }
            }
            return(result);
        }