private static bool Prefix(Passion passion, ref Color __result) { int p = (int)passion; InterestDef interest = InterestBase.interestList[p]; float val = interest.GetValue(); if (val < 0) { if (val / 75.0f < 1.0f) { __result = veryNegativeColor; } else { __result = negativeColor; } } else if (val == 0) { __result = neutralColor; } else { if (val / 75.0f > 1.0f) { __result = veryPositiveColor; } else { __result = positiveColor; } } return(false); }
private static void Postfix(Object model, SkillDef def, object __instance) { var r = AccessTools.PropertyGetter(Patch_RimHUDBase.hudPawnModel, "Base"); Pawn b = (Pawn)r.Invoke(model, null); Pawn_SkillTracker st = b.skills; SkillRecord skillRecord = (st != null) ? st.GetSkill(def) : null; if (skillRecord == null) { return; } var label = AccessTools.Field(Patch_RimHUDBase.hudSkillModel, "<Label>k__BackingField"); if (label == null) { return; } InterestDef i = InterestBase.interestList[(int)skillRecord.passion]; string end = ""; float val = i.GetValue(); if (val < 0) { end = new string('-', -(int)Math.Floor(val / 75.0f)); } else if (val > 0) { end = new string('+', (int)Math.Floor(val / 75.0f)); } string l = def.LabelCap + end; label.SetValue(__instance, l); }