Beispiel #1
0
        private static IntVec3 TryFindTreasureCell(Pawn pawn)
        {
            Region rootReg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable),
                                                     TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false),
                                                     (Region r) => r.Room.PsychologicallyOutdoors, 100, out rootReg, RegionType.Set_Passable))
            {
                return(IntVec3.Invalid);
            }
            IntVec3 result = IntVec3.Invalid;

            RegionTraverser.BreadthFirstTraverse(rootReg, (Region from, Region r) => r.Room
                                                 == rootReg.Room, delegate(Region r)
            {
                for (int i = 0; i < 5; i++)
                {
                    IntVec3 randomCell = r.RandomCell;
                    if (JoyGiver_FindTreasure.IsGoodForSwimmingCell(randomCell, pawn))
                    {
                        result = randomCell;
                        return(true);
                    }
                }
                return(false);
            }, 30, RegionType.Set_Passable);
            return(result);
        }
Beispiel #2
0
        public override Job TryGiveJob(Pawn pawn)
        {
            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }

            IntVec3 c = JoyGiver_FindTreasure.TryFindTreasureCell(pawn);

            if (!c.IsValid)
            {
                return(null);
            }
            return(new Job(this.def.jobDef, c));
        }