public static bool Prefix(int index, ref Pawn __result) { Scenario scenario = Find.Scenario; if (scenario != null) { if (scenario.AllParts.Any(x => x is ScenPart_ConfigPage_ConfigureStartingPawnsSpecific)) { Pawn pawn = Find.GameInitData.startingAndOptionalPawns[index]; PawnKindDef kindDef = pawn.kindDef; PawnUtility.TryDestroyStartingColonistFamily(pawn); pawn.relations.ClearAllRelations(); PawnComponentsUtility.RemoveComponentsOnDespawned(pawn); Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); Find.GameInitData.startingAndOptionalPawns[index] = null; for (int i = 0; i < Find.GameInitData.startingAndOptionalPawns.Count; i++) { if (Find.GameInitData.startingAndOptionalPawns[i] != null) { PawnUtility.TryDestroyStartingColonistFamily(Find.GameInitData.startingAndOptionalPawns[i]); } } __result = SpecificStartingPawnUtility.NewGeneratedStartingPawn(kindDef); Find.GameInitData.startingAndOptionalPawns[index] = __result; return(false); } } return(true); }
private static Pawn RegenerateStartingPawnInPlace(int index) { Pawn pawn = Page_ConfigureStartingSlaves.StartingPawns[index]; PawnUtility.TryDestroyStartingColonistFamily(pawn); pawn.relations.ClearAllRelations(); Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); Page_ConfigureStartingSlaves.StartingPawns[index] = null; for (int i = 0; i < Find.GameInitData.startingPawns.Count; i++) { if (Page_ConfigureStartingSlaves.StartingPawns[i] != null) { PawnUtility.TryDestroyStartingColonistFamily(Find.GameInitData.startingPawns[i]); } } Pawn pawn2 = ElderThingFaction.ScenPart_ConfigPage_ConfigureStartingSlaves.NewGeneratedStartingSlave(); Find.GameInitData.startingPawns[index] = pawn2; return(pawn2); }
private static Pawn RegenerateStartingPawnInPlace(int index) { Pawn pawn = StartingAndOptionalPawns[index]; PawnUtility.TryDestroyStartingColonistFamily(pawn); pawn.relations.ClearAllRelations(); PawnComponentsUtility.RemoveComponentsOnDespawned(pawn); Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); StartingAndOptionalPawns[index] = null; for (int i = 0; i < StartingAndOptionalPawns.Count; i++) { if (StartingAndOptionalPawns[i] != null) { PawnUtility.TryDestroyStartingColonistFamily(StartingAndOptionalPawns[i]); } } Pawn pawn2 = NewGeneratedStartingPawn(); StartingAndOptionalPawns[index] = pawn2; return(pawn2); }