Beispiel #1
0
            private static void Prefix(ref Building_Cage[] __state, Map ___map, ref IntVec3 start, ref LocalTargetInfo dest,
                                       TraverseParms traverseParms, PathEndMode peMode)
            {
                if (traverseParms.pawn is null)
                {
                    return;
                }
                var map = ___map;

                (var cage1, var cage2) = (start.CageHere(map), dest.Cell.CageHere(map));
                __state = new Building_Cage[] { cage1, cage2 };
                foreach (var cage in map.CagesOnMap())
                {
                    if (cage1 != cage && cage2 != cage)
                    {
                        cage.isBlocking = true;
                    }
                }
                if (cage1 != null && (peMode == PathEndMode.Touch || peMode == PathEndMode.ClosestTouch) &&
                    TouchPathEndModeUtility.IsAdjacentOrInsideAndAllowedToTouch(start, dest, traverseParms.pawn.Map))
                {
                    dest = dest.Cell.ClampInsideRect(cage1.OccupiedRect());
                    return;
                }
                if (cage1 == cage2)
                {
                    if (cage1 != null)
                    {
                        cage1.pathCost = 0;
                    }
                    return;
                }
                if (cage1 != null)
                {
                    var spot1 = cage1.InteractionCell;
                    var spot2 = cage1.EntranceCell;
                    dest           = start == spot2 ? spot1 : spot2;
                    cage1.pathCost = 0;
                }
                else
                {
                    var spot1 = cage2.InteractionCell;
                    dest           = start == spot1 ? cage2.EntranceCell : spot1;
                    cage2.pathCost = 8000;
                }
            }