static void Postfix(Pawn_PlayerSettings __instance, bool __result) { if (__instance.master != null && Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(__instance.master).owning != null) { __result = true; } }
// Token: 0x06000005 RID: 5 RVA: 0x000020B4 File Offset: 0x000002B4 public override void PawnDied(Corpse corpse) { float value = (float)corpse.InnerPawn.ageTracker.AgeBiologicalYears; float value2 = (float)corpse.InnerPawn.ageTracker.AgeChronologicalYears; Name name = corpse.InnerPawn.Name; Pawn_PlayerSettings playerSettings = corpse.InnerPawn.playerSettings; Pawn_TrainingTracker training = corpse.InnerPawn.training; Pawn_HealthTracker health = corpse.InnerPawn.health; Pawn_RecordsTracker records = corpse.InnerPawn.records; Pawn_RelationsTracker relations = corpse.InnerPawn.relations; Pawn_SkillTracker skills = corpse.InnerPawn.skills; Faction faction = corpse.InnerPawn.Faction; Comp_TimeLord timeLord = corpse.InnerPawn.TryGetComp <Comp_TimeLord>(); if (timeLord != null) { if (timeLord.TimesRegenerated < 13) { int regens = timeLord.TimesRegenerated; regens++; Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(corpse.InnerPawn.kindDef, faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 0f, false, false, false, false, false, false, false, false, 0, null, 1, null, null, null)); pawn.TryGetComp <Comp_TimeLord>().TimesRegenerated = regens; GenSpawn.Spawn(pawn, corpse.Position, corpse.Map, Rot4.Random); pawn.Name = name; pawn.relations = relations; pawn.training = training; pawn.records = records; pawn.skills = skills; pawn.playerSettings = playerSettings; corpse.Destroy(0); } } }
static bool ResetMedicalCare(Pawn_PlayerSettings __instance) { if ((typeof(Pawn_PlayerSettings).GetField("pawn", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(__instance)) is Droid) { return(false); } return(true); }
private void trainPawnDone(String def) { PawnGenerationRequest request = new PawnGenerationRequest(DefDatabase <PawnKindDef> .GetNamed(def, true), Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null); Pawn item = PawnGenerator.GeneratePawn(request); Pawn_StoryTracker ps = item.story; ps.childhood = null; ps.adulthood = null; ps.traits.allTraits = new List <Trait>(); ps.traits.GainTrait(new Trait(DefDatabase <TraitDef> .GetNamed("ra2_MakeSoldier", true))); ps.traits.GainTrait(new Trait(TraitDefOf.Psychopath)); Pawn_WorkSettings pws = item.workSettings; pws.DisableAll(); Pawn_PlayerSettings pps = item.playerSettings; pps.hostilityResponse = HostilityResponseMode.Attack; NameTriple triple = NameTriple.FromString(item.kindDef.label.Replace(" ", "")); item.Name = triple; item.inventory.DestroyAll(); YuriSoldierMakeUp.tryMakeUp(item); SoundStarter.PlayOneShotOnCamera(DefDatabase <SoundDef> .GetNamed(this.parent.def.defName + "_UnitReady", true)); IntVec3 loc = CellFinder.RandomClosewalkCellNear(this.parent.Position, this.parent.Map, 3, null); Pawn pp; if (this.trainPawns[0] != "ra2_AlliedTanya") { pp = (Pawn)(GenSpawn.Spawn(item, loc, this.parent.Map, WipeMode.Vanish)); } else { // bool flag = true; if (getAllTanya().Count > 0) { foreach (Pawn tanya in getAllTanya()) { tanya.Destroy(DestroyMode.Vanish); } } pp = (Pawn)(GenSpawn.Spawn(getTanya(), loc, this.parent.Map, WipeMode.Vanish)); } this.trainPawns.Remove(this.trainPawns[0]); this.ticks = 0; }
public static void ResetPPSMedicalCare(Pawn_PlayerSettings pps, Pawn pawn) { if (pps == null || pawn == null) { return; } Config config = UtilityWorldObjectManager.GetUtilityWorldObject <Config>(); // needed for world creation, loading if (config == null || Find.FactionManager == null) { pps.medCare = MedicalCareCategory.HerbalOrWorse; if (pawn.IsColonist && !pawn.IsPrisoner && !pawn.RaceProps.Animal) { pps.medCare = MedicalCareCategory.Best; } return; } if (pawn.RaceProps.Humanlike) { if (pawn.Faction != null && pawn.Faction.IsPlayer) { if (pawn.IsPrisoner) { pps.medCare = config.care_PrisonerHuman; } else { pps.medCare = config.care_PlayerHuman; } } else if (pawn.Faction == null || !pawn.Faction.HostileTo(Faction.OfPlayer)) { pps.medCare = config.care_AllyHuman; } else { pps.medCare = config.care_EnemyHuman; } } else { if (pawn.Faction != null && pawn.Faction.IsPlayer) { pps.medCare = config.care_PlayerAnimal; } else if (pawn.Faction == null || !pawn.Faction.HostileTo(Faction.OfPlayer)) { pps.medCare = config.care_AllyAnimal; } else { pps.medCare = config.care_EnemyAnimal; } } }
public static void Postfix(Pawn_PlayerSettings __instance, Pawn pawn) { // If the pawn is an animal, automatically assign them to follow when drafted/doing fieldwork if (TinyTweaksSettings.autoAssignAnimalFollowSettings && pawn.RaceProps.Animal) { __instance.followDrafted = true; __instance.followFieldwork = true; } }
public static void NotifyAreaRemovedPostfix(Pawn_PlayerSettings __instance, Area area) { AreaExt pawnArea = FieldInfos.areaAllowedInt.GetValue(__instance) as AreaExt; if (pawnArea != null && pawnArea.Empty) { FieldInfos.areaAllowedInt.SetValue(__instance, null); } }
static bool Postfix(bool __result, Pawn_PlayerSettings __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (!__result && pawn != null && pawn.IsPrisonerOfColony) { return(true); } return(__result); }
public static void Postfix(Pawn_PlayerSettings __instance, Pawn ___pawn) { if (Scribe.mode == LoadSaveMode.LoadingVars) { return; } Pawn pawn = ___pawn; SurgeryUnlimitedGameComponent comp = SurgeryUnlimitedGameComponent.Get(); comp?.Set(pawn, comp.surgeryUnlimitedDefault); }
public static bool set_Master(Pawn_PlayerSettings __instance, Pawn value) { if (__instance.master == value) { return(false); } if (petsInit == false) { RebuildPetsDictionary(); } bool flag = ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(__instance.pawn); if (__instance.master != null) { if (pets.TryGetValue(__instance.master, out List <Pawn> pawnList2)) { pawnList2.Remove(__instance.pawn); } } __instance.master = null; if (!__instance.pawn.training.HasLearned(TrainableDefOf.Obedience)) { Log.ErrorOnce("Attempted to set master for non-obedient pawn", 73908573); return(false); } __instance.master = value; if (value != null) { if (!pets.TryGetValue(value, out List <Pawn> pawnList)) { pawnList = new List <Pawn>(); lock (pets) { pets[value] = pawnList; } } pawnList.Add(__instance.pawn); } if (__instance.pawn.Spawned && (flag || ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(__instance.pawn))) { __instance.pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); } return(false); }
public static void Pawn_PlayerSettings(this Pawn_PlayerSettings pps, Pawn pawn) { pps.SetFieldViaReflection("pawn", pawn); if (Current.ProgramState == ProgramState.Playing) { pps.joinTick = Find.TickManager.TicksGame; } else { pps.joinTick = 0; } if (pawn.Spawned && !pawn.Dead) { ResetPPSMedicalCare(pps, pawn); } }
private static void UpdateAnimalRelease(Pawn pawn, Pawn_PlayerSettings __instance) { __instance.animalsReleased = !__instance.animalsReleased; if (__instance.animalsReleased) { foreach (Pawn current in PawnUtility.SpawnedMasteredPawns(pawn)) { if (current.caller != null) { current.caller.Notify_Released(); } if (current.CurJob.def != GUC_JobDefOf.Mounted) { current.jobs.EndCurrentJob(JobCondition.InterruptForced, true); } } } }
//Almost literal copy of vanilla code. Only added a check around the EndCurrentJob call static IEnumerable <Gizmo> helpIterator(Pawn_PlayerSettings __instance) { Pawn pawn = __instance.pawn; if (pawn.Drafted) { if (PawnUtility.SpawnedMasteredPawns(pawn).Any((Pawn p) => p.training.HasLearned(TrainableDefOf.Release))) { yield return(new Command_Toggle { defaultLabel = "CommandReleaseAnimalsLabel".Translate(), defaultDesc = "CommandReleaseAnimalsDesc".Translate(), icon = TexCommand.ReleaseAnimals, hotKey = KeyBindingDefOf.Misc7, isActive = (() => __instance.animalsReleased), toggleAction = () => UpdateAnimalRelease(pawn, __instance) }); } } }
//Almost literal copy of vanilla code. Only added a check around the EndCurrentJob call static IEnumerable <Gizmo> helpIterator(Pawn_PlayerSettings __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (pawn.Drafted) { if (PawnUtility.SpawnedMasteredPawns(pawn).Any((Pawn p) => p.training.IsCompleted(TrainableDefOf.Release))) { yield return(new Command_Toggle { defaultLabel = "CommandReleaseAnimalsLabel".Translate(), defaultDesc = "CommandReleaseAnimalsDesc".Translate(), icon = TexCommand.ReleaseAnimals, hotKey = KeyBindingDefOf.Misc7, isActive = (() => __instance.animalsReleased), toggleAction = delegate { __instance.animalsReleased = !__instance.animalsReleased; if (__instance.animalsReleased) { foreach (Pawn current in PawnUtility.SpawnedMasteredPawns(pawn)) { if (current.caller != null) { current.caller.Notify_Released(); } if (current.CurJob.def != GUC_JobDefOf.Mounted) { current.jobs.EndCurrentJob(JobCondition.InterruptForced, true); } } } } }); } } }
public static void Notify_FactionChanged(Pawn_PlayerSettings pps) { ResetPPSMedicalCare(pps, pps.GetFieldViaReflection <Pawn>("pawn")); }
//purpose: Make sure animals don't throw of their rider when released. static bool Prefix(Pawn_PlayerSettings __instance, ref IEnumerable <Gizmo> __result) { __result = helpIterator(__instance); return(false); }
public static void Postfix(Pawn_PlayerSettings __instance, ref bool __result) { var pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); __result |= pawn.IsGuest(); }
public static void Notify_MadePrisoner(Pawn_PlayerSettings pps) { Notify_FactionChanged(pps); }