// Token: 0x060029EE RID: 10734 RVA: 0x0013DA2C File Offset: 0x0013BE2C
 private void TrySpawnPawns()
 {
     if (this.pointsLeft <= 0f)
     {
         return;
     }
     if (!this.parent.Spawned)
     {
         return;
     }
     if (this.lord == null)
     {
         IntVec3 invalid;
         if (!CellFinder.TryFindRandomCellNear(this.parent.Position, this.parent.Map, 5, (IntVec3 c) => c.Standable(this.parent.Map) && this.parent.Map.reachability.CanReach(c, this.parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)), out invalid, -1))
         {
             //    Log.Error("Found no place for Pawns to defend " + this, false);
             invalid = IntVec3.Invalid;
         }
         LordJob_PawnsDefendShip lordJob = new LordJob_PawnsDefendShip(this.parent, this.parent.Faction, 21f, invalid);
         this.lord = LordMaker.MakeNewLord(OfFaction, lordJob, this.parent.Map, null);
     }
     try
     {
         while (this.pointsLeft > 0f)
         {
             PawnKindDef kind;
             if (!(from def in DefDatabase <PawnKindDef> .AllDefs
                   where ((def.defaultFactionType == faction.def && def.defaultFactionType != null) || (def.defaultFactionType == null && faction.def.pawnGroupMakers.Any(pgm => pgm.options.Any(opt => opt.kind == def) && pgm.kindDef != PawnGroupKindDefOf.Trader && pgm.kindDef != PawnGroupKindDefOf.Peaceful))) && def.isFighter && def.combatPower <= this.pointsLeft
                   //where ((def.defaultFactionType == faction.def && def.defaultFactionType != null) || (!faction.def.pawnGroupMakers.All(pgm => pgm.options.Any(opt => opt.kind == def)) && def.defaultFactionType == null)) && def.isFighter && def.combatPower <= this.pointsLeft
                   select def).TryRandomElement(out kind))
             {
                 //    Log.Message(string.Format("kindDef: {0}", kind));
                 break;
             }
             IntVec3 center;
             if (!(from cell in GenAdj.CellsAdjacent8Way(this.parent)
                   where this.CanSpawnPawnAt(cell)
                   select cell).TryRandomElement(out center))
             {
                 break;
             }
             //    Log.Message(string.Format("kindDef: {0}", kind));
             PawnGenerationRequest request = new PawnGenerationRequest(kind, faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
             Pawn pawn = PawnGenerator.GeneratePawn(request);
             if (!GenPlace.TryPlaceThing(pawn, center, this.parent.Map, ThingPlaceMode.Near, null, null))
             {
                 Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
                 break;
             }
             this.lord.AddPawn(pawn);
             this.pointsLeft -= pawn.kindDef.combatPower;
         }
     }
     finally
     {
         this.pointsLeft = 0f;
     }
     SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(this.parent.Map);
 }
 // Token: 0x060029EE RID: 10734 RVA: 0x0013DA2C File Offset: 0x0013BE2C
 private void TrySpawnPawns()
 {
     if (this.pointsLeft <= 0f)
     {
         return;
     }
     if (!this.parent.Spawned)
     {
         return;
     }
     //        Log.Message(string.Format("parent Spawned: {0}", this.parent.Spawned));
     if (this.lord == null)
     {
         IntVec3 invalid;
         if (!CellFinder.TryFindRandomCellNear(this.parent.Position, this.parent.Map, 5, (IntVec3 c) => c.Standable(this.parent.Map) && this.parent.Map.reachability.CanReach(c, this.parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)), out invalid, -1))
         {
             Log.Error("Found no place for Pawns to defend " + this, false);
             invalid = IntVec3.Invalid;
         }
         LordJob_PawnsDefendShip lordJob = new LordJob_PawnsDefendShip(this.parent, this.parent.Faction, 21f, invalid);
         this.lord = LordMaker.MakeNewLord(OfFaction, lordJob, this.parent.Map, null);
     }
     try
     {
         while (this.pointsLeft > 0f)
         {
             PawnGenOption kindOption;
             PawnKindDef   kind;
             if (this.parent is Building_HiveLike_CrashedShipPart _HiveShip)
             {
                 _HiveShip.spawnablePawnKinds.TryRandomElement(out kind);
             }
             else
             if (!(from opt in PawnKinds
                   where opt.kind.combatPower <= this.pointsLeft
                   select opt).TryRandomElementByWeight((PawnGenOption x) => x.selectionWeight, out kindOption))
             {
                 if (PawnKinds.NullOrEmpty())
                 {
                     //        Log.Message(string.Format("PawnKinds.NullOrEmpty"));
                 }
                 //        Log.Message(string.Format("try spawn 2a"));
                 break;
             }
             else
             {
                 kind = kindOption.kind;
             }
             //        Log.Message(string.Format("try spawn 3"));
             IntVec3 center;
             if (!(from cell in GenAdj.CellsAdjacent8Way(this.parent)
                   where this.CanSpawnPawnAt(cell)
                   select cell).TryRandomElement(out center))
             {
                 break;
             }
             //        Log.Message(string.Format("try spawn 4"));
             PawnGenerationRequest request = new PawnGenerationRequest(kind, faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
             //        Log.Message(string.Format("try spawn 5"));
             Pawn pawn = PawnGenerator.GeneratePawn(request);
             //        Log.Message(string.Format("try spawn 6"));
             if (!GenPlace.TryPlaceThing(pawn, center, this.parent.Map, ThingPlaceMode.Near, null, null))
             {
                 //        Log.Message(string.Format("try spawn 6b"));
                 Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
                 break;
             }
             //        Log.Message(string.Format("try spawn 7"));
             this.lord.AddPawn(pawn);
             //        Log.Message(string.Format("pawn: {0} to Lord: {1}", pawn.LabelShortCap, this.lord));
             this.pointsLeft -= pawn.kindDef.combatPower;
         }
     }
     finally
     {
         //        Log.Message(string.Format("Finally {0} points left", this.pointsLeft));
         this.pointsLeft = 0f;
         //        Log.Message(string.Format("set points left to {0} ", this.pointsLeft));
     }
     SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(this.parent.Map);
 }