Class RecordingCompositeTechLevel

java.lang.Object
megamek.common.CompositeTechLevel
megamek.common.RecordingCompositeTechLevel
All Implemented Interfaces:
Serializable, ITechnology

public class RecordingCompositeTechLevel extends CompositeTechLevel
A CompositeTechLevel that remembers every component folded into it, together with the state of the composite immediately after that component was added.

This exists so that a tech level report can show which component is responsible for a unit's tech level, rather than only the final answer. Because it records the real addComponent calls instead of re-deriving the component list, it cannot drift from the calculation it is describing.

This class is a reporting aid and is never part of game state: it is not sent to clients and never reaches a saved game. The recorded components are therefore held in a transient list and RecordingCompositeTechLevel.ComponentTechRecord is deliberately not serializable.

Since:
0.51.01
See Also:
  • Constructor Details

    • RecordingCompositeTechLevel

      public RecordingCompositeTechLevel(Entity entity, Faction techFaction, int evaluationYear)
      Creates a composite tech level for the given unit that records each component as it is added.
      Parameters:
      entity - The unit whose tech level is being built
      techFaction - The faction to evaluate faction-specific dates for
      evaluationYear - The year to evaluate each component's variable tech level in
  • Method Details

    • recordComponent

      protected void recordComponent(ITechnology tech, @Nullable String componentName)
      Description copied from class: CompositeTechLevel
      Called after every component has been folded into this composite. Does nothing by default; subclasses may override it to record the components that make up the composite. See RecordingCompositeTechLevel.
      Overrides:
      recordComponent in class CompositeTechLevel
      Parameters:
      tech - - the advancement of the component that was just added
      componentName - - the name supplied for the component, or null if none was given
    • getComponentRecords

      Returns:
      Every component of this unit, in the order it was added to the composite
    • getEvaluationYear

      public int getEvaluationYear()
      Returns:
      The year each component's variable tech level was evaluated in