public bool TryInteractWith(Pawn recipient, InteractionDef intDef) { if (DebugSettings.alwaysSocialFight) { intDef = InteractionDefOf.Insult; } if (pawn == recipient) { Log.Warning(pawn + " tried to interact with self, interaction=" + intDef.defName); return(false); } if (!CanInteractNowWith(recipient, intDef)) { return(false); } if (InteractedTooRecentlyToInteract()) { Log.Error(pawn + " tried to do interaction " + intDef + " to " + recipient + " only " + (Find.TickManager.TicksGame - lastInteractionTime) + " ticks since last interaction (min is " + 120 + ")."); return(false); } List <RulePackDef> list = new List <RulePackDef>(); if (intDef.initiatorThought != null) { AddInteractionThought(pawn, recipient, intDef.initiatorThought); } if (intDef.recipientThought != null && recipient.needs.mood != null) { AddInteractionThought(recipient, pawn, intDef.recipientThought); } if (intDef.initiatorXpGainSkill != null) { pawn.skills.Learn(intDef.initiatorXpGainSkill, intDef.initiatorXpGainAmount); } if (intDef.recipientXpGainSkill != null && recipient.RaceProps.Humanlike) { recipient.skills.Learn(intDef.recipientXpGainSkill, intDef.recipientXpGainAmount); } bool flag = false; if (recipient.RaceProps.Humanlike) { flag = recipient.interactions.CheckSocialFightStart(intDef, pawn); } string letterText; string letterLabel; LetterDef letterDef; LookTargets lookTargets; if (!flag) { intDef.Worker.Interacted(pawn, recipient, list, out letterText, out letterLabel, out letterDef, out lookTargets); } else { letterText = null; letterLabel = null; letterDef = null; lookTargets = null; } MoteMaker.MakeInteractionBubble(pawn, recipient, intDef.interactionMote, intDef.Symbol); lastInteractionTime = Find.TickManager.TicksGame; if (flag) { list.Add(RulePackDefOf.Sentence_SocialFightStarted); } PlayLogEntry_Interaction playLogEntry_Interaction = new PlayLogEntry_Interaction(intDef, pawn, recipient, list); Find.PlayLog.Add(playLogEntry_Interaction); if (letterDef != null) { string text = playLogEntry_Interaction.ToGameStringFromPOV(pawn); if (!letterText.NullOrEmpty()) { text = text + "\n\n" + letterText; } Find.LetterStack.ReceiveLetter(letterLabel, text, letterDef, lookTargets ?? ((LookTargets)pawn)); } return(true); }
public bool TryInteractWith(Pawn recipient, InteractionDef intDef) { if (DebugSettings.alwaysSocialFight) { intDef = InteractionDefOf.Insult; } if (this.pawn == recipient) { Log.Warning(this.pawn + " tried to interact with self, interaction=" + intDef.defName, false); return(false); } if (!this.CanInteractNowWith(recipient)) { return(false); } if (this.InteractedTooRecentlyToInteract()) { Log.Error(string.Concat(new object[] { this.pawn, " tried to do interaction ", intDef, " to ", recipient, " only ", Find.TickManager.TicksGame - this.lastInteractionTime, " ticks since last interaction (min is ", 120, ")." }), false); return(false); } List <RulePackDef> list = new List <RulePackDef>(); if (intDef.initiatorThought != null) { Pawn_InteractionsTracker.AddInteractionThought(this.pawn, recipient, intDef.initiatorThought); } if (intDef.recipientThought != null && recipient.needs.mood != null) { Pawn_InteractionsTracker.AddInteractionThought(recipient, this.pawn, intDef.recipientThought); } if (intDef.initiatorXpGainSkill != null) { this.pawn.skills.Learn(intDef.initiatorXpGainSkill, (float)intDef.initiatorXpGainAmount, false); } if (intDef.recipientXpGainSkill != null && recipient.RaceProps.Humanlike) { recipient.skills.Learn(intDef.recipientXpGainSkill, (float)intDef.recipientXpGainAmount, false); } bool flag = false; if (recipient.RaceProps.Humanlike) { flag = recipient.interactions.CheckSocialFightStart(intDef, this.pawn); } string text; string label; LetterDef letterDef; if (!flag) { intDef.Worker.Interacted(this.pawn, recipient, list, out text, out label, out letterDef); } else { text = null; label = null; letterDef = null; } MoteMaker.MakeInteractionBubble(this.pawn, recipient, intDef.interactionMote, intDef.Symbol); this.lastInteractionTime = Find.TickManager.TicksGame; if (flag) { list.Add(RulePackDefOf.Sentence_SocialFightStarted); } PlayLogEntry_Interaction playLogEntry_Interaction = new PlayLogEntry_Interaction(intDef, this.pawn, recipient, list); Find.PlayLog.Add(playLogEntry_Interaction); if (letterDef != null) { string text2 = playLogEntry_Interaction.ToGameStringFromPOV(this.pawn, false); if (!text.NullOrEmpty()) { text2 = text2 + "\n\n" + text; } Find.LetterStack.ReceiveLetter(label, text2, letterDef, this.pawn, null, null); } return(true); }
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", " "))); }