• Advertisement
Sign in to follow this  

data driven design: defining new blueprint types through data

This topic is 805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I've been attempting to make my game more data-driven. My initial approach was to define blueprints - which are configurations of specific components - that can read data from JSON files using the serialization library Cereal.

A BlueprintLoader class knows about every type of blueprint. During initialization, it loads blueprints from their respective directories into a map, 1 per blueprint.

class BlueprintLoader {
 using WeaponBlueprintMap = std::map<std::string, WeaponBlueprint>; // keyed by the file name
 using ItemBlueprintMap = std::map<std::string, ItemBlueprint>;
 WeaponBlueprintMap weapons;
 ItemBlueprintMap items;
... more blueprint maps...


void init() {
... more load calls, one for each type of blueprint...

An example blueprint:

class WeaponBlueprint {
   std::vector<std::string> allowedEntityTypes; // entities that can use this weapon
   std::uint32_t accuracy, cooldown, damage, preparationTime;


An example JSON file that the weapon class can load from:

    "weapon": {
        "type": "laser cannons",
        "allowedEntityTypes": [
        "accuracy": 95,
        "cooldown": 10,
        "damage": 2,
        "preparationTime": 0,


And when loading a level from a level file:


void Level::load() {
...one function call per blueprint type...


This is becoming tedious to maintain as every new blueprint type requires its class definition, code to load the blueprint and code to instantiate instances of each blueprint in the world.

1. How can I support entirely new blueprint types to be defined through data? Blueprints are just specific grouping of components that already existing in c++ code.
2. How could inter-blueprint references be managed? For example, if an enemy blueprint e.g "level 1 boss.json" has items or weapons which are themselves blueprint types.
a) All the item and weapon blueprints need to be loaded first so that this enemy can be fully constructed. An initial idea would be to create a graph data structure, then do a topological sort to find the correct loading order; not sure how I would do this in practice though.
b) To construct this enemy example, the items and weapons referenced by this enemy need to have their pointers in the InInventory and UsedBy component set correctly, how could this be done?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement