Example #1
0
        public void StartSocialFight(Pawn otherPawn)
        {
            if (PawnUtility.ShouldSendNotificationAbout(this.pawn) || PawnUtility.ShouldSendNotificationAbout(otherPawn))
            {
                Thought thought = default(Thought);
                if (!InteractionUtility.TryGetRandomSocialFightProvokingThought(this.pawn, otherPawn, out thought))
                {
                    Log.Warning("Pawn " + this.pawn + " started a social fight with " + otherPawn + ", but he has no negative opinion thoughts towards " + otherPawn + ".");
                }
                else
                {
                    Messages.Message("MessageSocialFight".Translate(this.pawn.LabelShort, otherPawn.LabelShort, thought.LabelCapSocial), this.pawn, MessageTypeDefOf.ThreatSmall);
                }
            }
            MentalStateHandler mentalStateHandler = this.pawn.mindState.mentalStateHandler;
            MentalStateDef     socialFighting     = MentalStateDefOf.SocialFighting;

            mentalStateHandler.TryStartMentalState(socialFighting, null, false, false, otherPawn);
            MentalStateHandler mentalStateHandler2 = otherPawn.mindState.mentalStateHandler;

            socialFighting = MentalStateDefOf.SocialFighting;
            Pawn otherPawn2 = this.pawn;

            mentalStateHandler2.TryStartMentalState(socialFighting, null, false, false, otherPawn2);
            TaleRecorder.RecordTale(TaleDefOf.SocialFight, this.pawn, otherPawn);
        }
        public float MoodOffsetOfGroup(Thought group)
        {
            this.GetMoodThoughts(group, ThoughtHandler.tmpThoughts);
            float result;

            if (!ThoughtHandler.tmpThoughts.Any <Thought>())
            {
                result = 0f;
            }
            else
            {
                float num  = 0f;
                float num2 = 1f;
                float num3 = 0f;
                for (int i = 0; i < ThoughtHandler.tmpThoughts.Count; i++)
                {
                    Thought thought = ThoughtHandler.tmpThoughts[i];
                    num  += thought.MoodOffset();
                    num3 += num2;
                    num2 *= thought.def.stackedEffectMultiplier;
                }
                float num4 = num / (float)ThoughtHandler.tmpThoughts.Count;
                ThoughtHandler.tmpThoughts.Clear();
                result = num4 * num3;
            }
            return(result);
        }
Example #3
0
        public static Thought MakeThought(ThoughtDef def)
        {
            Thought thought = (Thought)Activator.CreateInstance(def.ThoughtClass);

            thought.def = def;
            thought.Init();
            return(thought);
        }
        public static Thought MakeThought(ThoughtDef def)
        {
            Thought obj = (Thought)Activator.CreateInstance(def.ThoughtClass);

            obj.def = def;
            obj.Init();
            return(obj);
        }
        // Token: 0x06000015 RID: 21 RVA: 0x0000222C File Offset: 0x0000042C
        public virtual void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks)
        {
            Thought thought = this.RandomBreakupReason(initiator, recipient);
            bool    flag    = initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient);

            if (flag)
            {
                initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Spouse, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExSpouse, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.DivorcedMe, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, initiator);
            }
            else
            {
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Lover, recipient);
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Fiance, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExLover, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.BrokeUpWithMe, initiator);
            }
            bool flag2 = initiator.ownership.OwnedBed != null && initiator.ownership.OwnedBed == recipient.ownership.OwnedBed;

            if (flag2)
            {
                Pawn pawn = (Rand.Value >= 0.5f) ? recipient : initiator;
                pawn.ownership.UnclaimBed();
            }
            TaleRecorder.RecordTale(TaleDefOf.Breakup, new object[]
            {
                initiator,
                recipient
            });
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("LetterNoLongerLovers".Translate(new object[]
            {
                initiator.LabelShort,
                recipient.LabelShort
            }));
            bool flag3 = thought != null;

            if (flag3)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("FinalStraw".Translate(new object[]
                {
                    thought.CurStage.label
                }));
            }
            bool flag4 = PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient);

            if (flag4)
            {
                Find.LetterStack.ReceiveLetter(Translator.Translate("LetterLabelBreakup"), stringBuilder.ToString(), LetterDefOf.NegativeEvent, initiator, null);
            }
        }
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
        {
            Thought thought = this.RandomBreakupReason(initiator, recipient);

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Spouse, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExSpouse, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.DivorcedMe, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, initiator);
            }
            else
            {
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Lover, recipient);
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Fiance, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExLover, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.BrokeUpWithMe, initiator);
            }
            if (initiator.ownership.OwnedBed != null && initiator.ownership.OwnedBed == recipient.ownership.OwnedBed)
            {
                Pawn pawn = (Rand.Value >= 0.5f) ? recipient : initiator;
                pawn.ownership.UnclaimBed();
            }
            TaleRecorder.RecordTale(TaleDefOf.Breakup, new object[]
            {
                initiator,
                recipient
            });
            if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("LetterNoLongerLovers".Translate(new object[]
                {
                    initiator.LabelShort,
                    recipient.LabelShort
                }));
                if (thought != null)
                {
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("FinalStraw".Translate(new object[]
                    {
                        thought.CurStage.label.CapitalizeFirst()
                    }));
                }
                letterLabel = "LetterLabelBreakup".Translate();
                letterText  = stringBuilder.ToString().TrimEndNewlines();
                letterDef   = LetterDefOf.NegativeEvent;
            }
            else
            {
                letterLabel = null;
                letterText  = null;
                letterDef   = null;
            }
        }
        public override bool GroupsWith(Thought other)
        {
            Thought_SituationalSocial thought_SituationalSocial = other as Thought_SituationalSocial;

            if (thought_SituationalSocial == null)
            {
                return(false);
            }
            return(base.GroupsWith(other) && this.otherPawn == thought_SituationalSocial.otherPawn);
        }
