private static void GenerateInitialHediffs(Pawn pawn)
        {
            int num = 0;

            while (true)
            {
                pawn.health.hediffSet.Clear();
                PawnTechHediffsGenerator.GenerateTechHediffsFor(pawn);
                if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Moving))
                {
                    break;
                }

                pawn.health.Reset();
                num++;
                if (num > 80)
                {
                    Log.Error(string.Concat("Could not generate old age injuries that allow pawn to move: ", pawn));
                    return;
                }
                if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Moving))
                {
                    break;
                }
            }
        }
        private static void GenerateInitialHediffs(Pawn pawn, PawnGenerationRequest request)
        {
            int num = 0;

            while (true)
            {
                AgeInjuryUtility.GenerateRandomOldAgeInjuries(pawn, !request.AllowDead);
                PawnTechHediffsGenerator.GeneratePartsAndImplantsFor(pawn);
                PawnAddictionHediffsGenerator.GenerateAddictionsAndTolerancesFor(pawn);
                if (request.AllowDead && pawn.Dead)
                {
                    return;
                }
                if (!request.AllowDowned && pawn.Downed)
                {
                    pawn.health.Reset();
                    num++;
                    if (num > 80)
                    {
                        break;
                    }
                    continue;
                }
                return;
            }
            Log.Warning("Could not generate old age injuries for " + pawn.ThingID + " of age " + pawn.ageTracker.AgeBiologicalYears + " that allow pawn to move after " + 80 + " tries. request=" + request);
        }
Esempio n. 3
0
        private static void GenerateInitialHediffs(Pawn pawn, PawnGenerationRequest request)
        {
            int num = 0;

            while (true)
            {
                AgeInjuryUtility.GenerateRandomOldAgeInjuries(pawn, !request.AllowDead);
                PawnTechHediffsGenerator.GenerateTechHediffsFor(pawn);
                PawnAddictionHediffsGenerator.GenerateAddictionsAndTolerancesFor(pawn);
                if (request.AllowDead && pawn.Dead)
                {
                    break;
                }
                if (request.AllowDowned || !pawn.Downed)
                {
                    break;
                }
                pawn.health.Reset();
                num++;
                if (num > 80)
                {
                    goto Block_4;
                }
            }
            goto IL_D7;
Block_4:
            Log.Warning(string.Concat(new object[]
            {
                "Could not generate old age injuries for ",
                pawn.ThingID,
                " of age ",
                pawn.ageTracker.AgeBiologicalYears,
                " that allow pawn to move after ",
                80,
                " tries. request=",
                request
            }), false);
IL_D7:
            if (!pawn.Dead && (request.Faction == null || !request.Faction.IsPlayer))
            {
                int num2 = 0;
                while (pawn.health.HasHediffsNeedingTend(false))
                {
                    num2++;
                    if (num2 > 10000)
                    {
                        Log.Error("Too many iterations.", false);
                        break;
                    }
                    TendUtility.DoTend(null, pawn, null);
                }
            }
        }
Esempio n. 4
0
 public static Thing SpawnModded(Thing newThing, IntVec3 loc, Rot4 rot)
 {
     if (!loc.InBounds())
     {
         Log.Error(string.Concat(new object[]
         {
             "Tried to spawn ",
             newThing,
             " out of bounds at ",
             loc,
             "."
         }));
         return(null);
     }
     GenSpawn.WipeExistingThings(loc, rot, newThing.def, false);
     if (newThing.def.randomizeRotationOnSpawn)
     {
         newThing.Rotation = Rot4.Random;
     }
     else
     {
         newThing.Rotation = rot;
     }
     newThing.SetPositionDirect(IntVec3.Invalid);
     newThing.Position = loc;
     newThing.SpawnSetup();
     if (newThing.stackCount == 0)
     {
         Log.Error("Spawned thing with 0 stackCount: " + newThing);
         newThing.Destroy(DestroyMode.Vanish);
         return(null);
     }
     if (newThing.def.GetType() != typeof(Thingdef_AlienRace))
     {
         return(newThing);
     }
     else
     {
         AlienPawn alienpawn2 = newThing as AlienPawn;
         alienpawn2.SpawnSetupAlien(alienpawn2);
         if (alienpawn2.TryGetComp <CompImmuneToAge>() != null)
         {
             alienpawn2.health.hediffSet.Clear();
             PawnTechHediffsGenerator.GeneratePartsAndImplantsFor(alienpawn2);
         }
         Log.Message(alienpawn2.kindDef.race.ToString());
         return(alienpawn2);
     }
 }
