private static IntVec3 TryFindSnowmanBuildCell(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_BuildSnowman.IsGoodSnowmanCell(randomCell, pawn))
                    {
                        result = randomCell;
                        return(true);
                    }
                }
                return(false);
            }, 30, RegionType.Set_Passable);
            return(result);
        }
        public override Job TryGiveJob(Pawn pawn)
        {
            Job result;

            if (pawn.story.WorkTypeIsDisabled(WorkTypeDefOf.Construction))
            {
                result = null;
            }
            else if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                result = null;
            }
            else if (pawn.Map.snowGrid.TotalDepth < 200f)
            {
                result = null;
            }
            else
            {
                IntVec3 c = JoyGiver_BuildSnowman.TryFindSnowmanBuildCell(pawn);
                if (!c.IsValid)
                {
                    result = null;
                }
                else
                {
                    result = new Job(this.def.jobDef, c);
                }
            }
            return(result);
        }
Пример #3
0
 internal bool <> m__1(Region r)
 {
     for (int i = 0; i < 5; i++)
     {
         IntVec3 randomCell = r.RandomCell;
         if (JoyGiver_BuildSnowman.IsGoodSnowmanCell(randomCell, this.pawn))
         {
             this.result = randomCell;
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
        public override Job TryGiveJob(Pawn pawn)
        {
            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }
            if (pawn.Map.snowGrid.TotalDepth < 200f)
            {
                return(null);
            }
            IntVec3 c = JoyGiver_BuildSnowman.TryFindSnowmanBuildCell(pawn);

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