Example #8
0
        public override bool GroupsWith(Thought other)
        {
            Thought_Memory thought_Memory = other as Thought_Memory;

            if (thought_Memory == null)
            {
                return(false);
            }
            return(base.GroupsWith(other) && (otherPawn == thought_Memory.otherPawn || LabelCap == thought_Memory.LabelCap));
        }
Example #9
0
        public override bool GroupsWith(Thought other)
        {
            Thought_MemorySocial thought_MemorySocial = other as Thought_MemorySocial;

            if (thought_MemorySocial == null)
            {
                return(false);
            }
            return(base.GroupsWith(other) && otherPawn == thought_MemorySocial.otherPawn);
        }
 public void GetMoodThoughts(Thought group, List <Thought> outThoughts)
 {
     this.GetAllMoodThoughts(outThoughts);
     for (int i = outThoughts.Count - 1; i >= 0; i--)
     {
         if (!outThoughts[i].GroupsWith(group))
         {
             outThoughts.RemoveAt(i);
         }
     }
 }
 public void GetMoodThoughts(Thought group, List <Thought> outThoughts)
 {
     GetAllMoodThoughts(outThoughts);
     for (int num = outThoughts.Count - 1; num >= 0; num--)
     {
         if (!outThoughts[num].GroupsWith(group))
         {
             outThoughts.RemoveAt(num);
         }
     }
 }
Example #12
0
        public override bool GroupsWith(Thought other)
        {
            Thought_PsychicHarmonizer thought_PsychicHarmonizer = other as Thought_PsychicHarmonizer;

            if (thought_PsychicHarmonizer == null)
            {
                return(false);
            }
            if (base.GroupsWith(other))
            {
                return(thought_PsychicHarmonizer.harmonizer == harmonizer);
            }
            return(false);
        }
Example #13
0
        public static Thought GetLeadingThoughtInGroup(List <Thought> thoughtsInGroup)
        {
            Thought result = null;
            int     num    = -1;

            for (int i = 0; i < thoughtsInGroup.Count; i++)
            {
                if (thoughtsInGroup[i].CurStageIndex > num)
                {
                    num    = thoughtsInGroup[i].CurStageIndex;
                    result = thoughtsInGroup[i];
                }
            }
            return(result);
        }
 public void GetDistinctMoodThoughtGroups(List <Thought> outThoughts)
 {
     GetAllMoodThoughts(outThoughts);
     for (int num = outThoughts.Count - 1; num >= 0; num--)
     {
         Thought other = outThoughts[num];
         for (int i = 0; i < num; i++)
         {
             if (outThoughts[i].GroupsWith(other))
             {
                 outThoughts.RemoveAt(num);
                 break;
             }
         }
     }
 }
 public void GetDistinctMoodThoughtGroups(List <Thought> outThoughts)
 {
     this.GetAllMoodThoughts(outThoughts);
     for (int i = outThoughts.Count - 1; i >= 0; i--)
     {
         Thought other = outThoughts[i];
         for (int j = 0; j < i; j++)
         {
             if (outThoughts[j].GroupsWith(other))
             {
                 outThoughts.RemoveAt(i);
                 break;
             }
         }
     }
 }
