Package megamek.common.units
Class EntityListFile
java.lang.Object
megamek.common.units.EntityListFile
This class provides static methods to save a list of
Entitys to, and load a list of Entitys
from a file.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetLocString(Entity entity, int indentLvl) Helper function that generates a string identifying the state of the locations for an entity.static StringindentStr(int level) Helper function to indent based on an indent levelstatic voidSave theEntitys in the list to the given file.static voidSave theEntitys in the list to the given file.static voidSave theEntitys in the list to the given file.static voidSave theEntitys in the list to the given file.static voidSave the entities from the game of client to the given file.static voidSave the entities from the game of client to the given file.static voidwriteEntityList(Writer output, ArrayList<Entity> list) static voidwriteEntityList(Writer output, ArrayList<Entity> list, boolean embedUnits)
-
Constructor Details
-
EntityListFile
public EntityListFile()
-
-
Method Details
-
indentStr
Helper function to indent based on an indent level -
getLocString
Helper function that generates a string identifying the state of the locations for an entity.- Parameters:
entity- - theEntitywhose location state is needed
-
saveTo
Save theEntitys in the list to the given file.
TheEntity'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 methodsaveTo, 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 allEntitys in the list will be written to the file.list- - AnArrayListcontainingEntitys to be stored in a file.- Throws:
IOException- - Is thrown on any error.
-
saveTo
Save theEntitys in the list to the given file.
TheEntity'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 methodsaveTo, 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 allEntitys in the list will be written to the file.list- - AnArrayListcontainingEntitys to be stored in a file.embedUnits- - Set totrueto 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 theEntitys in the list to the given file.
TheEntity'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, seethe overloaded version of this function- Parameters:
file- - The current contents of the file will be discarded and allEntitys in the list will be written to the file.list- - AArrayListcontainingEntitys to be stored in a file.genericBattleValue- - AnIntegerrepresenting 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 theEntitys in the list to the given file.
TheEntity'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 allEntitys in the list will be written to the file.list- - AArrayListcontainingEntitys to be stored in a file.genericBattleValue- - AnIntegerrepresenting the generic battle value. If it is greater than 0, it will be written into the XML.embedUnits- - Set totrueto 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
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
TheEntitys 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 allEntitys in the list will be written to the file.client- - aClientcontaining theGames to be used- Throws:
IOException- is thrown on any error.
-
saveTo
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
TheEntitys 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 allEntitys in the list will be written to the file.client- - aClientcontaining theGames to be usedlocalPlayer- - What player should we treat as "the" player?- Throws:
IOException- is thrown on any error.
-
writeEntityList
- Throws:
IOException
-
writeEntityList
public static void writeEntityList(Writer output, ArrayList<Entity> list, boolean embedUnits) throws IOException - Throws:
IOException
-