Esempio n. 5
0
        private static void GenerateInitialHediffs(Pawn pawn, PawnGenerationRequest request)
        {
            int num = 0;

            while (true)
            {
                AgeInjuryUtility.GenerateRandomOldAgeInjuries(pawn, !request.AllowDead);
                PawnTechHediffsGenerator.GenerateTechHediffsFor(pawn);
                if (request.AllowAddictions)
                {
                    PawnAddictionHediffsGenerator.GenerateAddictionsAndTolerancesFor(pawn);
                }
                if ((request.AllowDead && pawn.Dead) || request.AllowDowned || !pawn.Downed)
                {
                    break;
                }
                pawn.health.Reset();
                num++;
                if (num > 80)
                {
                    Log.Warning("Could not generate old age injuries for " + pawn.ThingID + " of age " + pawn.ageTracker.AgeBiologicalYears + " that allow pawn to move after " + 80 + " tries. request=" + request);
                    break;
                }
            }
            if (pawn.Dead || (request.Faction != null && request.Faction.IsPlayer))
            {
                return;
            }
            int num2 = 0;

            while (true)
            {
                if (pawn.health.HasHediffsNeedingTend())
                {
                    num2++;
                    if (num2 > 10000)
                    {
                        break;
                    }
                    TendUtility.DoTend(null, pawn, null);
                    continue;
                }
                return;
            }
            Log.Error("Too many iterations.");
        }
Esempio n. 6
0
        private static void GenerateInitialHediffs(Pawn pawn, PawnGenerationRequest request)
        {
            int num = 0;

            while (true)
            {
                ProTraverses.travGenerateRandomOldAgeInjuries.GetValue();
                PawnTechHediffsGenerator.GeneratePartsAndImplantsFor(pawn);
                PawnAddictionHediffsGenerator.GenerateAddictionsAndTolerancesFor(pawn);
                if (request.AllowDead && pawn.Dead)
                {
                    break;
                }
                if (request.AllowDowned || !pawn.Downed)
                {
                    return;
                }
                pawn.health.Reset();
                num++;
                if (num > 80)
                {
                    goto Block_4;
                }
            }
            return;

Block_4:
            Log.Warning(string.Concat(new object[]
            {
                "Could not generate old age injuries for ",
                pawn.ThingID,
                " of age ",
                pawn.ageTracker.AgeBiologicalYears,
                " that allow pawn to move after ",
                80,
                " tries. request=",
                request
            }));
        }
Esempio n. 7
0
        public void GenerateHediffsAndImplants(ChaosFollowerPawnKindDef pdef)
        {
            if (pdef.AdditionalImplantCount.min > 0)
            {
                int num = Rand.RangeInclusive(pdef.AdditionalImplantCount.min, pdef.AdditionalImplantCount.max);
                for (int i = 0; i < num; i++)
                {
                    PawnTechHediffsGenerator.GeneratePartsAndImplantsFor(this.pawn);
                }
            }
            if (!pdef.DisallowedStartingHediffs.NullOrEmpty())
            {
                foreach (HediffDef def in pdef.DisallowedStartingHediffs)
                {
                    this.pawn.health.hediffSet.hediffs.RemoveAll(x => x.def == def);
                }
            }

            if (!pdef.ForcedStartingHediffs.NullOrEmpty())
            {
                foreach (HediffDef hediffDef in pdef.ForcedStartingHediffs)
                {
                    Hediff current = HediffMaker.MakeHediff(hediffDef, this.pawn, null);
                    this.pawn.health.AddHediff(current);
                }
            }

            if (!pdef.ForcedStartingImplantRecipes.NullOrEmpty() && !pdef.ForcedStartingImplantRecipes.NullOrEmpty())
            {
                foreach (RecipeDef recipeDef in pdef.ForcedStartingImplantRecipes)
                {
                    if (!recipeDef.targetsBodyPart || recipeDef.Worker.GetPartsToApplyOn(pawn, recipeDef).Any <BodyPartRecord>())
                    {
                        recipeDef.Worker.ApplyOnPawn(pawn, recipeDef.Worker.GetPartsToApplyOn(pawn, recipeDef).Any <BodyPartRecord>() ? recipeDef.Worker.GetPartsToApplyOn(pawn, recipeDef).RandomElement <BodyPartRecord>() : null, null, new List <Thing>());
                    }
                }
            }
        }