public override void TickLong() { CheckTemperatureMakeLeafless(); if (!base.Destroyed) { if (PlantUtility.GrowthSeasonNow(base.Position, base.Map)) { float num = growthInt; bool flag = LifeStage == PlantLifeStage.Mature; growthInt += GrowthPerTick * 2000f; if (growthInt > 1f) { growthInt = 1f; } if (((!flag && LifeStage == PlantLifeStage.Mature) || (int)(num * 10f) != (int)(growthInt * 10f)) && CurrentlyCultivated()) { base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); } } if (!HasEnoughLightToGrow) { unlitTicks += 2000; } else { unlitTicks = 0; } ageInt += 2000; if (Dying) { Map map = base.Map; bool isCrop = IsCrop; bool harvestableNow = HarvestableNow; bool dyingBecauseExposedToLight = DyingBecauseExposedToLight; int num2 = Mathf.CeilToInt(CurrentDyingDamagePerTick * 2000f); TakeDamage(new DamageInfo(DamageDefOf.Rotting, (float)num2)); if (base.Destroyed) { if (isCrop && def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + def.defName, 240f)) { string key = harvestableNow ? "MessagePlantDiedOfRot_LeftUnharvested" : ((!dyingBecauseExposedToLight) ? "MessagePlantDiedOfRot" : "MessagePlantDiedOfRot_ExposedToLight"); Messages.Message(key.Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(base.Position, map), MessageTypeDefOf.NegativeEvent); } return; } } cachedLabelMouseover = null; if (def.plant.dropLeaves) { MoteLeaf moteLeaf = MoteMaker.MakeStaticMote(Vector3.zero, base.Map, ThingDefOf.Mote_Leaf) as MoteLeaf; if (moteLeaf != null) { float num3 = def.plant.visualSizeRange.LerpThroughRange(growthInt); float treeHeight = def.graphicData.drawSize.x * num3; Vector3 b = Rand.InsideUnitCircleVec3 * LeafSpawnRadius; moteLeaf.Initialize(base.Position.ToVector3Shifted() + Vector3.up * Rand.Range(LeafSpawnYMin, LeafSpawnYMax) + b + Vector3.forward * def.graphicData.shadowData.offset.z, Rand.Value * 2000.TicksToSeconds(), b.z > 0f, treeHeight); } } } }
public override string GetInspectString() { string text = string.Empty; 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 (PlantUtility.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 = ((!PlantUtility.GrowthSeasonNow(base.Position, base.Map, forSowing: true)) ? ((string)(text + ("\n" + "CannotGrowBadSeasonTemperature".Translate()))) : ((string)(text + ("\n" + "GrowSeasonHereNow".Translate())))); } return(text); }
public override string GetInspectString() { string text = ""; if (!base.Cells.NullOrEmpty()) { IntVec3 c = base.Cells.First(); if (c.UsesOutdoorTemperature(base.Map)) { text += "OutdoorGrowingPeriod".Translate() + ": " + GrowingQuadrumsDescription(base.Map.Tile) + "\n"; } text = ((!PlantUtility.GrowthSeasonNow(c, base.Map, forSowing: true)) ? ((string)(text + "CannotGrowBadSeasonTemperature".Translate())) : ((string)(text + "GrowSeasonHereNow".Translate()))); } return(text); }
public override string GetInspectString() { string text = base.GetInspectString(); if (base.Spawned) { if (PlantUtility.GrowthSeasonNow(base.Position, base.Map, true)) { text = text + "\n" + "GrowSeasonHereNow".Translate(); } else { text = text + "\n" + "CannotGrowBadSeasonTemperature".Translate(); } } return(text); }
private bool CanSpawnAt(IntVec3 c, Map map) { if (!c.Standable(map) || c.Fogged(map) || map.fertilityGrid.FertilityAt(c) < ThingDefOf.Plant_Ambrosia.plant.fertilityMin || !c.GetRoom(map).PsychologicallyOutdoors || c.GetEdifice(map) != null || !PlantUtility.GrowthSeasonNow(c, map)) { return(false); } Plant plant = c.GetPlant(map); if (plant != null && plant.def.plant.growDays > 10f) { return(false); } List <Thing> thingList = c.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].def == ThingDefOf.Plant_Ambrosia) { return(false); } } return(true); }
public override Job JobOnCell(Pawn pawn, IntVec3 c, bool forced = false) { Map map = pawn.Map; if (c.IsForbidden(pawn)) { return(null); } if (!PlantUtility.GrowthSeasonNow(c, map, forSowing: true)) { 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 < 0f) { return(null); } } if (WorkGiver_Grower.wantedPlantDef.plant.cavePlant) { if (!c.Roofed(map)) { JobFailReason.Is(CantSowCavePlantBecauseUnroofedTrans); return(null); } if (map.glowGrid.GameGlowAt(c, ignoreCavePlants: true) > 0f) { JobFailReason.Is(CantSowCavePlantBecauseOfLightTrans); return(null); } } if (WorkGiver_Grower.wantedPlantDef.plant.interferesWithRoof && c.Roofed(pawn.Map)) { return(null); } Plant plant = c.GetPlant(map); if (plant != null && plant.def.plant.blockAdjacentSow) { if (!pawn.CanReserve(plant, 1, -1, null, forced) || plant.IsForbidden(pawn)) { return(null); } return(JobMaker.MakeJob(JobDefOf.CutPlant, plant)); } Thing thing2 = PlantUtility.AdjacentSowBlocker(WorkGiver_Grower.wantedPlantDef, c, map); if (thing2 != null) { Plant plant2 = thing2 as Plant; if (plant2 != null && pawn.CanReserve(plant2, 1, -1, null, forced) && !plant2.IsForbidden(pawn)) { IPlantToGrowSettable plantToGrowSettable = plant2.Position.GetPlantToGrowSettable(plant2.Map); if (plantToGrowSettable == null || plantToGrowSettable.GetPlantDefToGrow() != plant2.def) { return(JobMaker.MakeJob(JobDefOf.CutPlant, plant2)); } } return(null); } if (WorkGiver_Grower.wantedPlantDef.plant.sowMinSkill > 0 && pawn.skills != null && pawn.skills.GetSkill(SkillDefOf.Plants).Level < WorkGiver_Grower.wantedPlantDef.plant.sowMinSkill) { JobFailReason.Is("UnderAllowedSkill".Translate(WorkGiver_Grower.wantedPlantDef.plant.sowMinSkill), def.label); return(null); } for (int j = 0; j < thingList.Count; j++) { Thing thing3 = thingList[j]; if (!thing3.def.BlocksPlanting()) { continue; } if (!pawn.CanReserve(thing3, 1, -1, null, forced)) { return(null); } if (thing3.def.category == ThingCategory.Plant) { if (!thing3.IsForbidden(pawn)) { return(JobMaker.MakeJob(JobDefOf.CutPlant, thing3)); } return(null); } if (thing3.def.EverHaulable) { return(HaulAIUtility.HaulAsideJobFor(pawn, thing3)); } return(null); } if (!WorkGiver_Grower.wantedPlantDef.CanEverPlantAt_NewTemp(c, map) || !PlantUtility.GrowthSeasonNow(c, map, forSowing: true) || !pawn.CanReserve(c, 1, -1, null, forced)) { return(null); } Job job = JobMaker.MakeJob(JobDefOf.Sow, c); job.plantDefToSow = WorkGiver_Grower.wantedPlantDef; return(job); }
public override void TickLong() { this.CheckTemperatureMakeLeafless(); if (base.Destroyed) { return; } if (PlantUtility.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)) && 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(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); } } }
// Token: 0x060000AB RID: 171 RVA: 0x00005B20 File Offset: 0x00003D20 public override Job JobOnCell(Pawn pawn, IntVec3 c, bool forced = false) { Map map = pawn.Map; bool flag = c.IsForbidden(pawn); Job result; if (flag) { result = null; } else { bool flag2 = !PlantUtility.GrowthSeasonNow(c, map, false); if (flag2) { result = null; } else { bool flag3 = WorkGiver_WPGrower.wantedPlantDef == null; if (flag3) { WorkGiver_WPGrower.wantedPlantDef = WorkGiver_WPGrower.CalculateWantedPlantDef(c, map); bool flag4 = WorkGiver_WPGrower.wantedPlantDef == null; if (flag4) { return(null); } } List <Thing> thingList = c.GetThingList(map); bool flag5 = false; for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; bool flag6 = thing.def == WorkGiver_WPGrower.wantedPlantDef; if (flag6) { return(null); } bool flag7 = (thing is Blueprint || thing is Frame) && thing.Faction == pawn.Faction; if (flag7) { flag5 = true; } } bool flag8 = flag5; if (flag8) { Thing edifice = c.GetEdifice(map); bool flag9 = edifice == null || edifice.def.fertility < 0f; if (flag9) { return(null); } } bool cavePlant = WorkGiver_WPGrower.wantedPlantDef.plant.cavePlant; if (cavePlant) { bool flag10 = !c.Roofed(map); if (flag10) { JobFailReason.Is(WorkGiver_WPGrowerSow.CantSowCavePlantBecauseUnroofedTrans, null); return(null); } bool flag11 = map.glowGrid.GameGlowAt(c, true) > 0f; if (flag11) { JobFailReason.Is(WorkGiver_WPGrowerSow.CantSowCavePlantBecauseOfLightTrans, null); return(null); } } Plant plant = c.GetPlant(map); bool flag12 = plant != null && plant.def.plant.blockAdjacentSow; if (flag12) { bool flag13 = !pawn.CanReserve(plant, 1, -1, null, false) || plant.IsForbidden(pawn); if (flag13) { result = null; } else { result = new Job(JobDefOf.CutPlant, plant); } } else { Thing thing2 = PlantUtility.AdjacentSowBlocker(WorkGiver_WPGrower.wantedPlantDef, c, map); bool flag14 = thing2 != null; if (flag14) { Plant plant2 = thing2 as Plant; bool flag15 = plant2 != null && pawn.CanReserve(plant2, 1, -1, null, false) && !plant2.IsForbidden(pawn); if (flag15) { IPlantToGrowSettable plantToGrowSettable = plant2.Position.GetPlantToGrowSettable(plant2.Map); bool flag16 = plantToGrowSettable == null || plantToGrowSettable.GetPlantDefToGrow() != plant2.def; if (flag16) { return(new Job(JobDefOf.CutPlant, plant2)); } } result = null; } else { bool flag17 = WorkGiver_WPGrower.wantedPlantDef.plant.sowMinSkill > 0 && pawn.skills != null && pawn.skills.GetSkill(SkillDefOf.Plants).Level < WorkGiver_WPGrower.wantedPlantDef.plant.sowMinSkill; if (flag17) { result = null; } else { int j = 0; while (j < thingList.Count) { Thing thing3 = thingList[j]; bool blockPlanting = thing3.def.BlockPlanting; if (blockPlanting) { bool flag18 = !pawn.CanReserve(thing3, 1, -1, null, false); if (flag18) { return(null); } bool flag19 = thing3.def.category == ThingCategory.Plant; if (flag19) { bool flag20 = !thing3.IsForbidden(pawn); if (flag20) { return(new Job(JobDefOf.CutPlant, thing3)); } return(null); } else { bool everHaulable = thing3.def.EverHaulable; if (everHaulable) { return(HaulAIUtility.HaulAsideJobFor(pawn, thing3)); } return(null); } } else { j++; } } bool flag21 = !WorkGiver_WPGrower.wantedPlantDef.CanEverPlantAt(c, map) || !PlantUtility.GrowthSeasonNow(c, map, false) || !pawn.CanReserve(c, 1, -1, null, false); if (flag21) { result = null; } else { result = new Job(WPJobDefOf.WPSow, c) { plantDefToSow = WorkGiver_WPGrower.wantedPlantDef }; } } } } } } return(result); }
public override Job JobOnCell(Pawn pawn, IntVec3 c, bool forced = false) { Map map = pawn.Map; if (c.IsForbidden(pawn)) { return(null); } if (!PlantUtility.GrowthSeasonNow(c, map, true)) { 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 < 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)) { return(null); } Plant plant = c.GetPlant(map); if (plant != null && 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)); } else { Thing thing2 = PlantUtility.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)); } } } return(null); } if (WorkGiver_Grower.wantedPlantDef.plant.sowMinSkill > 0 && 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) && PlantUtility.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 }); } } return(null); } }
public override void TickLong() { CheckTemperatureMakeLeafless(); if (Destroyed) { return; } if (PlantUtility.GrowthSeasonNow(Position, Map)) { //Grow float prevGrowth = growthInt; bool wasMature = LifeStage == PlantLifeStage.Mature; growthInt += GrowthPerTick * GenTicks.TickLongInterval; if (growthInt > 1f) { growthInt = 1f; } //Regenerate layers if ((!wasMature && LifeStage == PlantLifeStage.Mature) || (int)(prevGrowth * 10f) != (int)(growthInt * 10f)) { if (CurrentlyCultivated()) { Map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Things); } } } bool hasLight = HasEnoughLightToGrow; //Record light starvation if (!hasLight) { unlitTicks += GenTicks.TickLongInterval; } else { unlitTicks = 0; } //Age ageInt += GenTicks.TickLongInterval; //Dying if (Dying) { var map = Map; bool isCrop = IsCrop; // before applying damage! bool harvestableNow = HarvestableNow; bool dyingBecauseExposedToLight = DyingBecauseExposedToLight; int dyingDamAmount = Mathf.CeilToInt(CurrentDyingDamagePerTick * GenTicks.TickLongInterval); TakeDamage(new DamageInfo(DamageDefOf.Rotting, dyingDamAmount)); if (Destroyed) { if (isCrop && def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + def.defName, 240f)) { string messageKey; if (harvestableNow) { messageKey = "MessagePlantDiedOfRot_LeftUnharvested"; } else if (dyingBecauseExposedToLight) { messageKey = "MessagePlantDiedOfRot_ExposedToLight"; } else { messageKey = "MessagePlantDiedOfRot"; } Messages.Message(messageKey.Translate(GetCustomLabelNoCount(includeHp: false)).CapitalizeFirst(), new TargetInfo(Position, map), MessageTypeDefOf.NegativeEvent); } return; } } //State has changed, label may have to as well //Also, we want to keep this null so we don't have useless data sitting there a long time in plants that never get looked at cachedLabelMouseover = null; // Drop a leaf if (def.plant.dropLeaves) { var mote = MoteMaker.MakeStaticMote(Vector3.zero, Map, ThingDefOf.Mote_Leaf) as MoteLeaf; if (mote != null) { float size = def.plant.visualSizeRange.LerpThroughRange(growthInt); float graphicSize = def.graphicData.drawSize.x * size; //Plants don't support non-square drawSizes var disc = Rand.InsideUnitCircleVec3 * LeafSpawnRadius; // Horizontal alignment mote.Initialize(Position.ToVector3Shifted() // Center of the tile + Vector3.up * Rand.Range(LeafSpawnYMin, LeafSpawnYMax) // Vertical alignment + disc // Horizontal alignment + Vector3.forward * def.graphicData.shadowData.offset.z, // Move to the approximate base of the tree Rand.Value * GenTicks.TickLongInterval.TicksToSeconds(), disc.z > 0, graphicSize ); } } }