PrefabGroupBehavior.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <PrefabGroup/PrefabGroup.h>
  10. #include <AzCore/Memory/Memory.h>
  11. #include <AzCore/Memory/SystemAllocator.h>
  12. #include <AzCore/std/containers/vector.h>
  13. #include <AzCore/std/smart_ptr/shared_ptr.h>
  14. #include <AzCore/IO/Path/Path.h>
  15. #include <SceneAPI/SceneCore/Events/ProcessingResult.h>
  16. #include <SceneAPI/SceneCore/Components/BehaviorComponent.h>
  17. #include <AzCore/JSON/rapidjson.h>
  18. namespace AZ
  19. {
  20. class ReflectContext;
  21. }
  22. namespace AZ::SceneAPI::Events
  23. {
  24. class PreExportEventContext;
  25. }
  26. namespace AZ::SceneAPI::Behaviors
  27. {
  28. class PrefabGroupBehavior
  29. : public SceneCore::BehaviorComponent
  30. {
  31. public:
  32. AZ_COMPONENT(PrefabGroupBehavior, "{13DC2819-CAC2-4977-91D7-C870087072AB}", SceneCore::BehaviorComponent);
  33. ~PrefabGroupBehavior() override = default;
  34. void Activate() override;
  35. void Deactivate() override;
  36. static void Reflect(ReflectContext* context);
  37. private:
  38. Events::ProcessingResult OnPrepareForExport(Events::PreExportEventContext& context) const;
  39. AZStd::unique_ptr<rapidjson::Document> CreateProductAssetData(const SceneData::PrefabGroup* prefabGroup, const AZ::IO::Path& relativePath) const;
  40. bool WriteOutProductAsset(
  41. Events::PreExportEventContext& context,
  42. const SceneData::PrefabGroup* prefabGroup,
  43. const rapidjson::Document& doc) const;
  44. bool WriteOutProductAssetFile(
  45. const AZStd::string& filePath,
  46. Events::PreExportEventContext& context,
  47. const SceneData::PrefabGroup* prefabGroup,
  48. const rapidjson::Document& doc,
  49. bool debug) const;
  50. struct ExportEventHandler;
  51. AZStd::shared_ptr<ExportEventHandler> m_exportEventHandler;
  52. static constexpr int s_prefabGroupPreferredTabOrder{ 6 };
  53. };
  54. }