Class HeatBreakdown

java.lang.Object
megamek.common.units.HeatBreakdown
All Implemented Interfaces:
Serializable

public class HeatBreakdown extends Object implements Serializable
Itemized record of how a unit's heat was built up and dissipated during a single turn, used to give the Heat Phase report (report 5035) a hover/click breakdown of its "gains N heat" and "sinks N heat" values.

Both sides are keyed by a human-readable source label in the order heat was first applied; buildup sources also count how many times they fired (so several of the same weapon read "PPC x2: +20 (10 each)" rather than a single misleading "+20"). This object lives on Entity and is rebuilt each turn.

See Also:
  • Constructor Details

    • HeatBreakdown

      public HeatBreakdown()
  • Method Details

    • addBuildup

      public void addBuildup(int heat, String reason)
      Records a contribution to this turn's heat buildup. Contributions sharing a label are summed and the source count is incremented; zero heat or a missing label is ignored.
      Parameters:
      heat - the signed heat added (negative for cooling/reductions)
      reason - a short human-readable source label, e.g. "Movement (Running)" or "PPC"
    • addDissipation

      public void addDissipation(int heat, String reason)
      Records a source of this turn's heat dissipation. Contributions sharing a label are summed.
      Parameters:
      heat - the heat this source dissipates (positive)
      reason - a short human-readable source label, e.g. "Heat sinks" or "Submerged"
    • buildup

      Returns:
      an unmodifiable, insertion-ordered view of this turn's heat-buildup contributions (source label -> count and signed total)
    • dissipation

      public Map<String,Integer> dissipation()
      Returns:
      an unmodifiable, insertion-ordered view of this turn's heat-dissipation contributions (source label -> heat removed)
    • clear

      public void clear()
      Clears both breakdowns so the next turn starts fresh.
    • buildupTooltip

      public String buildupTooltip(int reportedTotal)
      Formats the buildup breakdown into a single-line tooltip for the "gains N heat" value (e.g. "Movement (Running): +2, PPC x2: +20 (10 each), Cooling (water/coolant/etc.): -9"). Any heat not itemized here is reconciled into a trailing "Other" entry so the listed contributions still sum to the reported total - skipped when the net is negative, since the reported buildup is then clamped to 0.
      Parameters:
      reportedTotal - the heat-buildup total shown on the report (used to reconcile un-itemized heat)
      Returns:
      the tooltip text, or an empty string if nothing was itemized this turn
    • dissipationTooltip

      public String dissipationTooltip()
      Formats the dissipation breakdown into a single-line tooltip for the "sinks N heat" value (e.g. "Heat sinks: 10, Submerged: 2, Radical heat sink: 3"). The figures are the unit's dissipation capacity by source; a cool unit may not use all of it.
      Returns:
      the tooltip text, or an empty string if nothing recorded dissipation this turn