Skip to content

Saving/Loading #70

Open
Open

Description

@MStachowicz

All the engine data lives inside the ECS. To save/load we have to save the state of the ECS storage and load it back.

Some things live above the scene/ECS, such as engine preferences e.g. Light/Dark mode, editor camera settings, file being worked on.

Tackling ECS saving first:
To save an Archetype, we need to call all the Component::serialise functions in the order they appear and save the ComponentIDs to be able to deduce which function pointers to use on deserialise.

Currently the ComponentIDs are being set at compile time in the order they are exposed. To save an Archetype, we require the IDs to remain the same across all compilers + runs otherwise the wrong serialise/deserialise will be used on the file data if they change. Additionally, all the function pointers (ComponentInfo) need to be set before deserialise will be called.

The above requirement means we have to add an ECS set_persistent_ID(), which the client then calls for all the ComponentTypes that will be stored inside at the start of the application.

By adding a constexpr static size_t Persistent_ID = X; To every component class, we can remove the need for runtime mapping of a Type to a ComponentData. I.e. the Component::get_ID<ComponentType>() function no longer has to find the matching ComponentData by searching the Type_Infos list. The alternative was set_info<ComponentType>(ComponentID) would save the ComponentID and a std::type_index to perform a runtime mapping so when given just the ComponentType, we could deduce the ComponentID by matching the std::type_index.

These will be the IDs the ECS saves and uses to deduce the serialise/deserialise functions to call.

Metadata

Metadata

Assignees

Labels

Cat: SystemsImpact: LargeSize: LargeType: Feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions