public static bool MoodOffsetOfGroup(ThoughtHandler __instance, ref float __result, Thought group) { List <Thought> tmpThoughts = new List <Thought>(); __instance.GetMoodThoughts(group, tmpThoughts); if (!tmpThoughts.Any <Thought>()) { __result = 0.0f; return(false); } float num1 = 0.0f; float num2 = 1f; float num3 = 0.0f; for (int index = 0; index < tmpThoughts.Count; ++index) { Thought tmpThought = tmpThoughts[index]; if (null != tmpThought) { num1 += tmpThought.MoodOffset(); num3 += num2; num2 *= tmpThought.def.stackedEffectMultiplier; } } double num4 = (double)num1 / (double)tmpThoughts.Count; tmpThoughts.Clear(); double num5 = (double)num3; __result = (float)(num4 * num5); return(false); }
private static float <RandomFinalStraw> m__1(Thought x) { return(-x.MoodOffset()); }
public override float CalculateNewsImportanceForPawn(Pawn pawn, TaleNewsReference reference) { // Again, this code is also a placeholder. float result = pawn.GetSocialProximityScoreForOther(Victim); // We have 2500 tick for 1 RW hour; hence, 60000 tick for 1 RW day // Shock grade scrapped in favour of simple boolean "shocking news" flag // result += (int)reference.ShockGrade * Mathf.Pow(0.5f, (1.0f / (60000 * 15)) * (Find.TickManager.TicksGame - reference.TickReceived)); //float victimKindScore = Victim.RaceProps.Animal ? 1 : 10; // First determine thought by relations ThoughtDef potentialGivenThought = pawn.GetMostImportantRelation(Victim)?.GetGenderSpecificDiedThought(Victim) ?? null; // If there exists none, then determine by factions if (potentialGivenThought == null) { if (pawn.Faction != null && pawn.Faction == Victim.Faction) { potentialGivenThought = ThoughtDefOf.KnowColonistDied; } } float relationalDeathImpact; if (potentialGivenThought != null) { Thought tempThought = ThoughtMaker.MakeThought(potentialGivenThought); tempThought.pawn = pawn; relationalDeathImpact = Mathf.Abs(tempThought.MoodOffset()); } else { relationalDeathImpact = 0; } // Calculate main impact score // Base score is 2 float mainScore = 2; // Accumulate relational impact mainScore += relationalDeathImpact; // Humanlike bonus: killing a man should be more significant than killing an animal if (PrimaryVictim.RaceProps.Humanlike) { mainScore += 5; } // Body size scaling: killing XL animals should be more significant than killing S animals mainScore *= PrimaryVictim.BodySize; // Pawn relations scaling: pawns with deeper bonds or deeper toothmarks should be more significant. Scales up to factor of 3. mainScore *= 1 + Mathf.Abs(((float)pawn.relations.OpinionOf(Victim)) / 50); // Faction relations scaling: factions with stronger relations should be more significant. Scales up to factor of 3. int interFactionGoodwill = pawn.Faction.GetGoodwillWith(Victim.Faction); mainScore *= 1 + Mathf.Abs((float)interFactionGoodwill / 50); // News importance decays over time. Normal rate is halving per year. // Decay factor increased if news is shocking float decayFactor = 0.5f; if (reference.IsShockingNews) { decayFactor = 0.75f; } // There are 60000 ticks per day, 15 days per Quadrum, and 4 Quadrums per year. result += mainScore * Mathf.Pow(decayFactor, (1.0f / (60000 * 15 * 4)) * (Find.TickManager.TicksGame - reference.TickReceived)); // Memories are faulty. // They can be stronger or weaker, depending on how the brain is functioning at that moment. // Goes from -2 to +2. result += Rand.Value * 4 - 2; // Check that the result is valid; value should not drop below 0. if (result < 0) { return(0); } else { return(result); } }