← API Reference Class

asge::game::scene::SceneSerializer

Serializes an ecs::Registry's entities to a TOML scene file.

#include <SceneSerializer.hpp>

Private Attributes

Public Member Functions

#explicit SceneSerializer(filesystem::VirtualFileSystem const &inVfs) noexcept

Binds this serializer to the VFS scene asset paths are resolved through.

#SceneSerializer(SceneSerializer const &)=default
#SceneSerializer(SceneSerializer &&)=default
#SceneSerializer & operator=(SceneSerializer const &)=default
#SceneSerializer & operator=(SceneSerializer &&)=default
#~SceneSerializer()=default
#BoolResult Save(ecs::Registry const &inRegistry, filesystem::Path const &inPath, SaveContext *outCtx=nullptr) const noexcept

Writes every currently-alive entity in inRegistry to inPath as TOML: one [[entity]] array-of-tables entry per entity, with a subtable for each serializable component it currently has.

Parameters
outCtx

If non-null, receives each entity's index in the file (m_Ids).

Returns

Ok on success, or the underlying filesystem::WriteText error.

#BoolResult Load(ecs::Registry &dstRegistry, str::String const &inVirtualPath, LoadContext *outCtx=nullptr) const noexcept

Populates dstRegistry from a scene file previously written by Save(): one fresh CreateEntity() per [[entity]] block, with every serializable component present re-added via its Serializer.

Parameters
outCtx

If non-null, receives each file index's new entity (m_Entities) on success.

Returns

Ok on success. On any failure, only the entities this call itself created are rolled back — anything already in dstRegistry before the call is never touched, win or lose.

#BoolResult LoadFromFile(ecs::Registry &dstRegistry, filesystem::Path const &inPath, LoadContext *outCtx=nullptr) const noexcept

Same as Load(), but for a scene file addressed by a real filesystem path instead of one resolved through the VFS.

Returns

Ok on success, with the same partial-load rollback guarantee as Load().

Private Member Functions

#BoolResult LoadResolved(ecs::Registry &dstRegistry, filesystem::Path const &inPath, LoadContext *outCtx) const noexceptprivate