Example #16
0
        public override bool GroupsWith(Thought other)
        {
            Thought_Memory thought_Memory = other as Thought_Memory;

            if (thought_Memory == null)
            {
                return(false);
            }
            if (base.GroupsWith(other))
            {
                if (otherPawn != thought_Memory.otherPawn)
                {
                    return(LabelCap == thought_Memory.LabelCap);
                }
                return(true);
            }
            return(false);
        }
 public void GetDistinctMoodThoughtGroups(List <Thought> outThoughts)
 {
     this.GetAllMoodThoughts(outThoughts);
     for (int num = outThoughts.Count - 1; num >= 0; num--)
     {
         Thought other = outThoughts[num];
         int     num2  = 0;
         while (num2 < num)
         {
             if (!outThoughts[num2].GroupsWith(other))
             {
                 num2++;
                 continue;
             }
             outThoughts.RemoveAt(num);
             break;
         }
     }
 }
Example #18
0
        public static MoteBubble MakeMoodThoughtBubble(Pawn pawn, Thought thought)
        {
            MoteBubble result;

            if (Current.ProgramState != ProgramState.Playing)
            {
                result = null;
            }
            else if (!pawn.Spawned)
            {
                result = null;
            }
            else
            {
                float num = thought.MoodOffset();
                if (num == 0f)
                {
                    result = null;
                }
                else
                {
                    MoteBubble moteBubble = MoteMaker.ExistingMoteBubbleOn(pawn);
                    if (moteBubble != null)
                    {
                        if (moteBubble.def == ThingDefOf.Mote_Speech)
                        {
                            return(null);
                        }
                        if (moteBubble.def == ThingDefOf.Mote_ThoughtBad || moteBubble.def == ThingDefOf.Mote_ThoughtGood)
                        {
                            moteBubble.Destroy(DestroyMode.Vanish);
                        }
                    }
                    ThingDef   def         = (num <= 0f) ? ThingDefOf.Mote_ThoughtBad : ThingDefOf.Mote_ThoughtGood;
                    MoteBubble moteBubble2 = (MoteBubble)ThingMaker.MakeThing(def, null);
                    moteBubble2.SetupMoteBubble(thought.Icon, null);
                    moteBubble2.Attach(pawn);
                    GenSpawn.Spawn(moteBubble2, pawn.Position, pawn.Map, WipeMode.Vanish);
                    result = moteBubble2;
                }
            }
            return(result);
        }
        public float MoodOffsetOfGroup(Thought group)
        {
            GetMoodThoughts(group, tmpThoughts);
            if (!tmpThoughts.Any())
            {
                return(0f);
            }
            float num  = 0f;
            float num2 = 1f;
            float num3 = 0f;

            for (int i = 0; i < tmpThoughts.Count; i++)
            {
                Thought thought = tmpThoughts[i];
                num  += thought.MoodOffset();
                num3 += num2;
                num2 *= thought.def.stackedEffectMultiplier;
            }
            float num4 = num / (float)tmpThoughts.Count;

            tmpThoughts.Clear();
            return(num4 * num3);
        }
Example #20
0
        public static MoteBubble MakeMoodThoughtBubble(Pawn pawn, Thought thought)
        {
            if (Current.ProgramState != ProgramState.Playing)
            {
                return(null);
            }
            if (!pawn.Spawned)
            {
                return(null);
            }
            float num = thought.MoodOffset();

            if (num == 0f)
            {
                return(null);
            }
            MoteBubble moteBubble = ExistingMoteBubbleOn(pawn);

            if (moteBubble != null)
            {
                if (moteBubble.def == ThingDefOf.Mote_Speech)
                {
                    return(null);
                }
                if (moteBubble.def == ThingDefOf.Mote_ThoughtBad || moteBubble.def == ThingDefOf.Mote_ThoughtGood)
                {
                    moteBubble.Destroy();
                }
            }
            ThingDef   def         = (!(num > 0f)) ? ThingDefOf.Mote_ThoughtBad : ThingDefOf.Mote_ThoughtGood;
            MoteBubble moteBubble2 = (MoteBubble)ThingMaker.MakeThing(def);

            moteBubble2.SetupMoteBubble(thought.Icon, null);
            moteBubble2.Attach(pawn);
            GenSpawn.Spawn(moteBubble2, pawn.Position, pawn.Map);
            return(moteBubble2);
        }
