Class engineSpec
XML data is parsed by XStream into the appropriate data object.
So for instance the XML <planet> element is processed by the planet
class to create a planet data object with properties set from the XML. These
properties are fixed and thus have no public setter methods since there is no
in-game reason to change them or create them.
Once loaded, the data object can be converted into a usable entity with components
via by creating the appropriate entity factory eg a planetEF and using the
baseEF.fromXML(name.moore.kevin.ze.XMLdata.XMLbase)
with the XML data object as a the parameter.
Once transferred into the entity-component database, the data object can be discarded.
- Author:
- Kevin Moore
<dev@kevin.moore.name>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe base number of days to construct this engine.private org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>The amount of energy that the engine can deliver per game-tick.private static org.slf4j.Loggerprivate org.jscience.physics.amount.Amount<javax.measure.quantity.Mass>Mass of the component in kilogrammes.private org.jscience.physics.amount.Amount<org.jscience.economics.money.Money>The base cost of constructing this item.private IntegerThe relative size of this engine. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintorg.jscience.physics.amount.Amount<javax.measure.quantity.Energy>Derived classes have to override this and say what class eg engine.class they are.org.jscience.physics.amount.Amount<javax.measure.quantity.Mass>getMass()org.jscience.physics.amount.Amount<org.jscience.economics.money.Money>getMoney()getSize()protected ObjectCalled automatically when loading from XML as part of JDK serialisation.Methods inherited from class name.moore.kevin.ze.XMLdata.XMLbase
defaultXMLmessage, duplicatedXMLmessage, getDescription, getKey, getSpec, missingXMLmessage
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
size
The relative size of this engine.This takes up space in the hull and thus limits what can be installed into which bay in the hull.
Optional element in XML<size>. Defaulted to one. -
money
@XStreamConverter(SingleValueMoneyConverter.class) private org.jscience.physics.amount.Amount<org.jscience.economics.money.Money> moneyThe base cost of constructing this item.This many be modified by factors considered in the construction logic. It is always an exact value, no decimals. Defaults to zero.
Optional element in XML<money>. Defaults to zero if not provided. -
daystobuild
private int daystobuildThe base number of days to construct this engine.This value may be refined by things such as a damaged factory.
Required element in XML<daystobuild>. -
mass
@XStreamConverter(SingleValueMassConverter.class) private org.jscience.physics.amount.Amount<javax.measure.quantity.Mass> massMass of the component in kilogrammes. Required XML<mass>100000 t</mass>. -
energy
@XStreamConverter(SingleValueEnergyConverter.class) private org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> energyThe amount of energy that the engine can deliver per game-tick. Required XML element<energy>10 GJ></energy>.
-
-
Constructor Details
-
engineSpec
public engineSpec()
-
-
Method Details
-
getSize
- Returns:
-
getMass
public org.jscience.physics.amount.Amount<javax.measure.quantity.Mass> getMass()- Returns:
-
getEnergy
public org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> getEnergy()- Returns:
-
getMoney
public org.jscience.physics.amount.Amount<org.jscience.economics.money.Money> getMoney()- Returns:
-
getDaystobuild
public int getDaystobuild()- Returns:
-
readResolve
Description copied from class:XMLbaseCalled automatically when loading from XML as part of JDK serialisation.Used to do some validation of that incoming XML by asserting that properties are set and have defaults as required. Output warning messages if a default is applied. Output error messages if a required XML element is missing and return null to indicate an invalid object.
- Overrides:
readResolvein classXMLbase- Returns:
- null if we can't create a valid object
-
getEntityClass
Description copied from class:XMLbaseDerived classes have to override this and say what class eg engine.class they are. This allows us to use this base class but discover the derived class.- Specified by:
getEntityClassin classXMLbase- Returns:
-