protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; PawnKindDef pawnKindDef = default(PawnKindDef); if (!this.TryFindAnimalKind(map.Tile, out pawnKindDef)) { return(false); } IntVec3 intVec = default(IntVec3); IntVec3 near = default(IntVec3); if (!this.TryFindStartAndEndCells(map, out intVec, out near)) { return(false); } Rot4 rot = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat); List <Pawn> list = this.GenerateAnimals(pawnKindDef, map.Tile); for (int i = 0; i < list.Count; i++) { Pawn newThing = list[i]; IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); GenSpawn.Spawn(newThing, loc, map, rot, false); } LordMaker.MakeNewLord(null, new LordJob_ExitMapNear(near, LocomotionUrgency.Walk, 12f, false, false), map, list); string text = string.Format(base.def.letterText, pawnKindDef.GetLabelPlural(-1)).CapitalizeFirst(); string label = string.Format(base.def.letterLabel, pawnKindDef.GetLabelPlural(-1).CapitalizeFirst()); Find.LetterStack.ReceiveLetter(label, text, base.def.letterDef, list[0], null); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; PawnKindDef bossKind = def.pawnKind; PawnKindDef animalKind = GetAnimalKind(parms.points, map.Tile); if (bossKind == null || animalKind == null || ManhunterPackIncidentUtility.GetAnimalsCount(animalKind, (parms.points * PointsFactor) - bossKind.combatPower) <= 0) { return(false); } IntVec3 result = parms.spawnCenter; if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal)) { return(false); } List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(bossKind, map.Tile, bossKind.combatPower, 1); list.AddRange(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, map.Tile, (parms.points * PointsFactor) - bossKind.combatPower, parms.pawnCount)); Rot4 rot = Rot4.FromAngleFlat((map.Center - result).AngleFlat); for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i]; IntVec3 loc = CellFinder.RandomClosewalkCellNear(result, map, 10); QuestUtility.AddQuestTag(GenSpawn.Spawn(pawn, loc, map, rot), parms.questTag); pawn.health.AddHediff(HediffDefOf.Scaria); pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent); pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(AnimalsStayDurationMin, AnimalsStayDurationMax); } TaggedString labelString = null; if (def.letterLabel != null) { labelString = def.letterLabel; } else { labelString = "LetterLabelManhunterPackArrived".Translate(); } TaggedString textString = null; if (def.letterText != null) { textString = def.letterText; } else { textString = "ManhunterPackArrived".Translate(animalKind.GetLabelPlural()); } SendStandardLetter(labelString, textString, LetterDefOf.ThreatBig, parms, list[0]); Find.TickManager.slower.SignalForceNormalSpeedShort(); LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical); LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null)) { Helper.Log($"Cant fire custom manhunter. No edge road chance entry cell"); return(false); } int count = ManhunterPackIncidentUtility.GetAnimalsCount(PawnKindDef, parms.points); ToolkitPatchLogger.Log(LOGGER_NAME, $"Spawning {count} beasts based {parms.points}"); for (int i = 0; i < count; i++) { var loc = CellFinder.RandomClosewalkCellNear(intVec, map, 12, null); var pawn = PawnGenerator.GeneratePawn(PawnKindDef, null); GenSpawn.Spawn(pawn, loc, map, Rot4.Random, WipeMode.Vanish, false); pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); } var text = "CustomManhunterEnteringLabel".Translate(PawnKindDef.GetLabelPlural(-1)); Find.LetterStack.ReceiveLetter("CustomManhunterStoriesLetterLabel".Translate(), text, LetterDefOf.NegativeEvent, new TargetInfo(intVec, map, false), null, null); return(true); }
public AcceptanceReport CanBeTrained(PawnKindDef pawnKind, TrainableDef td, out bool visible) { if (pawnKind.RaceProps.untrainableTags != null) { for (var index = 0; index < pawnKind.RaceProps.untrainableTags.Count; ++index) { if (td.MatchesTag(pawnKind.RaceProps.untrainableTags[index])) { visible = false; return(false); } } } if (pawnKind.RaceProps.trainableTags != null) { for (var index = 0; index < pawnKind.RaceProps.trainableTags.Count; ++index) { if (td.MatchesTag(pawnKind.RaceProps.trainableTags[index])) { if (pawnKind.RaceProps.baseBodySize < (double)td.minBodySize) { visible = true; return(new AcceptanceReport( "CannotTrainTooSmall".Translate((object)pawnKind.LabelCap))); } visible = true; return(true); } } } if (!td.defaultTrainable) { visible = false; return(false); } if (pawnKind.RaceProps.baseBodySize < (double)td.minBodySize) { visible = true; return(new AcceptanceReport( "FM.Livestock.CannotTrainTooSmall".Translate((object)pawnKind.GetLabelPlural()))); } if (pawnKind.RaceProps.trainability.intelligenceOrder < td.requiredTrainability.intelligenceOrder) { visible = true; return (new AcceptanceReport("CannotTrainNotSmartEnough".Translate((object)td.requiredTrainability))); } visible = true; return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { if (PawnKindDef == null && !TryFindAnimalKind(parms.target.Tile, out PawnKindDef)) { return(false); } var map = (Map)parms.target; IntVec3 intVec; if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null)) { return(false); } if (Count <= 0) { Count = Mathf.Clamp(GenMath.RoundRandom(TotalBodySizeToSpawn / PawnKindDef.RaceProps.baseBodySize), 2, 10);; } for (int i = 0; i < Count; i++) { var loc = CellFinder.RandomClosewalkCellNear(intVec, map, 12, null); var pawn = PawnGenerator.GeneratePawn(PawnKindDef, null); GenSpawn.Spawn(pawn, loc, map, Rot4.Random, WipeMode.Vanish, false); if (JoinColony) { pawn.SetFaction(Faction.OfPlayer, null); } if (Manhunter) { pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); } } var text = DefaultText ? "LetterFarmAnimalsWanderIn".Translate(PawnKindDef.GetLabelPlural(-1)) : ""; if (Quote != null) { if (DefaultText) { text += "\n\n"; } text += Quote; } Find.LetterStack.ReceiveLetter((Label ?? "LetterLabelFarmAnimalsWanderIn").Translate(PawnKindDef.GetLabelPlural(-1)).CapitalizeFirst(), text, Manhunter ? LetterDefOf.NegativeEvent : LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null, null); return(true); }
private float DrawAnimalSection(ref Vector2 pos, float width, string type, PawnKindDef pawnKind, List <Pawn> animals) { if (animals == null) { return(0); } var start = pos; DrawAnimalListheader(ref pos, new Vector2(width, ListEntryHeight / 3 * 2), pawnKind); if (animals.Count == 0) { Label(new Rect(pos.x, pos.y, width, ListEntryHeight), "FML.NoAnimals".Translate(type, pawnKind.GetLabelPlural()), TextAnchor.MiddleCenter, color: Color.grey); pos.y += ListEntryHeight; } for (var i = 0; i < animals.Count; i++) { DrawAnimalRow(ref pos, new Vector2(width, ListEntryHeight), animals[i]); } return(pos.y - start.y); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec = default(IntVec3); if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, (Predicate <IntVec3>)null)) { return(false); } PawnKindDef pawnKindDef = default(PawnKindDef); if (!(from x in DefDatabase <PawnKindDef> .AllDefs where x.RaceProps.Animal && x.RaceProps.wildness < 0.34999999403953552 && map.mapTemperature.SeasonAndOutdoorTemperatureAcceptableFor(x.race) select x).TryRandomElementByWeight <PawnKindDef>((Func <PawnKindDef, float>)((PawnKindDef k) => (float)(0.42000001668930054 - k.RaceProps.wildness)), out pawnKindDef)) { return(false); } int num = Mathf.Clamp(GenMath.RoundRandom((float)(2.5 / pawnKindDef.RaceProps.baseBodySize)), 2, 10); for (int i = 0; i < num; i++) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 12, null); Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDef, null); GenSpawn.Spawn(pawn, loc, map, Rot4.Random, false); pawn.SetFaction(Faction.OfPlayer, null); } Find.LetterStack.ReceiveLetter("LetterLabelFarmAnimalsWanderIn".Translate(pawnKindDef.GetLabelPlural(-1)).CapitalizeFirst(), "LetterFarmAnimalsWanderIn".Translate(pawnKindDef.GetLabelPlural(-1)), LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; PawnKindDef pawnKindDef = default(PawnKindDef); if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out pawnKindDef)) { return(false); } IntVec3 intVec = default(IntVec3); if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, (Predicate <IntVec3>)null)) { return(false); } List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(pawnKindDef, map.Tile, (float)(parms.points * 1.3999999761581421)); Rot4 rot = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat); for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i]; IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); GenSpawn.Spawn(pawn, loc, map, rot, false); pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null); pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 135000); } Find.LetterStack.ReceiveLetter("LetterLabelManhunterPackArrived".Translate(), "ManhunterPackArrived".Translate(pawnKindDef.GetLabelPlural(-1)), LetterDefOf.ThreatBig, list[0], null); Find.TickManager.slower.SignalForceNormalSpeedShort(); LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical); LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; PawnKindDef animalKind = parms.pawnKind; if ((animalKind == null && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out animalKind)) || ManhunterPackIncidentUtility.GetAnimalsCount(animalKind, parms.points) == 0) { return(false); } IntVec3 result = parms.spawnCenter; if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal)) { return(false); } List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals_NewTmp(animalKind, map.Tile, parms.points * 1f, parms.pawnCount); Rot4 rot = Rot4.FromAngleFlat((map.Center - result).AngleFlat); for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i]; IntVec3 loc = CellFinder.RandomClosewalkCellNear(result, map, 10); QuestUtility.AddQuestTag(GenSpawn.Spawn(pawn, loc, map, rot), parms.questTag); pawn.health.AddHediff(HediffDefOf.Scaria); pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent); pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 120000); } SendStandardLetter("LetterLabelManhunterPackArrived".Translate(), "ManhunterPackArrived".Translate(animalKind.GetLabelPlural()), LetterDefOf.ThreatBig, parms, list[0]); Find.TickManager.slower.SignalForceNormalSpeedShort(); LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical); LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important); return(true); }
static bool Prefix(ref bool __result, IncidentWorker_FarmAnimalsWanderIn __instance, IncidentParms parms) { Map map = (Map)parms.target; object[] parameters = new object[] { map, null }; bool flag = (bool)TryFindRandomPawnKindInfo.Invoke(__instance, parameters); if (!flag) { return(false); } PawnKindDef kind = (PawnKindDef)parameters[1]; // Check this AFTER getting a pawn kind if (!RCellFinderExtended.TryFindRandomPawnEntryCell(out IntVec3 result, map, kind, CellFinder.EdgeRoadChance_Animal)) { return(false); } int num = Mathf.Clamp(GenMath.RoundRandom(2.5f / kind.RaceProps.baseBodySize), 2, 10); for (int i = 0; i < num; i++) { IntVec3 loc = CellFinderExtended.RandomClosewalkCellNear(result, map, kind, 12); Pawn pawn = PawnGenerator.GeneratePawn(kind); GenSpawn.Spawn(pawn, loc, map, Rot4.Random); pawn.SetFaction(Faction.OfPlayer); } SendStandardLetterInfo.Invoke(__instance, new object[] { "LetterLabelFarmAnimalsWanderIn".Translate(kind.GetLabelPlural()).CapitalizeFirst(), "LetterFarmAnimalsWanderIn".Translate(kind.GetLabelPlural()), LetterDefOf.PositiveEvent, parms, new LookTargets(result, map), new NamedArgument[0] { } }); return(false); }
// Token: 0x0600000E RID: 14 RVA: 0x0000221C File Offset: 0x0000041C protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; PawnKindDef named = DefDatabase <PawnKindDef> .GetNamed("KillerRabbit", true); IntVec3 intVec; bool flag = !RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, false, null); bool result; if (flag) { result = false; } else { List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(named, map.Tile, parms.points * 1f); Rot4 rot = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat); for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i]; IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); GenSpawn.Spawn(pawn, loc, map, rot, WipeMode.Vanish, false); pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false); pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 120000); } Find.LetterStack.ReceiveLetter(Translator.Translate("LetterLabelManhunterPackArrived"), TranslatorFormattedStringExtensions.Translate("ManhunterPackArrived", named.GetLabelPlural(-1)), LetterDefOf.ThreatBig, list[0], null, null); Find.TickManager.slower.SignalForceNormalSpeedShort(); LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical); LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important); result = true; } return(result); }