private static void SpawnPawnQuality() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (PawnKindDef item in DefDatabase <PawnKindDef> .AllDefs.Where(x => x.GetModExtension <DefExtension_Hybrid>() != null || x.race.tradeTags?.Contains("AnimalGeneticMechanoid") == true).OrderBy((PawnKindDef kd) => kd.defName)) { PawnKindDef localKindDef = item; list.Add(new DebugMenuOption(localKindDef.defName, DebugMenuOptionMode.Tool, delegate { Faction faction = FactionUtility.DefaultFactionFrom(localKindDef.defaultFactionType); Pawn newPawn = PawnGenerator.GeneratePawn(localKindDef, faction); GenSpawn.Spawn(newPawn, UI.MouseCell(), Find.CurrentMap); CompHybrid compHybrid = newPawn.TryGetComp <CompHybrid>(); if (compHybrid != null) { compHybrid.quality = QualityUtility.GenerateQualityRandomEqualChance(); } if (faction != null && faction != Faction.OfPlayer) { Lord lord = null; if (newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) => p != newPawn)) { lord = ((Pawn)GenClosest.ClosestThing_Global(newPawn.Position, newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction), 99999f, (Thing p) => p != newPawn && ((Pawn)p).GetLord() != null)).GetLord(); } if (lord == null) { LordJob_DefendPoint lordJob = new LordJob_DefendPoint(newPawn.Position); lord = LordMaker.MakeNewLord(faction, lordJob, Find.CurrentMap); } lord.AddPawn(newPawn); } })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
public static void AddQuality(Pawn pawn, Thing motherOrEgg) { CompHybrid compMother = motherOrEgg?.TryGetComp <CompHybrid>(); CompHybrid compFather = GeneticRim_Hediff_Pregnant_DoBirthSpawn_Patch.fatherStored?.TryGetComp <CompHybrid>(); if (compMother != null) { QualityCategory qualityMother = compMother.quality; QualityCategory qualityFather = QualityCategory.Awful; if (compFather != null) { qualityFather = compFather.quality; } CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>(); if (compHybrid != null) { if (compFather != null) { compHybrid.quality = (QualityCategory)Math.Min((sbyte)qualityMother, (sbyte)qualityFather); } else { compHybrid.quality = qualityMother; } } } }
public static void Postfix(Pawn __instance, ref string __result) { CompHybrid comp = __instance?.TryGetComp <CompHybrid>(); if (comp != null) { __result += $" ({comp.quality.GetLabel().CapitalizeFirst()})"; } }
public static void AddQualityToEgg(Pawn pawn) { CompHybrid compMother = GeneticRim_CompHatcher_Hatch_Patch.motherStored?.TryGetComp <CompHybrid>(); CompHybrid compFather = GeneticRim_CompHatcher_Hatch_Patch.fatherStored?.TryGetComp <CompHybrid>(); if (compMother != null && compFather != null) { QualityCategory qualityMother = compMother.quality; QualityCategory qualityFather = compFather.quality; CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>(); if (compHybrid != null) { compHybrid.quality = (QualityCategory)Math.Min((sbyte)qualityMother, (sbyte)qualityFather); } } }
public void SpawnHostileHYbrid() { Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(hybridsList.RandomElement(), null, fixedBiologicalAge: 3, fixedChronologicalAge: 3, newborn: false, forceGenerateNewPawn: true)); IntVec3 near = CellFinder.StandableCellNear(this.parent.Position, this.parent.Map, 2f); GenSpawn.Spawn(pawn, near, this.parent.Map); CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>(); if (compHybrid != null) { compHybrid.quality = QualityUtility.GenerateQualityRandomEqualChance(); } pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, true, false, null, false); pawn.health.AddHediff(InternalDefOf.GR_GreaterScaria); this.parent.Destroy(); }
public override void Tick() { base.Tick(); if (progress >= 0) { progress += 1f / this.duration; if (unSpentFuse == null && !oneRaidPerProgress) { mechRaidProgress++; if (mechRaidProgress > mechRaidInterval) { if (Find.FactionManager.FirstFactionOfDef(FactionDefOf.Mechanoid) != null) { IncidentParms parms = new IncidentParms(); parms.target = this.Map; parms.faction = Faction.OfMechanoids; parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target) * 2.5f; parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; parms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop; IncidentDef def = IncidentDefOf.RaidEnemy; def.Worker.TryExecute(parms); oneRaidPerProgress = true; } mechRaidProgress = 0; } } if (progress >= 1) { progress = -1f; this.Map.mapDrawer.MapMeshDirty(this.Position, MapMeshFlag.Things | MapMeshFlag.Buildings); Pawn innerPawn = this.innerContainer?.FirstOrFallback() as Pawn; PawnKindDef kindDef = innerPawn?.kindDef.GetModExtension <DefExtension_Paragon>()?.mechToConvertTo; Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(kindDef, Faction.OfPlayer, fixedBiologicalAge: 1, fixedChronologicalAge: 1, newborn: false, forceGenerateNewPawn: true)); IntVec3 near = CellFinder.StandableCellNear(this.Position, this.Map, 5f); GenSpawn.Spawn(pawn, near, this.Map); pawn.health.AddHediff(InternalDefOf.GR_RecentlyHatched); pawn.health.AddHediff(InternalDefOf.GR_AnimalControlHediff); if (innerPawn.Name != null && !innerPawn.Name.ToString().UncapitalizeFirst().Contains(innerPawn.def.label)) { pawn.Name = innerPawn.Name; } if (innerPawn.training != null) { pawn.training = innerPawn.training; } if (innerPawn.relations != null) { pawn.relations = innerPawn.relations; } if (innerPawn.playerSettings != null && innerPawn.playerSettings.AreaRestriction != null) { pawn.playerSettings.AreaRestriction = innerPawn.playerSettings.AreaRestriction; } QualityCategory quality = innerPawn.TryGetComp <CompHybrid>()?.quality ?? QualityCategory.Normal; CompHybrid comp = pawn.TryGetComp <CompHybrid>(); if (comp != null) { comp.quality = quality; } if (unSpentFuse != null) { unSpentFuse.active = false; GenExplosion.DoExplosion(unSpentFuse.Position, this.Map, 2.9f, DamageDefOf.Flame, this, -1, -1, null, null, null, null, null, 0f, 1, false, null, 0f, 1); } this.DestroyContents(); } } }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; float totalPoints = parms.points / 2; HashSet <PawnKindDef> hybridsList; if (StaticCollectionsClass.AnyMechAntennas()) { hybridsList = DefDatabase <PawnKindDef> .AllDefsListForReading.Where(x => (x.race.tradeTags?.Contains("AnimalGenetic") == true) && (x.race.tradeTags?.Contains("AnimalGeneticFailure") == false) && (x.race.tradeTags?.Contains("AnimalGeneticCentipede") == false)).ToHashSet(); } else { hybridsList = DefDatabase <PawnKindDef> .AllDefsListForReading.Where(x => (x.race.tradeTags?.Contains("AnimalGenetic") == true) && (x.race.tradeTags?.Contains("AnimalGeneticFailure") == false) && (x.race.tradeTags?.Contains("AnimalGeneticMechanoid") == false)).ToHashSet(); } List <Pawn> list = new List <Pawn>(); PawnKindDef firstPawn; hybridsList.TryRandomElementByWeight((PawnKindDef a) => ManhunterPackIncidentUtility.ManhunterAnimalWeight(a, parms.points), out firstPawn); IntVec3 result = parms.spawnCenter; if (firstPawn != null) { if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal)) { return(false); } Pawn item = PawnGenerator.GeneratePawn(new PawnGenerationRequest(firstPawn, null, PawnGenerationContext.NonPlayer, map.Tile)); list.Add(item); totalPoints -= item.kindDef.combatPower; while (totalPoints > 0) { PawnKindDef nextPawn; hybridsList.TryRandomElementByWeight((PawnKindDef a) => ManhunterPackIncidentUtility.ManhunterAnimalWeight(a, totalPoints), out nextPawn); Pawn nextitem = PawnGenerator.GeneratePawn(new PawnGenerationRequest(nextPawn, null, PawnGenerationContext.NonPlayer, map.Tile)); list.Add(nextitem); totalPoints -= nextitem.kindDef.combatPower; } } 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(InternalDefOf.GR_GreaterScaria); pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent); CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>(); if (compHybrid != null) { compHybrid.quality = QualityUtility.GenerateQualityRandomEqualChance(); } } SendStandardLetter("GR_LetterLabelMonstrositiesArrived".Translate(), "GR_LetterMonstrositiesArrived".Translate(), LetterDefOf.ThreatBig, parms, list[0]); Find.TickManager.slower.SignalForceNormalSpeedShort(); return(true); }
public override void CompTick() { base.CompTick(); if (this.growingResult != null) { if (compPowerTrader?.PowerOn == true) { this.progress += 1f / hoursProcess; // (GenDate.TicksPerDay * 7f); if (this.progress > 1) { Pawn pawn = null; if (failure) { pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(this.failureResult, null, fixedBiologicalAge: 1, fixedChronologicalAge: 1, newborn: false, forceGenerateNewPawn: true)); if (!GeneticRim_Mod.settings.GR_DisableWombAlerts) { Messages.Message("GR_ElectroWomb_Finished_Failure".Translate(), this.parent, MessageTypeDefOf.NegativeEvent, true); } } else { pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(this.growingResult, Faction.OfPlayer, fixedBiologicalAge: 1, fixedChronologicalAge: 1, newborn: false, forceGenerateNewPawn: true)); if (!GeneticRim_Mod.settings.GR_DisableWombAlerts) { Messages.Message("GR_ElectroWomb_Finished".Translate(), this.parent, MessageTypeDefOf.PositiveEvent, true); } } this.progress = 0; this.growingResult = null; IntVec3 near = CellFinder.StandableCellNear(this.parent.Position, this.parent.Map, 5f); GenSpawn.Spawn(pawn, near, this.parent.Map); pawn.health.AddHediff(InternalDefOf.GR_RecentlyHatched); if (!failure) { DefExtension_HybridChanceAlterer extension = this.booster?.GetModExtension <DefExtension_HybridChanceAlterer>(); if (extension?.isFertilityUnblocker != true && !GeneticRim_Mod.settings.GR_MakeAllHybridsFertile) { pawn.health.AddHediff(HediffDefOf.Sterilized); } if (extension?.isController == true || GeneticRim_Mod.settings.GR_MakeAllHybridsControllable) { pawn.health.AddHediff(InternalDefOf.GR_AnimalControlHediff); } if (extension?.addedHediffs != null) { AddInitialHybridHediffs(extension, pawn); } if (extension?.forceFemale != false) { pawn.gender = Gender.Female; } if (extension?.forceMale != false) { pawn.gender = Gender.Male; } } CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>(); if (compHybrid != null) { compHybrid.quality = this.genoframe?.GetModExtension <DefExtension_Quality>()?.quality ?? QualityCategory.Awful; } if (failureResult == InternalDefOf.GR_FleshGrowth && failure) { this.parent.Destroy(); } } } } }