Example #21
0
 public virtual bool GroupsWith(Thought other)
 {
     return(def == other.def);
 }
        public static bool TryGetRandomSocialFightProvokingThought(Pawn pawn, Pawn otherPawn, out Thought thought)
        {
            bool result;

            if (pawn.needs.mood == null)
            {
                thought = null;
                result  = false;
            }
            else
            {
                pawn.needs.mood.thoughts.GetSocialThoughts(otherPawn, InteractionUtility.tmpSocialThoughts);
                ISocialThought socialThought;
                bool           flag = InteractionUtility.tmpSocialThoughts.Where(delegate(ISocialThought x)
                {
                    ThoughtDef def = ((Thought)x).def;
                    return(def != ThoughtDefOf.HadAngeringFight && def != ThoughtDefOf.HadCatharticFight && x.OpinionOffset() < 0f);
                }).TryRandomElementByWeight((ISocialThought x) => - x.OpinionOffset(), out socialThought);
                InteractionUtility.tmpSocialThoughts.Clear();
                thought = (Thought)socialThought;
                result  = flag;
            }
            return(result);
        }
        public override bool GroupsWith(Thought other)
        {
            Thought_Memory thought_Memory = other as Thought_Memory;

            return(thought_Memory != null && base.GroupsWith(other) && (this.otherPawn == thought_Memory.otherPawn || this.LabelCap == thought_Memory.LabelCap));
        }
Example #24
0
        public static bool TryGetRandomSocialFightProvokingThought(Pawn pawn, Pawn otherPawn, out Thought thought)
        {
            if (pawn.needs.mood == null)
            {
                thought = null;
                return(false);
            }
            pawn.needs.mood.thoughts.GetSocialThoughts(otherPawn, InteractionUtility.tmpSocialThoughts);
            ISocialThought socialThought = default(ISocialThought);
            bool           result        = InteractionUtility.tmpSocialThoughts.Where(delegate(ISocialThought x)
            {
                ThoughtDef def = ((Thought)x).def;
                if (def != ThoughtDefOf.HadAngeringFight && def != ThoughtDefOf.HadCatharticFight)
                {
                    return(x.OpinionOffset() < 0.0);
                }
                return(false);
            }).TryRandomElementByWeight <ISocialThought>((Func <ISocialThought, float>)((ISocialThought x) => (float)(0.0 - x.OpinionOffset())), out socialThought);

            InteractionUtility.tmpSocialThoughts.Clear();
            thought = (Thought)socialThought;
            return(result);
        }
Example #25
0
        public static bool HasAnySocialFightProvokingThought(Pawn pawn, Pawn otherPawn)
        {
            Thought thought = default(Thought);

            return(InteractionUtility.TryGetRandomSocialFightProvokingThought(pawn, otherPawn, out thought));
        }
