January 8, 2012

More XML

Well, playing Deus Ex: HR definitely took more time than I wanted... :).  The new year also brought a bit more stress at work, so I've been less productive after work than usual.

In the interest of simplicity, I'm going to try and use XStream for all my XML needs.  I've developed a basic XMLLoader class which loads data from a pre-defined list of files into pre-defined Java classes, which are then accessible to various game systems as needed.  This should still provide modding flexibility, as each XML file will host an expandable list of entities of a given type.

For example, a file named SpaceMonsters.xml will contain a listing of all the space monsters in the game.  Each monster would be contained within a tag such as <spacemonster></spacemonster>.  New monsters can be added by simply creating a new set of these tags at the end of the document and filling in the relevant details.  In code, all space monsters will implement the same ISpaceMonster interface.  Using XStream, I can read SpaceMonsters.xml entries into an ArrayList in code and then handle any given monster via its interface.  It should be straightforward to implement a similar system for technologies, random events, default starship designs, etc.

Tasks remaining:

1) Finish conversion of remaining Java Enumerations into XML files/classes.
2) Add in support for custom XML galaxy shapes.
3) Implement load/save capability for a single star object (as a test run).

No comments:

Post a Comment