Esempio n. 1
0
        private static void GrowToMaturity()
        {
            IntVec3 intVec = UI.MouseCell();
            Plant   plant  = intVec.GetPlant(Find.CurrentMap);

            if (plant != null && plant.def.plant != null)
            {
                int num = (int)((1f - plant.Growth) * plant.def.plant.growDays);
                plant.Age   += num;
                plant.Growth = 1f;
                Find.CurrentMap.mapDrawer.SectionAt(intVec).RegenerateAllLayers();
            }
        }
        // Token: 0x06000011 RID: 17 RVA: 0x00002F24 File Offset: 0x00001124
        protected override Job TryGiveJob(Pawn pawn)
        {
            Region region = pawn.GetRegion(RegionType.Set_Passable);
            bool   flag   = region == null;
            Job    result;

            if (flag)
            {
                result = null;
            }
            else
            {
                for (int i = 0; i < 500; i++)
                {
                    IntVec3 randomCell = region.RandomCell;
                    for (int j = 0; j < 4; j++)
                    {
                        IntVec3 c     = randomCell + GenAdj.CardinalDirections[j];
                        Plant   plant = c.GetPlant(pawn.Map);
                        bool    flag2 = plant != null && plant.def.plant.Harvestable && plant.LifeStage == PlantLifeStage.Mature && pawn.CanReserve(plant, 1, -1, null, false) && plant.IsCrop;
                        if (flag2)
                        {
                            return(new Job(JobDefOf.Harvest, plant));
                        }
                        foreach (Designation designation in pawn.Map.designationManager.AllDesignationsOn(plant))
                        {
                            bool flag3 = designation.def == DesignationDefOf.HarvestPlant && pawn.CanReserve(plant, 1, -1, null, false);
                            if (flag3)
                            {
                                return(new Job(JobDefOf.Harvest, plant));
                            }
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
Esempio n. 3
0
        // Token: 0x06000009 RID: 9 RVA: 0x00002ACC File Offset: 0x00000CCC
        protected override Job TryGiveJob(Pawn pawn)
        {
            Region region = pawn.GetRegion(RegionType.Set_Passable);
            bool   flag   = region == null;
            Job    result;

            if (flag)
            {
                result = null;
            }
            else
            {
                for (int i = 0; i < 500; i++)
                {
                    IntVec3 randomCell = region.RandomCell;
                    for (int j = 0; j < 4; j++)
                    {
                        IntVec3 c     = randomCell + GenAdj.CardinalDirections[j];
                        Plant   plant = c.GetPlant(pawn.Map);
                        using (IEnumerator <Designation> enumerator = pawn.Map.designationManager.AllDesignationsOn(plant).GetEnumerator())
                        {
                            if (enumerator.MoveNext())
                            {
                                Designation designation = enumerator.Current;
                                bool        flag2       = designation.def == DesignationDefOf.CutPlant && pawn.CanReserve(plant, 1, -1, null, false);
                                if (flag2)
                                {
                                    return(new Job(JobDefOf.CutPlant, plant));
                                }
                                return(null);
                            }
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
Esempio n. 4
0
        private static void Grow1Day()
        {
            IntVec3 intVec = UI.MouseCell();
            Plant   plant  = intVec.GetPlant(Find.CurrentMap);

            if (plant != null && plant.def.plant != null)
            {
                int num = (int)((1f - plant.Growth) * plant.def.plant.growDays);
                if (num >= 60000)
                {
                    plant.Age += 60000;
                }
                else if (num > 0)
                {
                    plant.Age += num;
                }
                plant.Growth += 1f / plant.def.plant.growDays;
                if ((double)plant.Growth > 1.0)
                {
                    plant.Growth = 1f;
                }
                Find.CurrentMap.mapDrawer.SectionAt(intVec).RegenerateAllLayers();
            }
        }