Class EntityListFile

java.lang.Object
megamek.common.units.EntityListFile

public class EntityListFile extends Object
This class provides static methods to save a list of Entitys to, and load a list of Entitys from a file.
  • Constructor Details

    • EntityListFile

      public EntityListFile()
  • Method Details

    • indentStr

      public static String indentStr(int level)
      Helper function to indent based on an indent level
    • getLocString

      public static String getLocString(Entity entity, int indentLvl)
      Helper function that generates a string identifying the state of the locations for an entity.
      Parameters:
      entity - - the Entity whose location state is needed
    • saveTo

      public static void saveTo(File file, ArrayList<Entity> list) throws IOException
      Save the Entitys in the list to the given file.

      The Entity's pilots, damage, ammo loads, ammo usage, and other campaign-related information are retained, but data specific to a particular game is ignored. This method is a simpler version of the overloaded method saveTo, with a default generic battle value of 0 (this causes GBV to be ignored), and with unit embedding off.
      Parameters:
      file - - The current contents of the file will be discarded and all Entitys in the list will be written to the file.
      list - - An ArrayList containing Entitys to be stored in a file.
      Throws:
      IOException - - Is thrown on any error.
    • saveTo

      public static void saveTo(File file, ArrayList<Entity> list, boolean embedUnits) throws IOException
      Save the Entitys in the list to the given file.

      The Entity's pilots, damage, ammo loads, ammo usage, and other campaign-related information are retained, but data specific to a particular game is ignored. This method is a simpler version of the overloaded method saveTo, with a default generic battle value of 0 (this causes GBV to be ignored).
      Parameters:
      file - - The current contents of the file will be discarded and all Entitys in the list will be written to the file.
      list - - An ArrayList containing Entitys to be stored in a file.
      embedUnits - - Set to true to embed the unit file of custom units (blk/mtf data) into the file. This allows the resulting file to be loaded by someone who doesn't have those custom units available.
      Throws:
      IOException - - Is thrown on any error.
    • saveTo

      public static void saveTo(File file, ArrayList<Entity> list, int genericBattleValue) throws IOException
      Save the Entitys in the list to the given file.

      The Entity's pilots, damage, ammo loads, ammo usage, and other campaign-related information are retained, but data specific to a particular game is ignored. Unit embedding is off, see the overloaded version of this function
      Parameters:
      file - - The current contents of the file will be discarded and all Entitys in the list will be written to the file.
      list - - A ArrayList containing Entitys to be stored in a file.
      genericBattleValue - - An Integer representing the generic battle value. If it is greater than 0, it will be written into the XML.
      Throws:
      IOException - - Is thrown on any error.
    • saveTo

      public static void saveTo(File file, ArrayList<Entity> list, int genericBattleValue, boolean embedUnits) throws IOException
      Save the Entitys in the list to the given file.

      The Entity's pilots, damage, ammo loads, ammo usage, and other campaign-related information are retained, but data specific to a particular game is ignored.
      Parameters:
      file - - The current contents of the file will be discarded and all Entitys in the list will be written to the file.
      list - - A ArrayList containing Entitys to be stored in a file.
      genericBattleValue - - An Integer representing the generic battle value. If it is greater than 0, it will be written into the XML.
      embedUnits - - Set to true to embed the unit file of custom units (blk/mtf data) into the file. This allows the resulting file to be loaded by someone who doesn't have those custom units available.
      Throws:
      IOException - - Is thrown on any error.
    • saveTo

      public static void saveTo(File file, Client client) throws IOException
      Save the entities from the game of client to the given file. This will create separate sections for salvage, devastated, and ejected crews in addition to the surviving units

      The Entitys pilots, damage, ammo loads, ammo usage, and other campaign-related information are retained but data specific to a particular game is ignored.
      Parameters:
      file - - The current contents of the file will be discarded and all Entitys in the list will be written to the file.
      client - - a Client containing the Games to be used
      Throws:
      IOException - is thrown on any error.
    • saveTo

      public static void saveTo(File file, Client client, Player localPlayer) throws IOException
      Save the entities from the game of client to the given file. This will create separate sections for salvage, devastated, and ejected crews in addition to the surviving units

      The Entitys pilots, damage, ammo loads, ammo usage, and other campaign-related information are retained but data specific to a particular game is ignored.
      Parameters:
      file - - The current contents of the file will be discarded and all Entitys in the list will be written to the file.
      client - - a Client containing the Games to be used
      localPlayer - - What player should we treat as "the" player?
      Throws:
      IOException - is thrown on any error.
    • writeEntityList

      public static void writeEntityList(Writer output, ArrayList<Entity> list) throws IOException
      Throws:
      IOException
    • writeEntityList

      public static void writeEntityList(Writer output, ArrayList<Entity> list, boolean embedUnits) throws IOException
      Throws:
      IOException