| 562 | } |
| 563 | |
| 564 | void OvCore::ECS::Actor::OnDeserialize(tinyxml2::XMLDocument & p_doc, tinyxml2::XMLNode * p_actorsRoot) |
| 565 | { |
| 566 | OvCore::Helpers::Serializer::DeserializeString(p_doc, p_actorsRoot, "name", m_name); |
| 567 | OvCore::Helpers::Serializer::DeserializeString(p_doc, p_actorsRoot, "tag", m_tag); |
| 568 | OvCore::Helpers::Serializer::DeserializeBoolean(p_doc, p_actorsRoot, "active", m_active); |
| 569 | OvCore::Helpers::Serializer::DeserializeInt64(p_doc, p_actorsRoot, "id", m_actorID); |
| 570 | OvCore::Helpers::Serializer::DeserializeUInt64(p_doc, p_actorsRoot, "guid", m_guid); |
| 571 | std::string prefabSource; |
| 572 | OvCore::Helpers::Serializer::DeserializeString(p_doc, p_actorsRoot, "prefab_source", prefabSource); |
| 573 | SetPrefabSource(prefabSource); |
| 574 | uint64_t prefabNodeGUID = 0; |
| 575 | OvCore::Helpers::Serializer::DeserializeUInt64(p_doc, p_actorsRoot, "prefab_node_guid", prefabNodeGUID); |
| 576 | SetPrefabNodeGUID(prefabNodeGUID); |
| 577 | OvCore::Helpers::Serializer::DeserializeInt64(p_doc, p_actorsRoot, "parent", m_parentID); |
| 578 | |
| 579 | { |
| 580 | tinyxml2::XMLNode* componentsRoot = p_actorsRoot->FirstChildElement("components"); |
| 581 | if (componentsRoot) |
| 582 | { |
| 583 | tinyxml2::XMLElement* currentComponent = componentsRoot->FirstChildElement("component"); |
| 584 | |
| 585 | while (currentComponent) |
| 586 | { |
| 587 | const std::string componentType = currentComponent->FirstChildElement("type")->GetText(); |
| 588 | OvCore::ECS::Components::AComponent* component = nullptr; |
| 589 | |
| 590 | using namespace OvCore::ECS::Components; |
| 591 | |
| 592 | if (IsType<CTransform>(componentType)) component = &transform; |
| 593 | else if (IsType<CPhysicalBox>(componentType)) component = &AddComponent<CPhysicalBox>(); |
| 594 | else if (IsType<CPhysicalSphere>(componentType)) component = &AddComponent<CPhysicalSphere>(); |
| 595 | else if (IsType<CPhysicalCapsule>(componentType)) component = &AddComponent<CPhysicalCapsule>(); |
| 596 | else if (IsType<CModelRenderer>(componentType)) component = &AddComponent<CModelRenderer>(); |
| 597 | else if (IsType<CCamera>(componentType)) component = &AddComponent<CCamera>(); |
| 598 | else if (IsType<CMaterialRenderer>(componentType)) component = &AddComponent<CMaterialRenderer>(); |
| 599 | else if (IsType<CAudioSource>(componentType)) component = &AddComponent<CAudioSource>(); |
| 600 | else if (IsType<CAudioListener>(componentType)) component = &AddComponent<CAudioListener>(); |
| 601 | else if (IsType<CPointLight>(componentType)) component = &AddComponent<CPointLight>(); |
| 602 | else if (IsType<CDirectionalLight>(componentType)) component = &AddComponent<CDirectionalLight>(); |
| 603 | else if (IsType<CSpotLight>(componentType)) component = &AddComponent<CSpotLight>(); |
| 604 | else if (IsType<CAmbientBoxLight>(componentType)) component = &AddComponent<CAmbientBoxLight>(); |
| 605 | else if (IsType<CAmbientSphereLight>(componentType)) component = &AddComponent<CAmbientSphereLight>(); |
| 606 | else if (IsType<CPostProcessStack>(componentType)) component = &AddComponent<CPostProcessStack>(); |
| 607 | else if (IsType<CReflectionProbe>(componentType)) component = &AddComponent<CReflectionProbe>(); |
| 608 | else if (IsType<CSkinnedMeshRenderer>(componentType)) component = &AddComponent<CSkinnedMeshRenderer>(); |
| 609 | |
| 610 | if (component) |
| 611 | { |
| 612 | component->OnDeserialize(p_doc, currentComponent->FirstChildElement("data")); |
| 613 | } |
| 614 | |
| 615 | currentComponent = currentComponent->NextSiblingElement("component"); |
| 616 | } |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | { |
| 621 | tinyxml2::XMLNode* behavioursRoot = p_actorsRoot->FirstChildElement("behaviours"); |
no test coverage detected