4 Sep 2012

Modding CZ2D

So, other than being brutally realistic, CZ2D is also designed to be very easily moddable (a la Minecraft). However, because it's written in C#, the game code is compiled into a single .exe, unlike Minecraft where all the compiled class files are left intact within the .jar, allowing you to individually replace them.

As such, I need to make it as easy as possible to modify without needing to change any of the code in the .exe (not that this can't be done, it'd just screw up compatibility).

This is particularly difficult for Items, as they can have custom actions and such, so modders have to be able to add the code for that. The system I have thought of so far to solve this is similar to that of Kerbal Space Program's, i.e. each item has a plaintext file giving its default properties (name, size, weight, inventory/world texture, etc) but in that file it can also reference a .dll and the name of a class within that .dll which implements an interface, allowing the class to expand the item's functionality. Multiple items can use the same .dll, indeed the same class if they want to act the same.

I will probably abstract many of the other parts of the game out to separate .dlls so that things like the world code, rendering or content-handling can be swapped out with modded versions.

I've also just about started work on the 3D version of the Carthage Engine, nicknamed Xana, and once it's done I will probably port CZ2D over to it, once I've added things like multiple floors.

No comments: