public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks) { PsychologyPawn realInitiator = initiator as PsychologyPawn; PsychologyPawn realRecipient = recipient as PsychologyPawn; PersonalityNode topic = (from node in realInitiator.psyche.PersonalityNodes where !node.Core select node).RandomElementByWeight(node => realInitiator.psyche.GetConversationTopicWeight(node.def, realRecipient)); Hediff_Conversation initiatorHediff = (Hediff_Conversation)HediffMaker.MakeHediff(HediffDefOfPsychology.HoldingConversation, realInitiator); initiatorHediff.otherPawn = realRecipient; initiatorHediff.topic = topic.def; initiatorHediff.waveGoodbye = true; realInitiator.health.AddHediff(initiatorHediff); Hediff_Conversation recipientHediff = (Hediff_Conversation)HediffMaker.MakeHediff(HediffDefOfPsychology.HoldingConversation, realRecipient); recipientHediff.otherPawn = realInitiator; recipientHediff.topic = topic.def; recipientHediff.waveGoodbye = false; realRecipient.health.AddHediff(recipientHediff); }
public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef) { letterText = null; letterLabel = null; letterDef = null; PersonalityNode topic = (from node in PsycheHelper.Comp(initiator).Psyche.PersonalityNodes where !node.Core select node).RandomElementByWeight(node => PsycheHelper.Comp(initiator).Psyche.GetConversationTopicWeight(node.def, recipient)); string convoTopic = topic.def.conversationTopics.RandomElement(); Hediff_Conversation initiatorHediff = (Hediff_Conversation)HediffMaker.MakeHediff(HediffDefOfPsychology.HoldingConversation, initiator); initiatorHediff.otherPawn = recipient; initiatorHediff.topic = topic.def; initiatorHediff.waveGoodbye = true; initiatorHediff.convoTopic = convoTopic; initiator.health.AddHediff(initiatorHediff); Hediff_Conversation recipientHediff = (Hediff_Conversation)HediffMaker.MakeHediff(HediffDefOfPsychology.HoldingConversation, recipient); recipientHediff.otherPawn = initiator; recipientHediff.topic = topic.def; recipientHediff.waveGoodbye = false; recipientHediff.convoTopic = convoTopic; recipient.health.AddHediff(recipientHediff); }
public override void PostRemoved() { base.PostRemoved(); if (this.pawn != null && this.otherPawn != null) { if (this.pawn.Dead || this.otherPawn.Dead || !PsycheHelper.PsychologyEnabled(pawn) || !PsycheHelper.PsychologyEnabled(otherPawn)) { return; } Hediff_Conversation otherConvo = otherPawn.health.hediffSet.hediffs.Find(h => h is Hediff_Conversation && ((Hediff_Conversation)h).otherPawn == this.pawn) as Hediff_Conversation; if (otherConvo != null) { this.otherPawn.health.RemoveHediff(otherConvo); this.startedFight = otherConvo.startedFight; } string talkDesc; if (this.ageTicks < 500) { int numShortTalks = int.Parse("NumberOfShortTalks".Translate()); talkDesc = "ShortTalk" + Rand.RangeInclusive(1, numShortTalks); } else if (this.ageTicks < GenDate.TicksPerHour / 2) { int numNormalTalks = int.Parse("NumberOfNormalTalks".Translate()); talkDesc = "NormalTalk" + Rand.RangeInclusive(1, numNormalTalks); } else if (this.ageTicks < GenDate.TicksPerHour * 2.5) { int numLongTalks = int.Parse("NumberOfLongTalks".Translate()); talkDesc = "LongTalk" + Rand.RangeInclusive(1, numLongTalks); } else { int numEpicTalks = int.Parse("NumberOfEpicTalks".Translate()); talkDesc = "EpicTalk" + Rand.RangeInclusive(1, numEpicTalks); } float opinionMod; ThoughtDef def = CreateSocialThought(out opinionMod); bool mattered = TryGainThought(def, Mathf.RoundToInt(opinionMod)); InteractionDef endConversation = new InteractionDef(); endConversation.socialFightBaseChance = 0.2f * PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive) * PopulationModifier * Mathf.InverseLerp(0f, -80f, opinionMod); endConversation.defName = "EndConversation"; endConversation.label = def.label; List <RulePackDef> socialFightPacks = new List <RulePackDef>(); if (otherConvo != null && (startedFight || (mattered && this.pawn.interactions.CheckSocialFightStart(endConversation, otherPawn)))) { if (startedFight) { socialFightPacks.Add(RulePackDefOfPsychology.Sentence_SocialFightConvoRecipientStarted); } else { socialFightPacks.Add(RulePackDefOfPsychology.Sentence_SocialFightConvoInitiatorStarted); } this.startedFight = true; if (!this.waveGoodbye && otherConvo.convoLog != null && !otherConvo.startedFight) { //The main conversation hediff was the other conversation, and didn't start a fight, so we have to add the extra sentence in after the fact. Traverse.Create(otherConvo.convoLog).Field("extraSentencePacks").GetValue <List <RulePackDef> >().AddRange(socialFightPacks); } } if (this.waveGoodbye && this.pawn.Map != null) { RulePack goodbyeText = new RulePack(); FieldInfo RuleStrings = typeof(RulePack).GetField("rulesStrings", BindingFlags.Instance | BindingFlags.NonPublic); List <string> text = new List <string>(1); text.Add("r_logentry->" + talkDesc.Translate(convoTopic, pawn.Named("INITIATOR"), otherPawn.Named("RECIPIENT"))); RuleStrings.SetValue(goodbyeText, text); endConversation.logRulesInitiator = goodbyeText; FieldInfo Symbol = typeof(InteractionDef).GetField("symbol", BindingFlags.Instance | BindingFlags.NonPublic); Symbol.SetValue(endConversation, Symbol.GetValue(InteractionDefOfPsychology.EndConversation)); PlayLogEntry_InteractionConversation log = new PlayLogEntry_InteractionConversation(endConversation, pawn, this.otherPawn, socialFightPacks); Find.PlayLog.Add(log); convoLog = log; MoteMaker.MakeInteractionBubble(this.pawn, this.otherPawn, InteractionDefOf.Chitchat.interactionMote, InteractionDefOf.Chitchat.Symbol); } } }