Class RATManager

All Implemented Interfaces:
IUnitGenerator

public class RATManager extends AbstractUnitGenerator
Provides a front end to RandomUnitGenerator that allows the user to generate units based on criteria such as faction, unit type, and weight class. May be restricted to a certain subset of all available RATs.
  • Constructor Details

    • RATManager

      public RATManager()
  • Method Details

    • updateRATConfig

      public void updateRATConfig(OptionsChangedEvent ev)
    • setSelectedRATs

      public void setSelectedRATs(List<String> selected)
      Replaces selected RAT collections with new list
      Parameters:
      selected - List of RAT collection names
    • setSelectedRATs

      public void setSelectedRATs(String[] selected)
      Replaces selected RAT collections with new list
      Parameters:
      selected - Array of RAT collection names
    • removeRAT

      public void removeRAT(String collection)
      Remove RAT collection from list of selected RATs
      Parameters:
      collection - Name of RAT collection to remove
    • setIgnoreRatEra

      public void setIgnoreRatEra(boolean ignore)
    • getAllRATCollections

      public static Map<String,List<Integer>> getAllRATCollections()
      Returns:
      A map of all collections available with a list of eras included
    • populateCollectionNames

      public static void populateCollectionNames()
      Scans ratdata directory for list of available RATs that can be used by CampaignOptions to provide a list.
    • isSupportedUnitType

      public boolean isSupportedUnitType(int unitType)
      Parameters:
      unitType - UnitType constant
      Returns:
      true if the generator supports the unit type
    • generate

      @Nullable public megamek.common.MekSummary generate(String faction, int unitType, int weightClass, int year, int quality, @Nullable Predicate<megamek.common.MekSummary> filter)
      Description copied from interface: IUnitGenerator
      Generate a single unit.
      Parameters:
      faction - Faction shortname
      unitType - UnitType constant
      weightClass - EntityWeightClass constant, or -1 for unspecified
      year - The year of the campaign date
      quality - Index of equipment rating, with zero being the lowest quality.
      filter - All generated units return true when the filter function is applied.
      Returns:
      A unit that matches the criteria
    • generate

      @Nullable public megamek.common.MekSummary generate(String faction, int unitType, int weightClass, int year, int quality, Collection<megamek.common.EntityMovementMode> movementModes, Collection<megamek.client.ratgenerator.MissionRole> missionRoles, @Nullable Predicate<megamek.common.MekSummary> filter)
      Description copied from interface: IUnitGenerator
      Generate a unit using additional parameters specific to the generation method.
      Parameters:
      faction - Faction shortname
      unitType - UnitType constant
      weightClass - EntityWeightClass constant, or -1 for unspecified
      year - The year of the campaign date
      quality - Index of equipment rating, with zero being the lowest quality.
      movementModes - A collection of various movement modes
      missionRoles - A collection of various mission roles
      filter - All generated units return true when the filter function is applied.
      Returns:
      A unit that matches the criteria
    • generate

      public List<megamek.common.MekSummary> generate(int count, String faction, int unitType, int weightClass, int year, int quality, @Nullable Predicate<megamek.common.MekSummary> filter)
      Description copied from interface: IUnitGenerator
      Generates a list of units with an additional test function.
      Parameters:
      count - The number of units to generate
      faction - Faction shortname
      unitType - UnitType constant
      weightClass - EntityWeightClass constant, or -1 for unspecified
      year - The year of the campaign date
      quality - Index of equipment rating, with zero being the lowest quality.
      filter - All generated units return true when the filter function is applied.
      Returns:
      A list of units matching the criteria.
    • generate

      public List<megamek.common.MekSummary> generate(int count, String faction, int unitType, int weightClass, int year, int quality, Collection<megamek.common.EntityMovementMode> movementModes, Collection<megamek.client.ratgenerator.MissionRole> missionRoles, @Nullable Predicate<megamek.common.MekSummary> filter)
      Description copied from interface: IUnitGenerator
      Generates a list of units using additional parameters specific to the generation method.
      Parameters:
      count - The number of units to generate
      faction - Faction shortname
      unitType - UnitType constant
      weightClass - EntityWeightClass constant, or -1 for unspecified
      year - The year of the campaign date
      quality - Index of equipment rating, with zero being the lowest quality.
      movementModes - A collection of various movement modes
      missionRoles - A collection of various mission roles
      filter - All generated units return true when the filter function is applied.
      Returns:
      A list of units matching the criteria.
    • generate

      @Nullable public megamek.common.MekSummary generate(UnitGeneratorParameters parameters)
      Generates a single unit, for the given faction, using the given set of parameters. Note that some of the properties of the parameters may be ignored for generation mechanisms that aren't the RAT Generator
      Parameters:
      parameters - data structure containing unit generation parameters
      Returns:
      Generated units. Null if none generated.
    • generate

      public List<megamek.common.MekSummary> generate(int count, UnitGeneratorParameters parameters)
      Generates a list of mek summaries from a RAT determined by the given faction, quality and other parameters. Note that for the purposes of this implementation, the only properties of "parameters" used are unit type, year, weight classes and movement modes. We also expect the rating to be a number 1-5, rather than A-F.
      Parameters:
      count - How many units to generate
      parameters - RATGenerator parameters (some are ignored)
      Returns:
      List of generated units. Empty if none are generated.