예제 #1
0
        public override string GetInspectString()
        {
            string text = "";

            if (!base.Cells.NullOrEmpty <IntVec3>())
            {
                IntVec3 c = base.Cells.First <IntVec3>();
                if (c.UsesOutdoorTemperature(base.Map))
                {
                    string text2 = text;
                    text = string.Concat(new string[]
                    {
                        text2,
                        "OutdoorGrowingPeriod".Translate(),
                        ": ",
                        Zone_Growing.GrowingQuadrumsDescription(base.Map.Tile),
                        "\n"
                    });
                }
                if (GenPlant.GrowthSeasonNow(c, base.Map, true))
                {
                    text += "GrowSeasonHereNow".Translate();
                }
                else
                {
                    text += "CannotGrowBadSeasonTemperature".Translate();
                }
            }
            return(text);
        }
        public override string GetInspectString()
        {
            string text = base.GetInspectString();

            if (base.Spawned)
            {
                text = ((!GenPlant.GrowthSeasonNow(base.Position, base.Map)) ? (text + "\n" + "CannotGrowBadSeasonTemperature".Translate()) : (text + "\n" + "GrowSeasonHereNow".Translate()));
            }
            return(text);
        }
예제 #3
0
        public override string GetInspectString()
        {
            string text = string.Empty;

            if (!base.Cells.NullOrEmpty())
            {
                IntVec3 c = base.Cells.First();
                if (c.UsesOutdoorTemperature(base.Map))
                {
                    string text2 = text;
                    text = text2 + "OutdoorGrowingPeriod".Translate() + ": " + Zone_Growing.GrowingQuadrumsDescription(base.Map.Tile) + "\n";
                }
                text = ((!GenPlant.GrowthSeasonNow(c, base.Map)) ? (text + "CannotGrowBadSeasonTemperature".Translate()) : (text + "GrowSeasonHereNow".Translate()));
            }
            return(text);
        }
        public override Job JobOnCell(Pawn pawn, IntVec3 c, bool forced = false)
        {
            Map map = pawn.Map;
            Job result;

            if (c.IsForbidden(pawn))
            {
                result = null;
            }
            else if (!GenPlant.GrowthSeasonNow(c, map, true))
            {
                result = null;
            }
            else
            {
                if (WorkGiver_Grower.wantedPlantDef == null)
                {
                    WorkGiver_Grower.wantedPlantDef = WorkGiver_Grower.CalculateWantedPlantDef(c, map);
                    if (WorkGiver_Grower.wantedPlantDef == null)
                    {
                        return(null);
                    }
                }
                List <Thing> thingList = c.GetThingList(map);
                bool         flag      = false;
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing = thingList[i];
                    if (thing.def == WorkGiver_Grower.wantedPlantDef)
                    {
                        return(null);
                    }
                    if ((thing is Blueprint || thing is Frame) && thing.Faction == pawn.Faction)
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    Thing edifice = c.GetEdifice(map);
                    if (edifice == null || edifice.def.fertility < 0f)
                    {
                        return(null);
                    }
                }
                if (WorkGiver_Grower.wantedPlantDef.plant.cavePlant)
                {
                    if (!c.Roofed(map))
                    {
                        JobFailReason.Is(WorkGiver_GrowerSow.CantSowCavePlantBecauseUnroofedTrans, null);
                        return(null);
                    }
                    if (map.glowGrid.GameGlowAt(c, true) > 0f)
                    {
                        JobFailReason.Is(WorkGiver_GrowerSow.CantSowCavePlantBecauseOfLightTrans, null);
                        return(null);
                    }
                }
                if (WorkGiver_Grower.wantedPlantDef.plant.interferesWithRoof && c.Roofed(pawn.Map))
                {
                    result = null;
                }
                else
                {
                    Plant plant = c.GetPlant(map);
                    if (plant != null)
                    {
                        if (plant.def.plant.blockAdjacentSow)
                        {
                            LocalTargetInfo target = plant;
                            if (!pawn.CanReserve(target, 1, -1, null, forced) || plant.IsForbidden(pawn))
                            {
                                return(null);
                            }
                            return(new Job(JobDefOf.CutPlant, plant));
                        }
                    }
                    Thing thing2 = GenPlant.AdjacentSowBlocker(WorkGiver_Grower.wantedPlantDef, c, map);
                    if (thing2 != null)
                    {
                        Plant plant2 = thing2 as Plant;
                        if (plant2 != null)
                        {
                            LocalTargetInfo target = plant2;
                            if (pawn.CanReserve(target, 1, -1, null, forced) && !plant2.IsForbidden(pawn))
                            {
                                IPlantToGrowSettable plantToGrowSettable = plant2.Position.GetPlantToGrowSettable(plant2.Map);
                                if (plantToGrowSettable == null || plantToGrowSettable.GetPlantDefToGrow() != plant2.def)
                                {
                                    return(new Job(JobDefOf.CutPlant, plant2));
                                }
                            }
                        }
                        result = null;
                    }
                    else
                    {
                        if (WorkGiver_Grower.wantedPlantDef.plant.sowMinSkill > 0)
                        {
                            if (pawn.skills != null && pawn.skills.GetSkill(SkillDefOf.Plants).Level < WorkGiver_Grower.wantedPlantDef.plant.sowMinSkill)
                            {
                                return(null);
                            }
                        }
                        int j = 0;
                        while (j < thingList.Count)
                        {
                            Thing thing3 = thingList[j];
                            if (thing3.def.BlockPlanting)
                            {
                                LocalTargetInfo target = thing3;
                                if (!pawn.CanReserve(target, 1, -1, null, forced))
                                {
                                    return(null);
                                }
                                if (thing3.def.category == ThingCategory.Plant)
                                {
                                    if (!thing3.IsForbidden(pawn))
                                    {
                                        return(new Job(JobDefOf.CutPlant, thing3));
                                    }
                                    return(null);
                                }
                                else
                                {
                                    if (thing3.def.EverHaulable)
                                    {
                                        return(HaulAIUtility.HaulAsideJobFor(pawn, thing3));
                                    }
                                    return(null);
                                }
                            }
                            else
                            {
                                j++;
                            }
                        }
                        if (WorkGiver_Grower.wantedPlantDef.CanEverPlantAt(c, map) && GenPlant.GrowthSeasonNow(c, map, true))
                        {
                            LocalTargetInfo target = c;
                            if (pawn.CanReserve(target, 1, -1, null, forced))
                            {
                                return(new Job(JobDefOf.Sow, c)
                                {
                                    plantDefToSow = WorkGiver_Grower.wantedPlantDef
                                });
                            }
                        }
                        result = null;
                    }
                }
            }
            return(result);
        }
