public static void QEE_BUildingPawnVatGrower_TryExtractProductPostfix(Building __instance, Pawn actor, bool __result) { string BUID = __instance.GetUniqueLoadID(); if (TargetGSequencer != null && __result) { Thing target = null; //Recherche et destruction du sequence de genome TX si succés TryExtractProduct for (int i = 0; i < __instance.Map.listerThings.AllThings.Count; i++) { Thing el = __instance.Map.listerThings.AllThings[i]; if (el != null && el.GetUniqueLoadID() == TargetGSequencer) { target = el; break; } } if (target != null) { //Si surrogate on va traficoter le pawnBeingGrown pour être un surrogate string source = (string)Traverse.Create(target).Field("sourceName").GetValue(); if (source.Contains("(surrogate)", StringComparison.CurrentCultureIgnoreCase)) { CompAndroidState cas = Utils.GCATPP.VatGrowerLastPawnInProgress[BUID].TryGetComp <CompAndroidState>(); if (cas != null) { Utils.initBodyAsSurrogate(Utils.GCATPP.VatGrowerLastPawnInProgress[BUID]); cas.initAsSurrogate(); Utils.setSurrogateName(Utils.GCATPP.VatGrowerLastPawnInProgress[BUID]); } } target.Destroy(); } } }
public static void Listener(ref Pawn ___pawn, ref Hediff hediff, BodyPartRecord part) { try { //Si il sagit d'une VX0 alors passation du pawn en mode surrogate if (hediff.def.defName == "ATPP_HediffVX0Chip" && (___pawn.Faction == Faction.OfPlayer || ___pawn.IsPrisoner)) { CompAndroidState cas = ___pawn.TryGetComp <CompAndroidState>(); if (cas == null || cas.isSurrogate) { return; } if (___pawn.Faction.IsPlayer && !Utils.preventVX0Thought) { //Simulation mort surrogate organic PawnDiedOrDownedThoughtsUtility.TryGiveThoughts(___pawn, null, PawnDiedOrDownedThoughtsKind.Died); Pawn spouse = ___pawn.GetSpouse(); if (spouse != null && !spouse.Dead && spouse.needs.mood != null) { MemoryThoughtHandler memories = spouse.needs.mood.thoughts.memories; memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried); memories.RemoveMemoriesOfDef(ThoughtDefOf.HoneymoonPhase); } Traverse.Create(___pawn.relations).Method("AffectBondedAnimalsOnMyDeath").GetValue(); ___pawn.health.NotifyPlayerOfKilled(null, null, null); } else { //Si pas de la faction du player alors on va changer sa faction dans simuler de mort if (!___pawn.Faction.IsPlayer) { ___pawn.SetFaction(Faction.OfPlayer, null); } } cas.initAsSurrogate(); //SKills vierges ___pawn.skills = new Pawn_SkillTracker(___pawn); ___pawn.needs = new Pawn_NeedsTracker(___pawn); //Effacement des relations ___pawn.relations = new Pawn_RelationsTracker(___pawn); //TOuts les SX sont simple minded et ont aucuns autres traits TraitDef td = DefDatabase <TraitDef> .GetNamed("SimpleMindedAndroid", false); Trait t = null; if (td != null) { t = new Trait(td); } ___pawn.story.traits.allTraits.Clear(); if (t != null) { ___pawn.story.traits.allTraits.Add(t); } Utils.notifTraitsChanged(___pawn); if (!___pawn.IsAndroidTier()) { //Reset du child et adulthood if (!Settings.keepPuppetBackstory && ___pawn.story.childhood != null) { Backstory bs = null; BackstoryDatabase.TryGetWithIdentifier("MercenaryRecruit", out bs); if (bs != null) { ___pawn.story.childhood = bs; } } ___pawn.story.adulthood = null; } //Reset incapable of Utils.ResetCachedIncapableOf(___pawn); //Définition nouveau nom ___pawn.Name = new NameTriple("", "S" + 0 + "-" + Utils.GCATPP.getNextSXID(0), ""); Utils.GCATPP.incNextSXID(0); if (!Utils.preventVX0Thought) { //Ajout du thought de PUPPET for (int i = 0; i < PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners.Count; i++) { Pawn current = PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners[i]; current.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(Utils.thoughtDefVX0Puppet, 0), null); } } if (___pawn.IsPrisoner) { if (___pawn.guest != null) { ___pawn.guest.SetGuestStatus(Faction.OfPlayer, false); } } if (___pawn.workSettings == null) { ___pawn.workSettings = new Pawn_WorkSettings(___pawn); ___pawn.workSettings.EnableAndInitializeIfNotAlreadyInitialized(); } } } catch (Exception ex) { Log.Message("[ATPP] Pawn_HealthTracker.AddHediffPostfix " + ex.Message + " " + ex.StackTrace); } }