#pragma once #include "SH_API.h" #include #include "ECS_Base/SHECSMacros.h" #include #include namespace YAML { class Emitter; class Node; } namespace SHADE { class SHSceneNode; constexpr const char* ComponentsNode = "Components"; constexpr const char* EntityNameNode = "Name"; constexpr const char* EIDNode = "EID"; constexpr const char* IsActiveNode = "IsActive"; constexpr const char* NumberOfChildrenNode = "NumberOfChildren"; constexpr const char* ScriptsNode = "Scripts"; constexpr const char* PrefabID = "PrefabID"; class SH_API SHSerialization { public: //Original EID : New EID using CreatedEntitiesList = std::unordered_map; static bool SerializeSceneToFile(AssetID const& sceneAssetID); static std::string SerializeSceneToString(); static void SerializeSceneToEmitter(YAML::Emitter& out); static std::string DeserializeSceneFromFile(AssetID const& sceneAssetID) noexcept; static void EmitEntity(SHSceneNode* entityNode, YAML::Emitter& out, bool isPrefab = false, EntityID* entityIndex = nullptr); static std::string SerializeEntitiesToString(std::vector const& entities) noexcept; static std::string SerializeEntityToString(EntityID eid) noexcept; //static void SerializeEntityToFile(std::filesystem::path const& path); static YAML::Node SerializeEntityToNode(SHSceneNode* sceneNode, bool isPrefab = false, EntityID* entityIndex = nullptr); static CreatedEntitiesList DeserializeEntitiesFromString(std::string const& data, EntityID const& parentEID = MAX_EID) noexcept; static std::vector GetComponentIDList(YAML::Node const& componentsNode); static void LoadAssetsFromAssetQueue(std::unordered_map& assetQueue); static std::string ResolveSerializedEntityIndices(std::string serializedEntityData, CreatedEntitiesList const& createdEntities) noexcept; private: //static void ResolveSerializedEntityID(YAML::Emitter& out, YAML::iterator& it, YAML::Node const& entityNode, CreatedEntitiesList const& createdEntities); static void InitializeEntity(YAML::Node const& entityNode, EntityID const& eid); static constexpr std::string_view NewSceneName = "New Scene"; }; }