Added serialization of component isActive #210
|
@ -179,7 +179,9 @@ namespace SHADE
|
|||
{
|
||||
if (ComponentType* component = SHComponentManager::GetComponent_s<ComponentType>(eid))
|
||||
{
|
||||
componentsNode[rttr::type::get<ComponentType>().get_name().data()] = YAML::convert<ComponentType>::encode(*component);
|
||||
auto componentNode = YAML::convert<ComponentType>::encode(*component);
|
||||
componentNode[IsActive.data()] = component->isActive;
|
||||
componentsNode[rttr::type::get<ComponentType>().get_name().data()] = componentNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace SHADE
|
||||
{
|
||||
static constexpr std::string_view IsActive = "IsActive";
|
||||
|
||||
using AssetQueue = std::unordered_map<AssetID, AssetType>;
|
||||
struct SHSerializationHelper
|
||||
{
|
||||
|
@ -118,9 +120,9 @@ namespace SHADE
|
|||
YAML::Node node{};
|
||||
if (!component)
|
||||
return node;
|
||||
|
||||
auto componentType = rttr::type::get<ComponentType>();
|
||||
node = RTTRToNode(*component);
|
||||
node[IsActive.data()] = component->isActive;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
@ -198,6 +200,9 @@ namespace SHADE
|
|||
auto componentNode = componentsNode[rttrType.get_name().data()];
|
||||
if (!componentNode.IsDefined())
|
||||
return;
|
||||
if(componentNode[IsActive.data()].IsDefined())
|
||||
component->isActive = componentNode[IsActive.data()].as<bool>();
|
||||
|
||||
auto properties = rttrType.get_properties();
|
||||
for (auto const& prop : properties)
|
||||
{
|
||||
|
@ -227,8 +232,10 @@ namespace SHADE
|
|||
auto component = SHComponentManager::GetComponent_s<ComponentType>(eid);
|
||||
if (componentsNode.IsNull() && !component)
|
||||
return;
|
||||
|
||||
YAML::convert<ComponentType>::decode(GetComponentNode<ComponentType>(componentsNode, eid), *component);
|
||||
auto componentNode = GetComponentNode<ComponentType>(componentsNode, eid);
|
||||
if (componentNode[IsActive.data()].IsDefined())
|
||||
component->isActive = componentNode[IsActive.data()].as<bool>();
|
||||
YAML::convert<ComponentType>::decode(componentNode, *component);
|
||||
}
|
||||
|
||||
template <typename ComponentType, std::enable_if_t<std::is_base_of_v<SHComponent, ComponentType>, bool> = true>
|
||||
|
|
Loading…
Reference in New Issue