Example #1
0
        private static bool TryFindDirectFleeDestination(IntVec3 root, float dist, Rot4 dirExcluded, Pawn pawn, out IntVec3 result)
        {
            for (int i = 0; i < 30; i++)
            {
                result = root + IntVec3.FromVector3(Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) * dist);
                if (result.Walkable(pawn.Map) && result.DistanceToSquared(pawn.Position) < result.DistanceToSquared(root) && GenSight.LineOfSight(root, result, pawn.Map, true, null, 0, 0))
                {
                    return(true);
                }
            }
            Region region = RegionAndRoomQuery.GetRegion(pawn, RegionType.Set_Passable);

            for (int j = 0; j < 30; j++)
            {
                IntVec3 randomCell = CellFinder.RandomRegionNear(region, 15, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), null, null, RegionType.Set_Passable).RandomCell;
                if (randomCell.Walkable(pawn.Map) && (float)(root - randomCell).LengthHorizontalSquared > dist * dist)
                {
                    using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, randomCell, pawn, PathEndMode.OnCell))
                    {
                        if (PawnPathUtility.TryFindCellAtIndex(pawnPath, (int)dist + 3, out result))
                        {
                            return(true);
                        }
                    }
                }
            }
            result = pawn.Position;
            return(false);
        }
Example #2
0
        public static Room FindNearbyPrivateRoom(Pawn pawn)
        {
            Region currentRegion = RegionAndRoomQuery.GetRegion(pawn);
            Room   currentRoom   = RegionAndRoomQuery.GetRoom(pawn);

            return(null);
        }