Package megamek.common.units
Class HeatBreakdown
java.lang.Object
megamek.common.units.HeatBreakdown
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne labelled heat-buildup contribution: how many times the source applied heat this turn (e.g. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBuildup(int heat, String reason) Records a contribution to this turn's heat buildup.voidaddDissipation(int heat, String reason) Records a source of this turn's heat dissipation.buildup()buildupTooltip(int reportedTotal) Formats the buildup breakdown into a single-line tooltip for the "gains N heat" value (e.g.voidclear()Clears both breakdowns so the next turn starts fresh.Formats the dissipation breakdown into a single-line tooltip for the "sinks N heat" value (e.g.
-
Constructor Details
-
HeatBreakdown
public HeatBreakdown()
-
-
Method Details
-
addBuildup
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
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
- 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
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
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
-