Class Factions2

java.lang.Object
megamek.common.universe.Factions2

public final class Factions2 extends Object
This class manages the unified Faction2 class that combines MHQ's Faction and the RATGenerator's FactionRecord and makes it available to all project parts.

Faction data is loaded from data/universe/factions and .../commands, as well as from the same folders in the user directory, if available.

  • Field Details

  • Constructor Details

    • Factions2

      public Factions2(String factionsDataPath)
      This constructor is intended for unit testing only and will load factions *only* from the provided path. The path is used as it is.
      Parameters:
      factionsDataPath - The path to load factions data from
  • Method Details

    • getInstance

      public static Factions2 getInstance()
    • getInstance

      public static Factions2 getInstance(boolean useTestDirectory)
    • setInstance

      public static void setInstance(@Nullable Factions2 instance)
    • getFactions

      public Collection<Faction2> getFactions()
      Returns:
      All available factions. The returned Collection is a view of the internal faction list and must not be modified.
    • getFaction

      public Optional<Faction2> getFaction(@Nullable String factionCode)
      Parameters:
      factionCode - The faction's key such as LA, HL, CGS or LA.DG
      Returns:
      The faction for the given faction code, if any.