private void TrySpawnMechanoids() { if (this.pointsLeft <= 0f) { return; } if (this.lord == null) { IntVec3 invalid; if (!CellFinder.TryFindRandomCellNear(base.Position, base.Map, 5, (IntVec3 c) => c.Standable(base.Map) && base.Map.reachability.CanReach(c, this, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)), out invalid)) { Log.Error("Found no place for mechanoids to defend " + this); invalid = IntVec3.Invalid; } LordJob_MechanoidsDefendShip lordJob = new LordJob_MechanoidsDefendShip(this, base.Faction, 21f, invalid); this.lord = LordMaker.MakeNewLord(Faction.OfMechanoids, lordJob, base.Map, null); } PawnKindDef kindDef; while ((from def in DefDatabase <PawnKindDef> .AllDefs where def.RaceProps.IsMechanoid && def.isFighter && def.combatPower <= this.pointsLeft select def).TryRandomElement(out kindDef)) { IntVec3 center; if ((from cell in GenAdj.CellsAdjacent8Way(this) where this.CanSpawnMechanoidAt(cell) select cell).TryRandomElement(out center)) { Pawn pawn = PawnGenerator.GeneratePawn(kindDef, Faction.OfMechanoids); if (GenPlace.TryPlaceThing(pawn, center, base.Map, ThingPlaceMode.Near, null)) { this.lord.AddPawn(pawn); this.pointsLeft -= pawn.kindDef.combatPower; continue; } Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); } IL_130: this.pointsLeft = 0f; if (base.Map == Find.VisibleMap) { SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(); } return; } this.pointsLeft = 0f; if (base.Map == Find.VisibleMap) { SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(); } }
private void TrySpawnMechanoids() { if (this.pointsLeft <= 0f) { return; } if (this.lord == null) { IntVec3 invalid; if (!CellFinder.TryFindRandomCellNear(base.Position, 5, (IntVec3 c) => c.Standable() && c.CanReach(this, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)), out invalid)) { Log.Error("Found no place for mechanoids to defend " + this); invalid = IntVec3.Invalid; } LordJob_MechanoidsDefendShip lordJob = new LordJob_MechanoidsDefendShip(this, base.Faction, 21f, invalid); this.lord = LordMaker.MakeNewLord(Faction.OfMechanoids, lordJob, null); } PawnKindDef kindDef; while (( from def in DefDatabase<PawnKindDef>.AllDefs where def.RaceProps.IsMechanoid && def.isFighter && def.combatPower <= this.pointsLeft select def).TryRandomElement(out kindDef)) { IntVec3 center; if (( from cell in GenAdj.CellsAdjacent8Way(this) where this.CanSpawnMechanoidAt(cell) select cell).TryRandomElement(out center)) { Pawn pawn = PawnGenerator.GeneratePawn(kindDef, Faction.OfMechanoids); if (GenPlace.TryPlaceThing(pawn, center, ThingPlaceMode.Near, null)) { this.lord.AddPawn(pawn); this.pointsLeft -= pawn.kindDef.combatPower; continue; } Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); } this.pointsLeft = 0f; SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(); return; } this.pointsLeft = 0f; SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(); return; }
//Handles the spawning of pawns public override void GiveBirth() { Pawn mother = pawn; if (mother == null) { return; } try { //fail if hediff added through debug, since babies not initialized if (babies.Count > 9999) { Log.Message("RJW mech pregnancy birthing pawn count: " + babies.Count); } } catch { Initialize(mother, father); } foreach (Pawn baby in babies) { Faction spawn_faction = null; if (!is_hacked) { spawn_faction = Faction.OfMechanoids; } Pawn baby1 = PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDef.Named("Mech_Scyther"), spawn_faction)); PawnUtility.TrySpawnHatchedOrBornPawn(baby1, mother); if (!is_hacked) { LordJob_MechanoidsDefendShip lordJob = new LordJob_MechanoidsDefendShip(mother, baby1.Faction, 50f, mother.Position); Lord lord = LordMaker.MakeNewLord(baby1.Faction, lordJob, baby1.Map); lord.AddPawn(baby1); } FilthMaker.MakeFilth(baby1.PositionHeld, baby1.MapHeld, mother.RaceProps.BloodDef, mother.LabelIndefinite()); } IEnumerable <BodyPartRecord> source = from x in mother.health.hediffSet.GetNotMissingParts() where x.IsInGroup(BodyPartGroupDefOf.Torso) && !x.IsCorePart //someday include depth filter //so it doesnt cut out external organs (breasts)? //vag is genital part and genital is external //anal is internal //make sep part of vag? //&& x.depth == BodyPartDepth.Inside select x; if (source.Any()) { foreach (BodyPartRecord part in source) { Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, mother, part); hediff_MissingPart.lastInjury = HediffDefOf.Cut; hediff_MissingPart.IsFresh = true; mother.health.AddHediff(hediff_MissingPart); //idk blood doesnt drop //mother.health.DropBloodFilth(); //FilthMaker.MakeFilth(corpse.PositionHeld, corpse.MapHeld, mother.RaceProps.BloodDef, mother.LabelIndefinite()); } } mother.health.RemoveHediff(this); }