Example #26
0
 private static bool DrawThoughtGroup(Rect rect, Thought group, Pawn pawn)
 {
     try
     {
         pawn.needs.mood.thoughts.GetMoodThoughts(group, NeedsCardUtility.thoughtGroup);
         Thought leadingThoughtInGroup = PawnNeedsUIUtility.GetLeadingThoughtInGroup(NeedsCardUtility.thoughtGroup);
         if (!leadingThoughtInGroup.VisibleInNeedsTab)
         {
             NeedsCardUtility.thoughtGroup.Clear();
             return(false);
         }
         if (leadingThoughtInGroup != NeedsCardUtility.thoughtGroup[0])
         {
             NeedsCardUtility.thoughtGroup.Remove(leadingThoughtInGroup);
             NeedsCardUtility.thoughtGroup.Insert(0, leadingThoughtInGroup);
         }
         if (Mouse.IsOver(rect))
         {
             Widgets.DrawHighlight(rect);
         }
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.Append(leadingThoughtInGroup.Description);
         if (group.def.DurationTicks > 5)
         {
             stringBuilder.AppendLine();
             stringBuilder.AppendLine();
             Thought_Memory thought_Memory = leadingThoughtInGroup as Thought_Memory;
             if (thought_Memory != null)
             {
                 if (NeedsCardUtility.thoughtGroup.Count == 1)
                 {
                     stringBuilder.Append("ThoughtExpiresIn".Translate((group.def.DurationTicks - thought_Memory.age).ToStringTicksToPeriod()));
                 }
                 else
                 {
                     Thought_Memory thought_Memory2 = (Thought_Memory)NeedsCardUtility.thoughtGroup[NeedsCardUtility.thoughtGroup.Count - 1];
                     stringBuilder.Append("ThoughtStartsExpiringIn".Translate((group.def.DurationTicks - thought_Memory.age).ToStringTicksToPeriod()));
                     stringBuilder.AppendLine();
                     stringBuilder.Append("ThoughtFinishesExpiringIn".Translate((group.def.DurationTicks - thought_Memory2.age).ToStringTicksToPeriod()));
                 }
             }
         }
         if (NeedsCardUtility.thoughtGroup.Count > 1)
         {
             bool flag = false;
             for (int i = 1; i < NeedsCardUtility.thoughtGroup.Count; i++)
             {
                 bool flag2 = false;
                 for (int j = 0; j < i; j++)
                 {
                     if (NeedsCardUtility.thoughtGroup[i].LabelCap == NeedsCardUtility.thoughtGroup[j].LabelCap)
                     {
                         flag2 = true;
                         break;
                     }
                 }
                 if (!flag2)
                 {
                     if (!flag)
                     {
                         stringBuilder.AppendLine();
                         stringBuilder.AppendLine();
                         flag = true;
                     }
                     stringBuilder.AppendLine("+ " + NeedsCardUtility.thoughtGroup[i].LabelCap);
                 }
             }
         }
         TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), 7291));
         Text.WordWrap = false;
         Text.Anchor   = TextAnchor.MiddleLeft;
         Rect rect2 = new Rect(rect.x + 10f, rect.y, 225f, rect.height);
         rect2.yMin -= 3f;
         rect2.yMax += 3f;
         string text = leadingThoughtInGroup.LabelCap;
         if (NeedsCardUtility.thoughtGroup.Count > 1)
         {
             text = text + " x" + NeedsCardUtility.thoughtGroup.Count;
         }
         Widgets.Label(rect2, text);
         Text.Anchor = TextAnchor.MiddleCenter;
         float num = pawn.needs.mood.thoughts.MoodOffsetOfGroup(group);
         if (num == 0f)
         {
             GUI.color = NeedsCardUtility.NoEffectColor;
         }
         else if (num > 0f)
         {
             GUI.color = NeedsCardUtility.MoodColor;
         }
         else
         {
             GUI.color = NeedsCardUtility.MoodColorNegative;
         }
         Rect rect3 = new Rect(rect.x + 235f, rect.y, 32f, rect.height);
         Widgets.Label(rect3, num.ToString("##0"));
         Text.Anchor   = TextAnchor.UpperLeft;
         GUI.color     = Color.white;
         Text.WordWrap = true;
     }
     catch (Exception ex)
     {
         Log.ErrorOnce(string.Concat(new object[]
         {
             "Exception in DrawThoughtGroup for ",
             group.def,
             " on ",
             pawn,
             ": ",
             ex.ToString()
         }), 3452698, false);
     }
     return(true);
 }
        public override bool GroupsWith(Thought other)
        {
            Thought_SituationalSocial thought_SituationalSocial = other as Thought_SituationalSocial;

            return(thought_SituationalSocial != null && base.GroupsWith(other) && this.otherPawn == thought_SituationalSocial.otherPawn);
        }
 public string OpinionExplanation(Pawn other)
 {
     if (other.RaceProps.Humanlike && this.pawn != other)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("OpinionOf".Translate(other.LabelShort) + ": " + this.OpinionOf(other).ToStringWithSign());
         string pawnSituationLabel = SocialCardUtility.GetPawnSituationLabel(other, this.pawn);
         if (!pawnSituationLabel.NullOrEmpty())
         {
             stringBuilder.AppendLine(pawnSituationLabel);
         }
         stringBuilder.AppendLine("--------------");
         bool flag = false;
         if (this.pawn.Dead)
         {
             stringBuilder.AppendLine("IAmDead".Translate());
             flag = true;
         }
         else
         {
             IEnumerable <PawnRelationDef> relations = this.pawn.GetRelations(other);
             foreach (PawnRelationDef item in relations)
             {
                 stringBuilder.AppendLine(item.GetGenderSpecificLabelCap(other) + ": " + item.opinionOffset.ToStringWithSign());
                 flag = true;
             }
             if (this.pawn.RaceProps.Humanlike)
             {
                 ThoughtHandler thoughts = this.pawn.needs.mood.thoughts;
                 thoughts.GetDistinctSocialThoughtGroups(other, Pawn_RelationsTracker.tmpSocialThoughts);
                 for (int i = 0; i < Pawn_RelationsTracker.tmpSocialThoughts.Count; i++)
                 {
                     ISocialThought socialThought = Pawn_RelationsTracker.tmpSocialThoughts[i];
                     int            num           = 1;
                     Thought        thought       = (Thought)socialThought;
                     if (thought.def.IsMemory)
                     {
                         num = thoughts.memories.NumMemoriesInGroup((Thought_MemorySocial)socialThought);
                     }
                     stringBuilder.Append(thought.LabelCapSocial);
                     if (num != 1)
                     {
                         stringBuilder.Append(" x" + num);
                     }
                     stringBuilder.AppendLine(": " + thoughts.OpinionOffsetOfGroup(socialThought, other).ToStringWithSign());
                     flag = true;
                 }
             }
             List <Hediff> hediffs = this.pawn.health.hediffSet.hediffs;
             for (int j = 0; j < hediffs.Count; j++)
             {
                 HediffStage curStage = hediffs[j].CurStage;
                 if (curStage != null && curStage.opinionOfOthersFactor != 1.0)
                 {
                     stringBuilder.Append(hediffs[j].LabelBase.CapitalizeFirst());
                     if (curStage.opinionOfOthersFactor != 0.0)
                     {
                         stringBuilder.AppendLine(": x" + curStage.opinionOfOthersFactor.ToStringPercent());
                     }
                     else
                     {
                         stringBuilder.AppendLine();
                     }
                     flag = true;
                 }
             }
             if (this.pawn.HostileTo(other))
             {
                 stringBuilder.AppendLine("Hostile".Translate());
                 flag = true;
             }
         }
         if (!flag)
         {
             stringBuilder.AppendLine("NoneBrackets".Translate());
         }
         return(stringBuilder.ToString().TrimEndNewlines());
     }
     return(string.Empty);
 }
