protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; Plant plant; if (!this.TryFindRandomBlightablePlant(map, out plant)) { return(false); } Room room = plant.GetRoom(RegionType.Set_Passable); plant.CropBlighted(); int i = 0; int num = GenRadial.NumCellsInRadius(15f); while (i < num) { IntVec3 intVec = plant.Position + GenRadial.RadialPattern[i]; if (intVec.InBounds(map) && intVec.GetRoom(map, RegionType.Set_Passable) == room) { Plant firstBlightableNowPlant = BlightUtility.GetFirstBlightableNowPlant(intVec, map); if (firstBlightableNowPlant != null && firstBlightableNowPlant != plant) { if (Rand.Chance(0.4f * this.BlightChanceFactor(firstBlightableNowPlant.Position, plant.Position))) { firstBlightableNowPlant.CropBlighted(); } } } i++; } Find.LetterStack.ReceiveLetter("LetterLabelCropBlight".Translate(), "LetterCropBlight".Translate(), LetterDefOf.NegativeEvent, new TargetInfo(plant.Position, map, false), null, null); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; float num = RadiusFactorPerPointsCurve.Evaluate(parms.points); if (!TryFindRandomBlightablePlant(map, out Plant plant)) { return(false); } Room room = plant.GetRoom(); int i = 0; for (int num2 = GenRadial.NumCellsInRadius(11f * num); i < num2; i++) { IntVec3 intVec = plant.Position + GenRadial.RadialPattern[i]; if (intVec.InBounds(map) && intVec.GetRoom(map) == room) { Plant firstBlightableNowPlant = BlightUtility.GetFirstBlightableNowPlant(intVec, map); if (firstBlightableNowPlant != null && firstBlightableNowPlant.def == plant.def && Rand.Chance(BlightChance(firstBlightableNowPlant.Position, plant.Position, num))) { firstBlightableNowPlant.CropBlighted(); } } } SendStandardLetter("LetterLabelCropBlight".Translate(new NamedArgument(plant.def, "PLANTDEF")), "LetterCropBlight".Translate(new NamedArgument(plant.def, "PLANTDEF")), LetterDefOf.NegativeEvent, parms, new TargetInfo(plant.Position, map)); return(true); }