protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; int maxPoints = 150; if (GenDate.DaysPassed < 7) { maxPoints = 40; } List <Pawn> list = (from p in map.mapPawns.AllPawnsSpawned where p.RaceProps.Animal && p.kindDef.combatPower <= (float)maxPoints && IncidentWorker_AnimalInsanityMass.AnimalUsable(p) select p).ToList <Pawn>(); if (list.Count == 0) { return(false); } Pawn pawn = list.RandomElement <Pawn>(); IncidentWorker_AnimalInsanityMass.DriveInsane(pawn); string text = "AnimalInsanitySingle".Translate(new object[] { pawn.Label }); Find.LetterStack.ReceiveLetter("LetterLabelAnimalInsanitySingle".Translate(), text, LetterDefOf.ThreatSmall, pawn, null); return(true); }
private bool TryFindRandomAnimal(Map map, out Pawn animal) { int maxPoints = 150; if (GenDate.DaysPassed < 7) { maxPoints = 40; } return (from p in map.mapPawns.AllPawnsSpawned where p.RaceProps.Animal && p.kindDef.combatPower <= (float)maxPoints && IncidentWorker_AnimalInsanityMass.AnimalUsable(p) select p).TryRandomElement(out animal); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!TryFindRandomAnimal(map, out var animal)) { return(false); } IncidentWorker_AnimalInsanityMass.DriveInsane(animal); string str = "AnimalInsanitySingle".Translate(animal.Label, animal.Named("ANIMAL")); SendStandardLetter("LetterLabelAnimalInsanitySingle".Translate(animal.Label, animal.Named("ANIMAL")), str, LetterDefOf.ThreatSmall, parms, animal); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!TryFindRandomAnimal(map, out Pawn animal)) { return(false); } IncidentWorker_AnimalInsanityMass.DriveInsane(animal); string text = "AnimalInsanitySingle".Translate(animal.Label, animal.Named("ANIMAL")); Find.LetterStack.ReceiveLetter("LetterLabelAnimalInsanitySingle".Translate(animal.Label, animal.Named("ANIMAL")), text, LetterDefOf.ThreatSmall, animal); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; Pawn pawn; if (!this.TryFindRandomAnimal(map, out pawn)) { return(false); } IncidentWorker_AnimalInsanityMass.DriveInsane(pawn); string text = "AnimalInsanitySingle".Translate(new object[] { pawn.Label }); Find.LetterStack.ReceiveLetter("LetterLabelAnimalInsanitySingle".Translate(new object[] { pawn.Label }), text, LetterDefOf.ThreatSmall, pawn, null, null); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (parms.points <= 0f) { Log.Error("AnimalInsanity running without points.", false); parms.points = (float)((int)(map.strengthWatcher.StrengthRating * 50f)); } float adjustedPoints = parms.points; if (adjustedPoints > 250f) { adjustedPoints -= 250f; adjustedPoints *= 0.5f; adjustedPoints += 250f; } IEnumerable <PawnKindDef> source = from def in DefDatabase <PawnKindDef> .AllDefs where def.RaceProps.Animal && def.combatPower <= adjustedPoints && (from p in map.mapPawns.AllPawnsSpawned where p.kindDef == def && IncidentWorker_AnimalInsanityMass.AnimalUsable(p) select p).Count <Pawn>() >= 3 select def; PawnKindDef animalDef; if (!source.TryRandomElement(out animalDef)) { return(false); } List <Pawn> list = (from p in map.mapPawns.AllPawnsSpawned where p.kindDef == animalDef && IncidentWorker_AnimalInsanityMass.AnimalUsable(p) select p).ToList <Pawn>(); float combatPower = animalDef.combatPower; float num = 0f; int num2 = 0; Pawn pawn = null; list.Shuffle <Pawn>(); foreach (Pawn current in list) { if (num + combatPower > adjustedPoints) { break; } IncidentWorker_AnimalInsanityMass.DriveInsane(current); num += combatPower; num2++; pawn = current; } if (num == 0f) { return(false); } string label; string text; LetterDef textLetterDef; if (num2 == 1) { label = "LetterLabelAnimalInsanitySingle".Translate(pawn.LabelShort, pawn.Named("ANIMAL")); text = "AnimalInsanitySingle".Translate(pawn.LabelShort, pawn.Named("ANIMAL")); textLetterDef = LetterDefOf.ThreatSmall; } else { label = "LetterLabelAnimalInsanityMultiple".Translate(animalDef.GetLabelPlural(-1)); text = "AnimalInsanityMultiple".Translate(animalDef.GetLabelPlural(-1)); textLetterDef = LetterDefOf.ThreatBig; } Find.LetterStack.ReceiveLetter(label, text, textLetterDef, pawn, null, null); SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(map); if (map == Find.CurrentMap) { Find.CameraDriver.shaker.DoShake(1f); } return(true); }
internal bool <> m__1(Pawn p) { return(p.kindDef == this.animalDef && IncidentWorker_AnimalInsanityMass.AnimalUsable(p)); }
internal bool <> m__0(PawnKindDef def) { return(def.RaceProps.Animal && def.combatPower <= this.adjustedPoints && (from p in this.map.mapPawns.AllPawnsSpawned where p.kindDef == def && IncidentWorker_AnimalInsanityMass.AnimalUsable(p) select p).Count <Pawn>() >= 3); }
internal bool <> m__0(Pawn p) { return(p.RaceProps.Animal && p.kindDef.combatPower <= (float)this.maxPoints && IncidentWorker_AnimalInsanityMass.AnimalUsable(p)); }