예제 #5
0
 public override void TickLong()
 {
     this.CheckTemperatureMakeLeafless();
     if (!base.Destroyed)
     {
         if (GenPlant.GrowthSeasonNow(base.Position, base.Map, false))
         {
             float num  = this.growthInt;
             bool  flag = this.LifeStage == PlantLifeStage.Mature;
             this.growthInt += this.GrowthPerTick * 2000f;
             if (this.growthInt > 1f)
             {
                 this.growthInt = 1f;
             }
             if ((!flag && this.LifeStage == PlantLifeStage.Mature) || (int)(num * 10f) != (int)(this.growthInt * 10f))
             {
                 if (this.CurrentlyCultivated())
                 {
                     base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things);
                 }
             }
         }
         if (!this.HasEnoughLightToGrow)
         {
             this.unlitTicks += 2000;
         }
         else
         {
             this.unlitTicks = 0;
         }
         this.ageInt += 2000;
         if (this.Dying)
         {
             Map  map                        = base.Map;
             bool isCrop                     = this.IsCrop;
             bool harvestableNow             = this.HarvestableNow;
             bool dyingBecauseExposedToLight = this.DyingBecauseExposedToLight;
             int  num2                       = Mathf.CeilToInt(this.CurrentDyingDamagePerTick * 2000f);
             base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, (float)num2, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null));
             if (base.Destroyed)
             {
                 if (isCrop && this.def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + this.def.defName, 240f))
                 {
                     string key;
                     if (harvestableNow)
                     {
                         key = "MessagePlantDiedOfRot_LeftUnharvested";
                     }
                     else if (dyingBecauseExposedToLight)
                     {
                         key = "MessagePlantDiedOfRot_ExposedToLight";
                     }
                     else
                     {
                         key = "MessagePlantDiedOfRot";
                     }
                     Messages.Message(key.Translate(new object[]
                     {
                         this.GetCustomLabelNoCount(false)
                     }).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent, true);
                 }
                 return;
             }
         }
         this.cachedLabelMouseover = null;
         if (this.def.plant.dropLeaves)
         {
             MoteLeaf moteLeaf = MoteMaker.MakeStaticMote(Vector3.zero, base.Map, ThingDefOf.Mote_Leaf, 1f) as MoteLeaf;
             if (moteLeaf != null)
             {
                 float   num3       = this.def.plant.visualSizeRange.LerpThroughRange(this.growthInt);
                 float   treeHeight = this.def.graphicData.drawSize.x * num3;
                 Vector3 b          = Rand.InsideUnitCircleVec3 * Plant.LeafSpawnRadius;
                 moteLeaf.Initialize(base.Position.ToVector3Shifted() + Vector3.up * Rand.Range(Plant.LeafSpawnYMin, Plant.LeafSpawnYMax) + b + Vector3.forward * this.def.graphicData.shadowData.offset.z, Rand.Value * 2000.TicksToSeconds(), b.z > 0f, treeHeight);
             }
         }
     }
 }
