Update Design Doc: `level` tool

master
Ashley N. 2023-09-09 14:23:02 +00:00
parent 5b1042e9e4
commit cf65722c64
1 changed files with 37 additions and 17 deletions

@ -87,27 +87,47 @@ The collision map is just an array of 8-bit unsigned integers laid out with the
### .ecs Format (Entity-Component System) ### .ecs Format (Entity-Component System)
This file contains the entity-component system defined by the [attributes](#entity-component-system) set in Tiled Map Editor's object layer(s). This file contains the entity-component system defined by the [attributes](#entity-component-system) set in Tiled Map Editor's object layer(s).
#### Entities #### Header
Holds information on the sizes of various large segments in the file.
``` ```
2 bytes: Number of entities 2 bytes: Object Table Size
For (number of entities): * The object table is a sparse array of active entities you memcpy into RAM. Normally this is 512 but future versions of level may permit customisation.
* 2 bytes: Entity ID 2 bytes: Component Attribute Union Size
* This is the size in bytes of the largest type i.e. the one requiring the most bytes for its component attributes (which are 2 bytes each).
2 bytes: Number of systems
* This is the number of systems in the total Entity-Component System.
``` ```
#### Components #### Type Table
Holds the registry of types and which set of components is associated with each type.
``` ```
* 2 bytes: Number of components 2 bytes: Number of Types (A Type is a predetermined combination of components.)
For (number of components): For (Number of types):
* 4 bytes: Component ID 1 byte: Type ID (1-255)
* Upper 2 bytes - ID of the associated entity 1 byte: Number of components attached to this type
* Lower 2 bytes - Index of the component within above entity For (Number of components attached to this type):
1 byte: ID of the component
``` ```
#### Component Attributes #### Object Table
Holds the list of active entities (or Objects). Normally you memcpy this into your RAM and work on it after its initial state defined here.
``` ```
* 2 bytes: Number of component attributes For (Object Table Size):
For (number of component attributes): 1 byte: ID of the type. (00 = No entity defined in this slot)
* 4 bytes: Component ID ```
* 2 bytes: Index of the property (Order of properties are identical to order of properties in configuration TOML)
* 2 bytes: Value of the property #### Component Attribute Table
Holds the list of active component attributes for each entity. Is a tagged union where the tag is the entity Type defined in the respective Object Table index, which you can get by dividing an index into this table by Component Attribute Union Size.
```
For (Object Table Size * Component Attribute Union Size):
(Component Attribute Union Size) bytes:
```
#### System Table
For each unique system ID, a length of the array, then a list of indices into the Object Table pointing to active objects that are relevant to this system (by virtue of their Types containing components used by this system).
```
For (Number of systems):
1 byte: Number of attached components
For (Number of attached components):
1 byte: Index into the Object Table pointing to a Type ID containing at least one relevant component to the system
``` ```