// ReSharper disable once InconsistentNaming private static void Pawn_Resurrected_Postfix([NotNull] Pawn_HealthTracker __instance) { FieldInfo pawnFieldInfo = typeof(Pawn_HealthTracker).GetField("pawn", BindingFlags.NonPublic | BindingFlags.Instance); Pawn pawn = (Pawn)pawnFieldInfo?.GetValue(__instance); if (pawn?.Faction != null && pawn.Faction.IsPlayer && Current.ProgramState == ProgramState.Playing) { EntriesDirty_Postfix(); CompPSI compPSI = pawn.GetComp <CompPSI>(); compPSI?.CheckTraits(); } }
// ReSharper disable once InconsistentNaming private static void Pawn_Kill_Postfix([NotNull] Pawn __instance) { if (__instance.Faction?.IsPlayer == true && Current.ProgramState == ProgramState.Playing) { EntriesDirty_Postfix(); CompPSI compPSI = __instance.GetComp <CompPSI>(); if (compPSI != null) { compPSI.BgColor = Color.gray; compPSI.ThisColCount = 0; } } }
public static void DrawColonistIconsBar([NotNull] this Pawn pawn, Rect psiRect, float rectAlpha) { CompPSI pawnStats = pawn.GetComp <CompPSI>(); if (pawn.Dead || !pawn.Spawned || pawn.holdingOwner == null || pawn.Map == null) { pawnStats.ThisColCount = 0; return; } SettingsColonistBar colBarSettings = Settings.BarSettings; int barIconNum = 0; int rowCount = pawnStats.ThisColCount; // Drafted if (colBarSettings.ShowDraft && pawn.Drafted) { if (pawnStats.IsPacifist) { DrawIconOnBar(psiRect, ref barIconNum, Icon.Draft, Textures.ColYellow, rectAlpha, rowCount); } else { DrawIconOnBar(psiRect, ref barIconNum, Icon.Draft, Textures.ColVermillion, rectAlpha, rowCount); } } List <IconEntryBar> drawIconEntries = pawnStats.BarIconList; if (!pawnStats.BarIconList.NullOrEmpty()) { int maxIconCount = Mathf.Min( Settings.BarSettings.IconsInColumn * 2, drawIconEntries.Count + barIconNum); for (int index = 0; index < maxIconCount - barIconNum; index++) { IconEntryBar iconEntryBar = drawIconEntries[index]; iconEntryBar.Color.a *= rectAlpha; DrawIconOnBar(psiRect, iconEntryBar, index + barIconNum, rowCount); } barIconNum += maxIconCount; } // Idle - bar icon already included - vanilla int colCount = Mathf.CeilToInt((float)barIconNum / Settings.BarSettings.IconsInColumn); pawnStats.ThisColCount = colCount; }
private static void DrawColonistRelationIconsPSI([NotNull] Pawn pawn) { // Log.Message("Begin Drawing"); if (pawn.Dead || !pawn.Spawned || pawn.holdingOwner == null || pawn.Map == null) { return; } CompPSI pawnStats = pawn.GetComp <CompPSI>(); if (pawnStats == null) { return; } // Log.Message("Relations checked"); if (!pawnStats.HasRelationWithColonist) { return; } // Log.Message("Has relation"); int iconNum = 0; // Pawn is no colonist, thus no further stat checks Vector3 bodyLoc = pawn.DrawPos; { float hediffSetBleedRateTotal = pawn.health.hediffSet.BleedRateTotal; if (hediffSetBleedRateTotal > 0.01f) { PSIDrawer.DrawIconOnColonist( bodyLoc, ref iconNum, Icon.Bloodloss, Statics.GradientRedAlertToNeutral.Evaluate(1.0f - hediffSetBleedRateTotal), Settings.ViewOpacityCrit); } Color color = Statics.Gradient4.Evaluate(1f - pawn.health.summaryHealth.SummaryHealthPercent); PSIDrawer.DrawIconOnColonist( bodyLoc, ref iconNum, Icon.Health, color, Settings.ViewOpacityCrit); } }
private static void Pawn_PostApplyDamage_Postfix([NotNull] Pawn __instance) { CompPSI compPSI = __instance.GetComp <CompPSI>(); compPSI?.SetEntriesDirty(); }
private static void DrawColonistIconsPSI([NotNull] Pawn pawn) { if (pawn.Dead || !pawn.Spawned || pawn.holdingOwner == null || pawn.Map == null) { return; } CompPSI pawnStats = pawn.GetComp <CompPSI>(); if (pawnStats == null) { return; } SettingsPSI psiSettings = Settings.PSISettings; float viewOpacity = psiSettings.IconOpacity; int iconNum = 0; Vector3 bodyLoc = pawn.DrawPos; // Target Point if (psiSettings.ShowTargetPoint && pawnStats.TargetPos != Vector3.zero) { if (psiSettings.UseColoredTarget) { Color skinColor = pawn.story.SkinColor; Color hairColor = pawn.story.hairColor; if (SkinMat == null) { return; } if (HairMat == null) { return; } PSIDrawer.DrawIcon_posOffset(pawnStats.TargetPos, Vector3.zero, SkinMat, skinColor, 1f); PSIDrawer.DrawIcon_posOffset(pawnStats.TargetPos, Vector3.zero, HairMat, hairColor, 1f); } else { if (TargetMat == null) { return; } PSIDrawer.DrawIcon_posOffset(pawnStats.TargetPos, Vector3.zero, TargetMat, ColorNeutralStatus, viewOpacity); } } // Drafted if (psiSettings.ShowDraft && pawn.Drafted) { if (pawnStats.IsPacifist) { PSIDrawer.DrawIconOnColonist(bodyLoc, ref iconNum, Icon.Pacific, ColYellow, Settings.ViewOpacityCrit); } else { PSIDrawer.DrawIconOnColonist(bodyLoc, ref iconNum, Icon.Draft, ColVermillion, Settings.ViewOpacityCrit); } } List <IconEntryPSI> drawIconEntries = pawnStats.PSIIconList; if (!drawIconEntries.NullOrEmpty()) { for (int index = 0; index < drawIconEntries.Count; index++) { IconEntryPSI iconEntryBar = drawIconEntries[index]; PSIDrawer.DrawIconOnColonist(bodyLoc, iconEntryBar, index + iconNum); } } }