예제 #6
0
        public override void TickLong()
        {
            this.CheckTemperatureMakeLeafless();
            if (!base.Destroyed)
            {
                if (GenPlant.GrowthSeasonNow(base.Position, base.Map))
                {
                    float num  = this.growthInt;
                    bool  flag = this.LifeStage == PlantLifeStage.Mature;
                    this.growthInt += (float)(this.GrowthPerTick * 2000.0);
                    if (this.growthInt > 1.0)
                    {
                        this.growthInt = 1f;
                    }
                    if (!flag && this.LifeStage == PlantLifeStage.Mature)
                    {
                        goto IL_0099;
                    }
                    if ((int)(num * 10.0) != (int)(this.growthInt * 10.0))
                    {
                        goto IL_0099;
                    }
                    goto IL_00bb;
                }
                goto IL_0103;
            }
            return;

IL_0103:
            if (!this.HasEnoughLightToGrow)
            {
                this.unlitTicks += 2000;
            }
            else
            {
                this.unlitTicks = 0;
            }
            this.ageInt += 2000;
            if (this.Dying)
            {
                Map  map                        = base.Map;
                bool isCrop                     = this.IsCrop;
                bool harvestableNow             = this.HarvestableNow;
                bool dyingBecauseExposedToLight = this.DyingBecauseExposedToLight;
                int  amount                     = Mathf.CeilToInt((float)(this.CurrentDyingDamagePerTick * 2000.0));
                base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, amount, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown));
                if (base.Destroyed)
                {
                    if (isCrop && base.def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + base.def.defName, 240f))
                    {
                        string key = (!harvestableNow) ? ((!dyingBecauseExposedToLight) ? "MessagePlantDiedOfRot" : "MessagePlantDiedOfRot_ExposedToLight") : "MessagePlantDiedOfRot_LeftUnharvested";
                        Messages.Message(key.Translate(this.Label).CapitalizeFirst(), new TargetInfo(base.Position, map, false), MessageTypeDefOf.NegativeEvent);
                    }
                    return;
                }
            }
            this.cachedLabelMouseover = null;
            return;

IL_00bb:
            if (this.CanReproduceNow && Rand.MTBEventOccurs(base.def.plant.reproduceMtbDays, 60000f, 2000f))
            {
                GenPlantReproduction.TryReproduceFrom(base.Position, base.def, SeedTargFindMode.Reproduce, base.Map);
            }
            goto IL_0103;