Example #29
0
 private static bool DrawThoughtGroup(Rect rect, Thought group, Pawn pawn)
 {
     try
     {
         pawn.needs.mood.thoughts.GetMoodThoughts(group, thoughtGroup);
         Thought leadingThoughtInGroup = PawnNeedsUIUtility.GetLeadingThoughtInGroup(thoughtGroup);
         if (!leadingThoughtInGroup.VisibleInNeedsTab)
         {
             thoughtGroup.Clear();
             return(false);
         }
         if (leadingThoughtInGroup != thoughtGroup[0])
         {
             thoughtGroup.Remove(leadingThoughtInGroup);
             thoughtGroup.Insert(0, leadingThoughtInGroup);
         }
         if (Mouse.IsOver(rect))
         {
             Widgets.DrawHighlight(rect);
         }
         if (Mouse.IsOver(rect))
         {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.Append(leadingThoughtInGroup.Description);
             if (group.def.DurationTicks > 5)
             {
                 stringBuilder.AppendLine();
                 stringBuilder.AppendLine();
                 Thought_Memory thought_Memory = leadingThoughtInGroup as Thought_Memory;
                 if (thought_Memory != null)
                 {
                     if (thoughtGroup.Count == 1)
                     {
                         stringBuilder.Append("ThoughtExpiresIn".Translate((group.def.DurationTicks - thought_Memory.age).ToStringTicksToPeriod()));
                     }
                     else
                     {
                         int num  = int.MaxValue;
                         int num2 = int.MinValue;
                         foreach (Thought_Memory item in thoughtGroup)
                         {
                             num  = Mathf.Min(num, item.age);
                             num2 = Mathf.Max(num2, item.age);
                         }
                         stringBuilder.Append("ThoughtStartsExpiringIn".Translate((group.def.DurationTicks - num2).ToStringTicksToPeriod()));
                         stringBuilder.AppendLine();
                         stringBuilder.Append("ThoughtFinishesExpiringIn".Translate((group.def.DurationTicks - num).ToStringTicksToPeriod()));
                     }
                 }
             }
             if (thoughtGroup.Count > 1)
             {
                 bool flag = false;
                 for (int i = 1; i < thoughtGroup.Count; i++)
                 {
                     bool flag2 = false;
                     for (int j = 0; j < i; j++)
                     {
                         if (thoughtGroup[i].LabelCap == thoughtGroup[j].LabelCap)
                         {
                             flag2 = true;
                             break;
                         }
                     }
                     if (!flag2)
                     {
                         if (!flag)
                         {
                             stringBuilder.AppendLine();
                             stringBuilder.AppendLine();
                             flag = true;
                         }
                         stringBuilder.AppendLine("+ " + thoughtGroup[i].LabelCap);
                     }
                 }
             }
             TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), 7291));
         }
         Text.WordWrap = false;
         Text.Anchor   = TextAnchor.MiddleLeft;
         Rect rect2 = new Rect(rect.x + 10f, rect.y, 225f, rect.height);
         rect2.yMin -= 3f;
         rect2.yMax += 3f;
         string text = leadingThoughtInGroup.LabelCap;
         if (thoughtGroup.Count > 1)
         {
             text = text + " x" + thoughtGroup.Count;
         }
         Widgets.Label(rect2, text);
         Text.Anchor = TextAnchor.MiddleCenter;
         float num3 = pawn.needs.mood.thoughts.MoodOffsetOfGroup(group);
         if (num3 == 0f)
         {
             GUI.color = NoEffectColor;
         }
         else if (num3 > 0f)
         {
             GUI.color = MoodColor;
         }
         else
         {
             GUI.color = MoodColorNegative;
         }
         Widgets.Label(new Rect(rect.x + 235f, rect.y, 32f, rect.height), num3.ToString("##0"));
         Text.Anchor   = TextAnchor.UpperLeft;
         GUI.color     = Color.white;
         Text.WordWrap = true;
     }
     catch (Exception ex)
     {
         Log.ErrorOnce("Exception in DrawThoughtGroup for " + group.def + " on " + pawn + ": " + ex.ToString(), 3452698);
     }
     return(true);
 }
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef, out LookTargets lookTargets)
        {
            Thought thought = RandomBreakupReason(initiator, recipient);
            bool    flag    = false;
            bool    flag2   = false;

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Spouse, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExSpouse, recipient);
                if (recipient.needs.mood != null)
                {
                    recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.DivorcedMe, initiator);
                    recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                    recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, initiator);
                }
                if (recipient.needs.mood != null)
                {
                    initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                    initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, recipient);
                }
                flag  = SpouseRelationUtility.ChangeNameAfterDivorce(initiator);
                flag2 = SpouseRelationUtility.ChangeNameAfterDivorce(recipient);
            }
            else
            {
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Lover, recipient);
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Fiance, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExLover, recipient);
                if (recipient.needs.mood != null)
                {
                    recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.BrokeUpWithMe, initiator);
                }
            }
            if (initiator.ownership.OwnedBed != null && initiator.ownership.OwnedBed == recipient.ownership.OwnedBed)
            {
                ((Rand.Value < 0.5f) ? initiator : recipient).ownership.UnclaimBed();
            }
            TaleRecorder.RecordTale(TaleDefOf.Breakup, initiator, recipient);
            if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("LetterNoLongerLovers".Translate(initiator.LabelShort, recipient.LabelShort, initiator.Named("PAWN1"), recipient.Named("PAWN2")));
                stringBuilder.AppendLine();
                if (flag)
                {
                    stringBuilder.Append("LetterNoLongerLovers_BackToBirthName".Translate(initiator.Named("PAWN")));
                }
                if (flag2)
                {
                    if (flag)
                    {
                        stringBuilder.Append(" ");
                    }
                    stringBuilder.Append("LetterNoLongerLovers_BackToBirthName".Translate(recipient.Named("PAWN")));
                }
                if (flag | flag2)
                {
                    stringBuilder.AppendLine();
                }
                if (thought != null)
                {
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("FinalStraw".Translate(thought.LabelCap));
                }
                letterLabel = "LetterLabelBreakup".Translate();
                letterText  = stringBuilder.ToString().TrimEndNewlines();
                letterDef   = LetterDefOf.NegativeEvent;
                lookTargets = new LookTargets(initiator, recipient);
            }
            else
            {
                letterLabel = null;
                letterText  = null;
                letterDef   = null;
                lookTargets = null;
            }
        }