Update Design Doc: `level` tool

master
Ashley N. 2023-09-09 14:41:45 +00:00
parent 9f4d33530a
commit da6445873f
1 changed files with 12 additions and 18 deletions

@ -87,33 +87,22 @@ 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).
#### Header
Holds information on the sizes of various large segments in the file.
```
2 bytes: Object Table Size
* 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: 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 (2 bytes each).
2 bytes: Number of systems
* This is the number of systems in the total Entity-Component System.
```
#### Type Table #### Type Table
Holds the registry of types and which set of components is associated with each type. Holds the registry of types and which set of components is associated with each type.
``` ```
2 bytes: Number of Types (A Type is a predetermined combination of components.) 2 bytes: Number of Types (A Type is a predetermined combination of components.)
For (Number of types): 2 bytes: Type Definition Union Size
1 byte: Type ID (1-255) * This is the size in bytes of the largest combo of components for a type.
1 byte: Number of components attached to this type For (Number of Types * Type Definition Union Size):
For (Number of components attached to this type): 1 byte: ID of the component (00 = No component in this slot, supposed to be at end)
1 byte: ID of the component
``` ```
#### Object Table #### 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. 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: Object Table Size
* 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.
For (Object Table Size): For (Object Table Size):
1 byte: ID of the type. (00 = No entity defined in this slot) 1 byte: ID of the type. (00 = No entity defined in this slot)
``` ```
@ -121,6 +110,9 @@ For (Object Table Size):
#### Component Attribute Table #### 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. 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.
``` ```
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 (2 bytes each).
For (Object Table Size * Component Attribute Union Size): For (Object Table Size * Component Attribute Union Size):
(Component Attribute Union Size) bytes: (Component Attribute Union Size) bytes:
``` ```
@ -128,6 +120,8 @@ For (Object Table Size * Component Attribute Union Size):
#### System Table #### 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 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).
``` ```
2 bytes: Number of systems
* This is the number of systems in the total Entity-Component System.
For (Number of systems): For (Number of systems):
1 byte: Number of attached components 1 byte: Number of attached components
For (Number of attached components): For (Number of attached components):