// Token: 0x06000043 RID: 67 RVA: 0x0000419C File Offset: 0x0000239C public static bool CompatPatch_InteractionsTrackerTick(ref Pawn_InteractionsTracker __instance) { Pawn pawn = HarmonyPatches.Pawn_InteractionsTracker_GetPawn(__instance); bool flag = pawn.def.HasModExtension <MechanicalPawnProperties>(); return(!flag); }
static void Postfix(Pawn_InteractionsTracker __instance, Pawn recipient, InteractionDef intDef) { // pawn is a private field, so we have to use reflection to access it. Pawn pawn = AccessTools.Field(__instance.GetType(), "pawn").GetValue(__instance) as Pawn; // bail if one of the pawns doesn't have any skills. if (pawn.skills == null || recipient.skills == null) { return; } if (pawn?.story?.traits?.HasTrait(GMT_DefOf.GMT_Teacher) ?? false) { // Make 2 attempts to teach a skill. Broad base of skills => better chance of teaching. for (int i = 0; i < 2; ++i) { SkillDef random = DefDatabase <SkillDef> .AllDefsListForReading.RandomElement <SkillDef>(); int diff = pawn.skills.GetSkill(random).Level - recipient.skills.GetSkill(random).Level; if (diff > 0) { recipient.skills.GetSkill(random).Learn(diff * GMT_Teacher_Helper.teacher_xp_per_level_difference * GMT_Teacher_Helper.teaching_factors.TryGetValue(intDef, 1.0f)); break; } } } }
public static void Postfix(Pawn_InteractionsTracker __instance, Pawn recipient, ref bool __result) { Traverse traverse = Traverse.Create(__instance); Pawn value3 = traverse.Field("pawn").GetValue <Pawn>(); if (recipient.kindDef.defName.StartsWith("ra2") || value3.kindDef.defName.StartsWith("ra2")) { //Log.Warning(recipient.kindDef.defName + "/" + value3.kindDef.defName + "/" + __result); __result = false; } }
public static bool Replacement(Pawn_InteractionsTracker __instance, ref bool __result) { // Added var pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (!IsInteractable(pawn)) { __result = false; return(false); } var workingList = Traverse.Create(__instance).Field("workingList").GetValue <List <Pawn> >(); // Had to add if (InteractedTooRecentlyToInteract(__instance)) // Changed to own { __result = false; return(false); } // BASE if (!InteractionUtility.CanInitiateRandomInteraction(pawn)) { __result = false; return(false); } var collection = pawn.MapHeld.mapPawns.AllPawnsSpawned.Where(IsInteractable); // Added workingList.Clear(); workingList.AddRange(collection); workingList.Shuffle <Pawn>(); List <InteractionDef> allDefsListForReading = DefDatabase <InteractionDef> .AllDefsListForReading; for (int i = 0; i < workingList.Count; i++) { Pawn p = workingList[i]; if (p != pawn && CanInteractNowWith(pawn, p) && InteractionUtility.CanReceiveRandomInteraction(p) && !pawn.HostileTo(p)) { InteractionDef intDef; if ( allDefsListForReading.TryRandomElementByWeight( (InteractionDef x) => x.Worker.RandomSelectionWeight(pawn, p), out intDef)) { if (__instance.TryInteractWith(p, intDef)) { __result = true; return(false); } Log.Error(pawn + " failed to interact with " + p); } } } __result = false; return(false); }
public static bool Prefix(Pawn_InteractionsTracker __instance, Pawn recipient, ref bool __result) { var tv = Traverse.Create(__instance); var pawn = tv.Field("pawn").GetValue <Pawn>(); if (!pawn.IsWarframe() && !recipient.IsWarframe()) { return(true); } __result = true; return(false); }
public static bool Replacement(Pawn_InteractionsTracker __instance, ref bool __result, Pawn ___pawn, List <Pawn> ___workingList, int ___lastInteractionTime) { // Added if (!IsInteractable(___pawn)) { __result = false; return(false); } if (InteractedTooRecentlyToInteract(___lastInteractionTime)) // Changed to own { __result = false; return(false); } // BASE if (!InteractionUtility.CanInitiateRandomInteraction(___pawn)) { __result = false; return(false); } var collection = ___pawn.MapHeld.mapPawns.AllPawnsSpawned.Where(IsInteractable); // Added ___workingList.Clear(); ___workingList.AddRange(collection); ___workingList.Shuffle(); List <InteractionDef> allDefsListForReading = DefDatabase <InteractionDef> .AllDefsListForReading; foreach (var p in ___workingList) { if (p != ___pawn && CanInteractNowWith(___pawn, p) && InteractionUtility.CanReceiveRandomInteraction(p) && !___pawn.HostileTo(p)) { var p1 = p; if ( allDefsListForReading.TryRandomElementByWeight( x => x.Worker.RandomSelectionWeight(___pawn, p1), out var intDef)) { if (__instance.TryInteractWith(p, intDef)) { __result = true; return(false); } Log.Warning($"{___pawn} failed to interact with {p}."); } } } __result = false; return(false); }
// Token: 0x06000044 RID: 68 RVA: 0x000041CC File Offset: 0x000023CC public static bool CompatPatch_CanInteractNowWith(ref Pawn_InteractionsTracker __instance, ref bool __result, ref Pawn recipient) { bool flag = recipient.def.HasModExtension <MechanicalPawnProperties>(); bool result; if (flag) { __result = false; result = false; } else { result = true; } return(result); }
// Token: 0x06000045 RID: 69 RVA: 0x000041F8 File Offset: 0x000023F8 public static bool CompatPatch_SocialFightChance(ref Pawn_InteractionsTracker __instance, ref float __result, ref InteractionDef interaction, ref Pawn initiator) { Pawn pawn = HarmonyPatches.Pawn_InteractionsTracker_GetPawn(__instance); bool flag = pawn.def.HasModExtension <MechanicalPawnProperties>() || initiator.def.HasModExtension <MechanicalPawnProperties>(); bool result; if (flag) { __result = 0f; result = false; } else { result = true; } return(result); }
public static bool TryInteractRandomly(Pawn_InteractionsTracker __instance, ref bool __result) { if (__instance.InteractedTooRecentlyToInteract()) { __result = false; return(false); } if (!InteractionUtility.CanInitiateRandomInteraction(pawn(__instance))) { __result = false; return(false); } List <Pawn> collection = pawn(__instance).Map.mapPawns.SpawnedPawnsInFaction(pawn(__instance).Faction); //Pawn_InteractionsTracker.workingList.Clear(); List <Pawn> workingList = getWorkingList(); //ADDED workingList.AddRange(collection); //REPLACED workingList with local workingList.Shuffle(); //REPLACED workingList with local List <InteractionDef> allDefsListForReading = DefDatabase <InteractionDef> .AllDefsListForReading; for (int i = 0; i < workingList.Count; i++) //REPLACED workingList with local { Pawn p = workingList[i]; //REPLACED workingList with local InteractionDef intDef; if (p != pawn(__instance) && __instance.CanInteractNowWith(p, null) && InteractionUtility.CanReceiveRandomInteraction(p) && !pawn(__instance).HostileTo(p) && allDefsListForReading.TryRandomElementByWeight(delegate(InteractionDef x) { if (!__instance.CanInteractNowWith(p, x)) { return(0f); } return(x.Worker.RandomSelectionWeight(pawn(__instance), p)); }, out intDef)) { if (__instance.TryInteractWith(p, intDef)) { workingList.Clear(); //REPLACED workingList with local __result = true; return(false); } Log.Error(pawn(__instance) + " failed to interact with " + p, false); } } //Pawn_InteractionsTracker.workingList.Clear(); __result = false; return(false); }
static void Postfix(Pawn_InteractionsTracker __instance, Pawn recipient, InteractionDef intDef) { // pawn is a private field, so we have to use reflection to access it. Pawn pawn = AccessTools.Field(__instance.GetType(), "pawn").GetValue(__instance) as Pawn; if (pawn?.story?.traits?.HasTrait(GMT_DefOf.GMT_Boring) ?? false) { // Boring pawns don't find each other boring if (recipient?.story?.traits?.HasTrait(GMT_DefOf.GMT_Boring) ?? false) { return; } Hediff hediff = HediffMaker.MakeHediff(GMT_DefOf.GMT_Hediff_Bored, recipient); hediff.Severity = GMT_Boring_Helper.boring_severity * GMT_Boring_Helper.bored_factors.TryGetValue(intDef, 1.0f); recipient.health.AddHediff(hediff); } }
public static void TryInteractWith_Postfix(Pawn_InteractionsTracker __instance, bool __result, Pawn recipient) { if (__instance == null) { return; } // FieldInfo PawnFieldInfo = // typeof(Pawn_InteractionsTracker).GetField("pawn", BindingFlags.NonPublic | BindingFlags.Instance); //PawnFieldInfo?.GetValue(__instance); Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_InteractionsTracker), "pawn").GetValue(__instance); if (pawn == null || recipient == null) { return; } if (__result) { if (pawn.GetCompFace(out CompFace compFace)) { if (compFace.Props.canRotateHead) { if (compFace.HeadRotator != null && !compFace.IsChild) { compFace.HeadRotator.LookAtPawn(recipient); } } } if (recipient.GetCompFace(out CompFace recipientFace)) { if (recipientFace.Props.canRotateHead) { if (recipientFace.HeadRotator != null && !recipientFace.IsChild) { recipientFace.HeadRotator.LookAtPawn(pawn); } } } } }
// Added to change InteractIntervalAbsoluteMin public static bool InteractedTooRecentlyToInteract(Pawn_InteractionsTracker tracker) { var lastInteractionTime = Traverse.Create(tracker).Field("lastInteractionTime").GetValue <int>(); return(Find.TickManager.TicksGame < lastInteractionTime + GuestUtility.InteractIntervalAbsoluteMin); }
// Token: 0x06000052 RID: 82 RVA: 0x00004580 File Offset: 0x00002780 public static Pawn Pawn_InteractionsTracker_GetPawn(Pawn_InteractionsTracker instance) { return((Pawn)HarmonyPatches.int_Pawn_InteractionsTracker_GetPawn.GetValue(instance)); }
public static string InteractWith(Pawn pawn, Pawn recipient, InteractionDef interaction) { if (pawn == recipient) { return(null); } var extraSentencePacks = new List <RulePackDef>(); if (interaction.initiatorThought != null) { Pawn_InteractionsTracker.AddInteractionThought(pawn, recipient, interaction.initiatorThought); } if (interaction.recipientThought != null && recipient.needs.mood != null) { Pawn_InteractionsTracker.AddInteractionThought(recipient, pawn, interaction.recipientThought); } bool isSocialFight = recipient.RaceProps.Humanlike && recipient.interactions.CheckSocialFightStart(interaction, pawn); string letterText = null; string letterLabel = null; LetterDef letterDef = null; LookTargets lookTargets = null; if (!isSocialFight) { interaction.Worker.Interacted(pawn, recipient, extraSentencePacks, out letterText, out letterLabel, out letterDef, out lookTargets); } MoteMaker.MakeInteractionBubble( pawn, recipient, interaction.interactionMote, interaction.GetSymbol(pawn.Faction, pawn.Ideo), interaction.GetSymbolColor(pawn.Faction) ); if (isSocialFight) { extraSentencePacks.Add(RulePackDefOf.Sentence_SocialFightStarted); } var entry = new PlayLogEntry_Interaction(interaction, pawn, recipient, extraSentencePacks); Find.PlayLog.Add(entry); string text = RichTextHelper.StripTags(entry.ToGameStringFromPOV(pawn)); if (letterDef == null) { return(MakeFirstPerson(pawn.LabelShort, text)); } if (!letterText.NullOrEmpty()) { text = text + "\n\n" + RichTextHelper.StripTags(letterText); } Find.LetterStack.ReceiveLetter(letterLabel, text, letterDef, lookTargets ?? pawn); return(MakeFirstPerson(pawn.LabelShort, text.Replace("\n\n", " "))); }