-
Notifications
You must be signed in to change notification settings - Fork 8
Entity Factory
Marcel Guzik edited this page May 3, 2017
·
2 revisions
Entity factory can load entity from .JSON file using static function:
EntityFactory::createEntity("filePath")
It returns an unique pointer to entity with all components defined in .JSON file.
{
"name" : "(name of our entity)",
"components" : [
{
"componentType" : "componentType1",
"componentArgName11" : "componentValue11",
...
"componentArgName1n" : "componentValue1n"
},
...
{
"componentType" : "componentType2",
"componentArgName21" : "componentValue21",
...
"componentArgName2n" : "componentValue2n"
}
]
}
Each JSON file should describe one entity. It stores its name and list of components. Component segment should look like that:
{
"componentType" : "componentType1",
"componentArgName11" : "componentValue11",
...
"componentArgName1n" : "componentValue1n"
},
Those are passed to components constructor, and every constructor have it's own requirements to that segment as nlohmann::json
. Remember that componentArg can be another JSON structure.