private Thought_SituationalSocial TryCreateSocialThought(ThoughtDef def, Pawn otherPawn) { Thought_SituationalSocial thought_SituationalSocial = null; try { if (!ThoughtUtility.CanGetThought(pawn, def)) { return(null); } if (!def.Worker.CurrentSocialState(pawn, otherPawn).ActiveFor(def)) { return(null); } thought_SituationalSocial = (Thought_SituationalSocial)ThoughtMaker.MakeThought(def); thought_SituationalSocial.pawn = pawn; thought_SituationalSocial.otherPawn = otherPawn; thought_SituationalSocial.RecalculateState(); return(thought_SituationalSocial); } catch (Exception ex) { Log.Error("Exception while recalculating " + def + " thought state for pawn " + pawn + ": " + ex); return(thought_SituationalSocial); } }
private Thought_SituationalSocial TryCreateSocialThought(ThoughtDef def, Pawn otherPawn) { Thought_SituationalSocial thought_SituationalSocial = null; try { if (!ThoughtUtility.CanGetThought(this.pawn, def)) { return(null); } if (!def.Worker.CurrentSocialState(this.pawn, otherPawn).ActiveFor(def)) { return(null); } thought_SituationalSocial = (Thought_SituationalSocial)ThoughtMaker.MakeThought(def); thought_SituationalSocial.pawn = this.pawn; thought_SituationalSocial.otherPawn = otherPawn; thought_SituationalSocial.RecalculateState(); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception while recalculating ", def, " thought state for pawn ", this.pawn, ": ", ex }), false); } return(thought_SituationalSocial); }
public static float ApparelScoreRaw(Pawn pawn, Apparel ap) { float num = 0.1f; float num2 = ap.GetStatValue(StatDefOf.ArmorRating_Sharp, true) + ap.GetStatValue(StatDefOf.ArmorRating_Blunt, true); num += num2; if (ap.def.useHitPoints) { float x = (float)ap.HitPoints / (float)ap.MaxHitPoints; num *= JobGiver_OptimizeApparel.HitPointsPercentScoreFactorCurve.Evaluate(x); } num += ap.GetSpecialApparelScoreOffset(); float num3 = 1f; if (JobGiver_OptimizeApparel.neededWarmth == NeededWarmth.Warm) { float statValue = ap.GetStatValue(StatDefOf.Insulation_Cold, true); num3 *= JobGiver_OptimizeApparel.InsulationColdScoreFactorCurve_NeedWarm.Evaluate(statValue); } num *= num3; if (ap.WornByCorpse && (pawn == null || ThoughtUtility.CanGetThought(pawn, ThoughtDefOf.DeadMansApparel))) { num = (float)(num - 0.5); if (num > 0.0) { num = (float)(num * 0.10000000149011612); } } if (ap.Stuff == ThingDefOf.Human.race.leatherDef) { if (pawn == null || ThoughtUtility.CanGetThought(pawn, ThoughtDefOf.HumanLeatherApparelSad)) { num = (float)(num - 0.5); if (num > 0.0) { num = (float)(num * 0.10000000149011612); } } if (pawn != null && ThoughtUtility.CanGetThought(pawn, ThoughtDefOf.HumanLeatherApparelHappy)) { num = (float)(num + 0.11999999731779099); } } return(num); }
public void TryGainMemory(Thought_Memory newThought, Pawn otherPawn = null) { if (ThoughtUtility.CanGetThought(this.pawn, newThought.def)) { if (newThought is Thought_MemorySocial && newThought.otherPawn == null && otherPawn == null) { Log.Error("Can't gain social thought " + newThought.def + " because its otherPawn is null and otherPawn passed to this method is also null. Social thoughts must have otherPawn."); } else { newThought.pawn = this.pawn; newThought.otherPawn = otherPawn; bool flag = default(bool); if (!newThought.TryMergeWithExistingMemory(out flag)) { this.memories.Add(newThought); } if (newThought.def.stackLimitPerPawn >= 0) { while (this.NumMemoriesInGroup(newThought) > newThought.def.stackLimitPerPawn) { this.RemoveMemory(this.OldestMemoryInGroup(newThought)); } } if (newThought.def.stackLimit >= 0) { while (this.NumMemoriesOfDef(newThought.def) > newThought.def.stackLimit) { this.RemoveMemory(this.OldestMemoryOfDef(newThought.def)); } } if (newThought.def.thoughtToMake != null) { this.TryGainMemory(newThought.def.thoughtToMake, newThought.otherPawn); } if (flag && newThought.def.showBubble && this.pawn.Spawned) { MoteMaker.MakeMoodThoughtBubble(this.pawn, newThought); } } } }
public void TryGainMemory(Thought_Memory newThought, Pawn otherPawn = null) { if (!ThoughtUtility.CanGetThought(pawn, newThought.def)) { return; } if (newThought is Thought_MemorySocial && newThought.otherPawn == null && otherPawn == null) { Log.Error("Can't gain social thought " + newThought.def + " because its otherPawn is null and otherPawn passed to this method is also null. Social thoughts must have otherPawn."); return; } newThought.pawn = pawn; newThought.otherPawn = otherPawn; if (!newThought.TryMergeWithExistingMemory(out bool showBubble)) { memories.Add(newThought); } if (newThought.def.stackLimitForSameOtherPawn >= 0) { while (NumMemoriesInGroup(newThought) > newThought.def.stackLimitForSameOtherPawn) { RemoveMemory(OldestMemoryInGroup(newThought)); } } if (newThought.def.stackLimit >= 0) { while (NumMemoriesOfDef(newThought.def) > newThought.def.stackLimit) { RemoveMemory(OldestMemoryOfDef(newThought.def)); } } if (newThought.def.thoughtToMake != null) { TryGainMemory(newThought.def.thoughtToMake, newThought.otherPawn); } if (showBubble && newThought.def.showBubble && pawn.Spawned && PawnUtility.ShouldSendNotificationAbout(pawn)) { MoteMaker.MakeMoodThoughtBubble(pawn, newThought); } }