-
Notifications
You must be signed in to change notification settings - Fork 0
Entity data storage
Nikola Dimitroff edited this page Jun 15, 2017
·
14 revisions
Entity data in Zmey is stored in two major categories - per entity class and per world (section). Below are listed how these would look like in both JSON (which will be used during development) and in binary.
{
"version": "1.0" // Format version of the current file
"name": "Magician", // The name of the type
"extends": "Actor", // What type does this one extend (inherit from)
"components": [{ // A list of components to be added to each instance of the class and their default values
"name": "transform", // Name of a component
// Default values of some component specific data
// Note that this component may already exist in the parents, but this will override the default value
"position": [1,2,3]
}, {
"name": "debugname",
"debugname": "Pikachu"
}, {
...
}]
}
marker for class descriptor
version
namehash
list of components, each containing component hash, followed by its data, flattened
- Flattened above refers to the fact that all components of all parents will be listed in the file instead of only the components specific to this class. This is performance improvement during loading as the loader doesn't have to resolve ambiguities between parent classes.
Example binary blob:
0
1.0
1234567890
transform
1 2 3
debugname
"testname"
{
"version": "1.0", // Version of the current format
"name": "city-of-township", // Name of the world section
"extends": "city-template", // The world section this section extends from (inherits from)
"entities": [ // List of entities in the world section
// Each entity has
// - type tells what class this entity is instance of
// - compiler-id (optional) is only used for overriding data on entities from parent sections
// - components is an array of components overriding default values for the entity's class
{ type: "Magician", "compiler-id": 1, "components": [{}] }
],
"subsections": [ // List of world sections to be added to the current section
// Each subsection has a name and a world-offset denoting where to place the section relative to the current one
{ name: "happiness-borough", "world-offset": [1,2,3] }
],
}
marker for world section descriptor
version // Version of the file
resourcecount // The number of resources this world will require at runtime
resources // a list of resoureces this world will require
entityCount // The number of entities contained in this world section
component_name component_instances_count
id1 id2 id3 id4... // The list of ids for component_1
component1_entity_data component1_entity_data... // List of data for component1
... // Similar list for all other components
Example blob:
1
1.0 // version
2 // resource count
1234567890 0987654321 // the hashes for two resources
2 // entity count
Transform 2 // component name & count
0 1 // ids for transform components
x y z q1 q2 q3 q4 s // Transform data for id 0 in SQT
x y z q1 q2 q3 q4 s // Transform data for id 1 in SQT
DebugName 1 32
1 // ids for debugname components
"Pikachu" // Debug name data for id 1