IL_0099:
            if (this.CurrentlyCultivated())
            {
                base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things);
            }
            goto IL_00bb;
        }
 private bool CanSpawnAt(IntVec3 c, Map map)
 {
     if (c.Standable(map) && !c.Fogged(map) && !(map.fertilityGrid.FertilityAt(c) < ThingDefOf.PlantAmbrosia.plant.fertilityMin) && c.GetRoom(map, RegionType.Set_Passable).PsychologicallyOutdoors&& c.GetEdifice(map) == null && GenPlant.GrowthSeasonNow(c, map))
     {
         Plant plant = c.GetPlant(map);
         if (plant != null && plant.def.plant.growDays > 10.0)
         {
             return(false);
         }
         List <Thing> thingList = c.GetThingList(map);
         for (int i = 0; i < thingList.Count; i++)
         {
             if (thingList[i].def == ThingDefOf.PlantAmbrosia)
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
예제 #8
0
        private bool CanSpawnAt(IntVec3 c, Map map)
        {
            bool result;

            if (!c.Standable(map) || c.Fogged(map) || map.fertilityGrid.FertilityAt(c) < ThingDefOf.Plant_Ambrosia.plant.fertilityMin || !c.GetRoom(map, RegionType.Set_Passable).PsychologicallyOutdoors || c.GetEdifice(map) != null || !GenPlant.GrowthSeasonNow(c, map, false))
            {
                result = false;
            }
            else
            {
                Plant plant = c.GetPlant(map);
                if (plant != null && plant.def.plant.growDays > 10f)
                {
                    result = false;
                }
                else
                {
                    List <Thing> thingList = c.GetThingList(map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        if (thingList[i].def == ThingDefOf.Plant_Ambrosia)
                        {
                            return(false);
                        }
                    }
                    result = true;
                }
            }
            return(result);
        }
예제 #9
0
        public override Job JobOnCell(Pawn pawn, IntVec3 c)
        {
            Map map = pawn.Map;

            if (c.IsForbidden(pawn))
            {
                return(null);
            }
            if (!GenPlant.GrowthSeasonNow(c, map))
            {
                return(null);
            }
            if (WorkGiver_Grower.wantedPlantDef == null)
            {
                WorkGiver_Grower.wantedPlantDef = WorkGiver_Grower.CalculateWantedPlantDef(c, map);
                if (WorkGiver_Grower.wantedPlantDef == null)
                {
                    return(null);
                }
            }
            List <Thing> thingList = c.GetThingList(map);
            bool         flag      = false;

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing = thingList[i];
                if (thing.def == WorkGiver_Grower.wantedPlantDef)
                {
                    return(null);
                }
                if ((thing is Blueprint || thing is Frame) && thing.Faction == pawn.Faction)
                {
                    flag = true;
                }
            }
            if (flag)
            {
                Thing edifice = c.GetEdifice(map);
                if (edifice != null && !(edifice.def.fertility < 0.0))
                {
                    goto IL_00dc;
                }
                return(null);
            }
            goto IL_00dc;
IL_00dc:
            if (WorkGiver_Grower.wantedPlantDef.plant.cavePlant)
            {
                if (!c.Roofed(map))
                {
                    JobFailReason.Is(WorkGiver_GrowerSow.CantSowCavePlantBecauseUnroofedTrans);
                    return(null);
                }
                if (map.glowGrid.GameGlowAt(c, true) > 0.0)
                {
                    JobFailReason.Is(WorkGiver_GrowerSow.CantSowCavePlantBecauseOfLightTrans);
                    return(null);
                }
            }
            Plant plant = c.GetPlant(map);

            if (plant != null && plant.def.plant.blockAdjacentSow)
            {
                if (pawn.CanReserve(plant, 1, -1, null, false) && !plant.IsForbidden(pawn))
                {
                    return(new Job(JobDefOf.CutPlant, plant));
                }
                return(null);
            }
            Thing thing2 = GenPlant.AdjacentSowBlocker(WorkGiver_Grower.wantedPlantDef, c, map);

            if (thing2 != null)
            {
                Plant plant2 = thing2 as Plant;
                if (plant2 != null && pawn.CanReserve(plant2, 1, -1, null, false) && !plant2.IsForbidden(pawn))
                {
                    IPlantToGrowSettable plantToGrowSettable = plant2.Position.GetPlantToGrowSettable(plant2.Map);
                    if (plantToGrowSettable != null && plantToGrowSettable.GetPlantDefToGrow() == plant2.def)
                    {
                        goto IL_0211;
                    }
                    return(new Job(JobDefOf.CutPlant, plant2));
                }
                goto IL_0211;
            }
            if (WorkGiver_Grower.wantedPlantDef.plant.sowMinSkill > 0 && pawn.skills != null && pawn.skills.GetSkill(SkillDefOf.Growing).Level < WorkGiver_Grower.wantedPlantDef.plant.sowMinSkill)
            {
                return(null);
            }
            for (int j = 0; j < thingList.Count; j++)
            {
                Thing thing3 = thingList[j];
                if (thing3.def.BlockPlanting)
                {
                    if (!pawn.CanReserve(thing3, 1, -1, null, false))
                    {
                        return(null);
                    }
                    if (thing3.def.category == ThingCategory.Plant)
                    {
                        if (!thing3.IsForbidden(pawn))
                        {
                            return(new Job(JobDefOf.CutPlant, thing3));
                        }
                        return(null);
                    }
                    if (thing3.def.EverHaulable)
                    {
                        return(HaulAIUtility.HaulAsideJobFor(pawn, thing3));
                    }
                    return(null);
                }
            }
            if (WorkGiver_Grower.wantedPlantDef.CanEverPlantAt(c, map) && GenPlant.GrowthSeasonNow(c, map) && pawn.CanReserve(c, 1, -1, null, false))
            {
                Job job = new Job(JobDefOf.Sow, c);
                job.plantDefToSow = WorkGiver_Grower.wantedPlantDef;
                return(job);
            }
            return(null);

IL_0211:
            return(null);
        }