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); }
/// <summary> /// Thread-safe version for vanilla. /// </summary> /// <param name="group"></param> /// <param name="handler"></param> /// <returns></returns> private float MoodOffsetOfGroup(Thought group, ThoughtHandler handler) { List <Thought> tmpThoughts = _thoughts.Value; handler.GetMoodThoughts(group, tmpThoughts); if (!tmpThoughts.Any()) { return(0f); } float totalMoodOffset = 0f; float effectMultiplier = 1f; float totalEffectMultiplier = 0f; foreach (Thought thought in tmpThoughts) { totalMoodOffset += thought.MoodOffset(); totalEffectMultiplier += effectMultiplier; effectMultiplier *= thought.def.stackedEffectMultiplier; } float num4 = totalMoodOffset / (float)tmpThoughts.Count; tmpThoughts.Clear(); return(num4 * totalEffectMultiplier); }