public void GetSocialThoughts(Pawn otherPawn, ISocialThought group, List <ISocialThought> outThoughts) { GetSocialThoughts(otherPawn, outThoughts); for (int num = outThoughts.Count - 1; num >= 0; num--) { if (!((Thought)outThoughts[num]).GroupsWith((Thought)group)) { outThoughts.RemoveAt(num); } } }
public void GetSocialThoughts(Pawn otherPawn, ISocialThought group, List <ISocialThought> outThoughts) { this.GetSocialThoughts(otherPawn, outThoughts); for (int i = outThoughts.Count - 1; i >= 0; i--) { if (!((Thought)outThoughts[i]).GroupsWith((Thought)group)) { outThoughts.RemoveAt(i); } } }
public void GetSocialThoughts(Pawn otherPawn, List <ISocialThought> outThoughts) { outThoughts.Clear(); List <Thought_Memory> list = memories.Memories; for (int i = 0; i < list.Count; i++) { ISocialThought socialThought = list[i] as ISocialThought; if (socialThought != null && socialThought.OtherPawn() == otherPawn) { outThoughts.Add(socialThought); } } situational.AppendSocialThoughts(otherPawn, outThoughts); }
public void GetDistinctSocialThoughtGroups(Pawn otherPawn, List <ISocialThought> outThoughts) { GetSocialThoughts(otherPawn, outThoughts); for (int num = outThoughts.Count - 1; num >= 0; num--) { ISocialThought socialThought = outThoughts[num]; for (int i = 0; i < num; i++) { if (((Thought)outThoughts[i]).GroupsWith((Thought)socialThought)) { outThoughts.RemoveAt(num); break; } } } }
public void GetDistinctSocialThoughtGroups(Pawn otherPawn, List <ISocialThought> outThoughts) { this.GetSocialThoughts(otherPawn, outThoughts); for (int i = outThoughts.Count - 1; i >= 0; i--) { ISocialThought socialThought = outThoughts[i]; for (int j = 0; j < i; j++) { if (((Thought)outThoughts[j]).GroupsWith((Thought)socialThought)) { outThoughts.RemoveAt(i); break; } } } }
public int OpinionOffsetOfGroup(ISocialThought group, Pawn otherPawn) { this.GetSocialThoughts(otherPawn, group, ThoughtHandler.tmpSocialThoughts); for (int i = ThoughtHandler.tmpSocialThoughts.Count - 1; i >= 0; i--) { if (ThoughtHandler.tmpSocialThoughts[i].OpinionOffset() == 0f) { ThoughtHandler.tmpSocialThoughts.RemoveAt(i); } } int result; if (!ThoughtHandler.tmpSocialThoughts.Any <ISocialThought>()) { Profiler.EndSample(); result = 0; } else { ThoughtDef def = ((Thought)group).def; if (def.IsMemory && def.stackedEffectMultiplier != 1f) { ThoughtHandler.tmpSocialThoughts.Sort((ISocialThought a, ISocialThought b) => ((Thought_Memory)a).age.CompareTo(((Thought_Memory)b).age)); } float num = 0f; float num2 = 1f; for (int j = 0; j < ThoughtHandler.tmpSocialThoughts.Count; j++) { num += ThoughtHandler.tmpSocialThoughts[j].OpinionOffset() * num2; num2 *= ((Thought)ThoughtHandler.tmpSocialThoughts[j]).def.stackedEffectMultiplier; } ThoughtHandler.tmpSocialThoughts.Clear(); if (num == 0f) { result = 0; } else if (num > 0f) { result = Mathf.Max(Mathf.RoundToInt(num), 1); } else { result = Mathf.Min(Mathf.RoundToInt(num), -1); } } return(result); }
public void GetDistinctSocialThoughtGroups(Pawn otherPawn, List <ISocialThought> outThoughts) { this.GetSocialThoughts(otherPawn, outThoughts); for (int num = outThoughts.Count - 1; num >= 0; num--) { ISocialThought socialThought = outThoughts[num]; int num2 = 0; while (num2 < num) { if (!((Thought)outThoughts[num2]).GroupsWith((Thought)socialThought)) { num2++; continue; } outThoughts.RemoveAt(num); break; } } }
public int OpinionOffsetOfGroup(ISocialThought group, Pawn otherPawn) { GetSocialThoughts(otherPawn, group, tmpSocialThoughts); for (int num = tmpSocialThoughts.Count - 1; num >= 0; num--) { if (tmpSocialThoughts[num].OpinionOffset() == 0f) { tmpSocialThoughts.RemoveAt(num); } } if (!tmpSocialThoughts.Any()) { return(0); } ThoughtDef def = ((Thought)group).def; if (def.IsMemory && def.stackedEffectMultiplier != 1f) { tmpSocialThoughts.Sort((ISocialThought a, ISocialThought b) => ((Thought_Memory)a).age.CompareTo(((Thought_Memory)b).age)); } float num2 = 0f; float num3 = 1f; for (int i = 0; i < tmpSocialThoughts.Count; i++) { num2 += tmpSocialThoughts[i].OpinionOffset() * num3; num3 *= ((Thought)tmpSocialThoughts[i]).def.stackedEffectMultiplier; } tmpSocialThoughts.Clear(); if (num2 == 0f) { return(0); } if (num2 > 0f) { return(Mathf.Max(Mathf.RoundToInt(num2), 1)); } return(Mathf.Min(Mathf.RoundToInt(num2), -1)); }
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); }
public static bool OpinionOffsetOfGroup(ThoughtHandler __instance, ref int __result, ISocialThought group, Pawn otherPawn) { List <ISocialThought> tmpSocialThoughts = new List <ISocialThought>(); __instance.GetSocialThoughts(otherPawn, group, tmpSocialThoughts); for (int index = tmpSocialThoughts.Count - 1; index >= 0; --index) { if ((double)tmpSocialThoughts[index].OpinionOffset() == 0.0) { tmpSocialThoughts.RemoveAt(index); } } if (!tmpSocialThoughts.Any <ISocialThought>()) { __result = 0; return(false); } ThoughtDef def = ((Thought)group).def; if (def.IsMemory && (double)def.stackedEffectMultiplier != 1.0) { tmpSocialThoughts.Sort((Comparison <ISocialThought>)((a, b) => ((Thought_Memory)a).age.CompareTo(((Thought_Memory)b).age))); } float f = 0.0f; float num = 1f; for (int index = 0; index < tmpSocialThoughts.Count; ++index) { f += tmpSocialThoughts[index].OpinionOffset() * num; num *= ((Thought)tmpSocialThoughts[index]).def.stackedEffectMultiplier; } tmpSocialThoughts.Clear(); if ((double)f == 0.0) { __result = 0; return(false); } __result = (double)f > 0.0 ? Mathf.Max(Mathf.RoundToInt(f), 1) : Mathf.Min(Mathf.RoundToInt(f), -1); return(false); }
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); }
private static float <TryGetRandomSocialFightProvokingThought> m__1(ISocialThought x) { return(-x.OpinionOffset()); }
private static bool <TryGetRandomSocialFightProvokingThought> m__0(ISocialThought x) { ThoughtDef def = ((Thought)x).def; return(def != ThoughtDefOf.HadAngeringFight && def != ThoughtDefOf.HadCatharticFight && x.OpinionOffset() < 0f); }
private static int <OpinionOffsetOfGroup> m__0(ISocialThought a, ISocialThought b) { return(((Thought_Memory)a).age.CompareTo(((Thought_Memory)b).age)); }