Class MekSummaryCache

java.lang.Object
megamek.common.loaders.MekSummaryCache

public class MekSummaryCache extends Object
Cache of the Mek summary information. Implemented as Singleton so a client and server running in the same process can share it
  • Field Details

  • Method Details

    • getInstance

      public static MekSummaryCache getInstance()
    • getInstance

      public static MekSummaryCache getInstance(boolean ignoreUnofficial)
    • refreshUnitData

      public static void refreshUnitData(boolean ignoreUnofficial)
      Checks the unit files directory for any changes since the last time the unit cache was loaded. If there are any updates, the new cache is saved.
      Parameters:
      ignoreUnofficial - If true, skips unofficial directories
    • rebuildUnitData

      public static void rebuildUnitData(boolean ignoreUnofficial)
      Rebuilds the unit cache from scratch, ignoring any existing on-disk cache data.
      Parameters:
      ignoreUnofficial - If true, skips unofficial directories
    • dispose

      public static void dispose()
    • getUnitCacheDir

      public static File getUnitCacheDir()
      Get the directory for the unit cache file.
      Returns:
      The path to the directory containing the unit cache.
    • isInitialized

      public boolean isInitialized()
    • isLoading

      public boolean isLoading()
    • addListener

      public void addListener(MekSummaryCache.Listener listener)
    • removeListener

      public void removeListener(MekSummaryCache.Listener listener)
    • getAllMeks

      public MekSummary[] getAllMeks()
    • getMek

      @Nullable public MekSummary getMek(String sRef)
    • getAsset

      @Nullable public MekSummary getAsset(String name)
      Parameters:
      name - the unit name (chassis + model)
      Returns:
      the Battlefield Support Asset summary with the given name, or null if none exists. Unlike getMek(String), this returns the Asset form even when a base unit shares the same name.
    • getByUnitFileUUID

      @Nullable public MekSummary getByUnitFileUUID(@Nullable String unitFileUUID)
      Parameters:
      unitFileUUID - a unit-file UUID
      Returns:
      the unit summary with the given unit-file UUID, or null if none exists
    • getLinkedAsset

      @Nullable public MekSummary getLinkedAsset(@Nullable MekSummary baseUnit)
      Parameters:
      baseUnit - a non-asset unit summary
      Returns:
      the Battlefield Support Asset linked to the given base unit (whose linkedUnitId is the base unit's UUID), or null if the base unit has no linked asset (or is itself an asset)
    • getLinkedAssetForUnitFileUUID

      @Nullable public MekSummary getLinkedAssetForUnitFileUUID(@Nullable String baseUnitFileUUID)
      Parameters:
      baseUnitFileUUID - the base unit's unit-file UUID
      Returns:
      the Battlefield Support Asset linked to the base unit with that UUID, or null if there is none
    • getLinkedBaseUnit

      @Nullable public MekSummary getLinkedBaseUnit(@Nullable MekSummary asset)
      Parameters:
      asset - a Battlefield Support Asset summary
      Returns:
      the base unit linked to the given asset (the unit whose UUID equals the asset's linkedUnitId), or null if the asset is standalone (or is not an asset)
    • getFailedFiles

      public Map<String,String> getFailedFiles()
    • loadMekData

      public void loadMekData()
    • loadMekData

      public void loadMekData(boolean ignoreUnofficial)
    • getSummaryFromFile

      @Nullable public static MekSummary getSummaryFromFile(File unitFile)
      Builds a fully populated MekSummary from a standalone unit file, without requiring the entire unit cache to be loaded. The unit does not need to be part of the official cache.

      This is intended for tooling (such as the SVG mass printer) that needs to process arbitrary or custom .blk/.mtf files.

      Parameters:
      unitFile - the unit file to parse
      Returns:
      a populated MekSummary, or null if the file could not be loaded
    • getCacheCount

      public int getCacheCount()
    • getFileCount

      public int getFileCount()
    • getZipCount

      public int getZipCount()