public static Pawn RandomizeInPlace(Pawn p) { int index = StartingPawnUtility.StartingPawns.IndexOf(p); Pawn pawn = StartingPawnUtility.RegenerateStartingPawnInPlace(index); if (pawn.story.WorkTagIsDisabled(WorkTags.ManualDumb) || pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { pawn = StartingPawnUtility.RegenerateStartingPawnInPlace(index); } return(pawn); }
private static Pawn RegenerateStartingPawnInPlace(int index) { Pawn pawn = StartingPawnUtility.StartingPawns[index]; PawnUtility.TryDestroyStartingColonistFamily(pawn); pawn.relations.ClearAllRelations(); PawnComponentsUtility.RemoveComponentsOnDespawned(pawn); Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); StartingPawnUtility.StartingPawns[index] = null; for (int i = 0; i < Find.GameInitData.startingPawns.Count; i++) { if (StartingPawnUtility.StartingPawns[i] != null) { PawnUtility.TryDestroyStartingColonistFamily(Find.GameInitData.startingPawns[i]); } } Pawn pawn2 = StartingPawnUtility.NewGeneratedStartingPawn(); Find.GameInitData.startingPawns[index] = pawn2; return(pawn2); }
public static Pawn RandomizeInPlace(Pawn p) { int index = StartingPawnUtility.StartingAndOptionalPawns.IndexOf(p); return(StartingPawnUtility.RegenerateStartingPawnInPlace(index)); }