For some time, I've been trying to figure out how to allow my game's data and logic to safely allow mod plugins similar to how Bethesda's work. Their method seems pretty sane, however I can't exactly see how they did it, nor do I have any connections to ask these sort of questions.
The issue is that say that the player already has a save game. And there exist an item in the save game such that... it has it's own instance data to work with that is completely unique to that one item. He installs a mod that adds more data onto the pre-existing mod. And then uninstalls the mod, and adds in a few more that also adds more data ontop of it.
What would be a sane and fast approach to this?
I've thought about using two different methods....
The first one which uses a monolithic class inheritance structure for low level system information that needs to exist. And then anything unique will be composited in with some identifiers. This method looks pretty identical to what bethesda's file format looks like.
So for example... assuming that [Engine Data] is required to exist.
ARMOR:
Harrowing Soul's Chest Plate: [Engine Data][Durability][Price][Description][Script]
Rogue's Hood: [Engine Data][Durability][Description][Hidden Description][Quest Reference]
Short Sword:[Engine Data][Durability][Price]
Where after the monolithic class, all extra data exist directly adjacent to the main class. I'd like to maintain data locality for the whole system so it's easier to serialize, pointer patch, and fit into tighter memory boundaries... but I'm getting closer to the point where I'm willing to deal.
This would also mean that scripting languages like Lua would need some special API to grab information that's not part of the main class already. But that won't be too much of a problem if I just cache the pointer.
The other thought was possibly using MongoDB, SQLite, or some other offline DB... but I'm not entirely sure about this. I've heard of games using Databases as save files and file formats. The prospect of being pretty easy to merge changes is also fairly nice. But it feels like peeling a grape with a sledge hammer to consider this. Not to mention I'm not entirely sure how fast using a DB would be in real time. I'm also not sure if they can load completely into ram either. I've literally never used a Database outside of web applications.
A side note, I'm avoiding the Entity-Component approach because the idea is to allow as much freedom to the users as possible without needing the source code. Even possibly exposing -most- of the engine's low level systems to Lua. Entity component requires things to be predefined, which is not the end goal here.
If anyone has suggestions, idea's, or better yet methods that works well for them, that would be helpful.