WhiteBoxSystemComponent.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #include "Asset/WhiteBoxMeshAssetHandler.h"
  9. #include "Rendering/Atom/WhiteBoxAtomRenderMesh.h"
  10. #include "WhiteBoxSystemComponent.h"
  11. #include <AzCore/Serialization/EditContext.h>
  12. #include <AzCore/Serialization/SerializeContext.h>
  13. namespace WhiteBox
  14. {
  15. void WhiteBoxSystemComponent::Reflect(AZ::ReflectContext* context)
  16. {
  17. if (auto serialize = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serialize->Class<WhiteBoxSystemComponent, AZ::Component>()->Version(0);
  20. if (AZ::EditContext* ec = serialize->GetEditContext())
  21. {
  22. ec->Class<WhiteBoxSystemComponent>(
  23. "WhiteBox", "[Description of functionality provided by this System Component]")
  24. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  25. ->Attribute(AZ::Edit::Attributes::AutoExpand, true);
  26. }
  27. }
  28. }
  29. WhiteBoxSystemComponent::WhiteBoxSystemComponent() = default;
  30. WhiteBoxSystemComponent::~WhiteBoxSystemComponent() = default;
  31. void WhiteBoxSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  32. {
  33. provided.push_back(AZ_CRC_CE("WhiteBoxService"));
  34. }
  35. void WhiteBoxSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  36. {
  37. incompatible.push_back(AZ_CRC_CE("WhiteBoxService"));
  38. }
  39. void WhiteBoxSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& /*required*/) {}
  40. void WhiteBoxSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& /*dependent*/) {}
  41. void WhiteBoxSystemComponent::Activate()
  42. {
  43. // default builder
  44. SetRenderMeshInterfaceBuilder(
  45. [](AZ::EntityId entityId) -> AZStd::unique_ptr<RenderMeshInterface>
  46. {
  47. return AZStd::make_unique<AtomRenderMesh>(entityId);
  48. });
  49. WhiteBoxRequestBus::Handler::BusConnect();
  50. }
  51. void WhiteBoxSystemComponent::Deactivate()
  52. {
  53. WhiteBoxRequestBus::Handler::BusDisconnect();
  54. m_assetHandlers.clear();
  55. }
  56. AZStd::unique_ptr<RenderMeshInterface> WhiteBoxSystemComponent::CreateRenderMeshInterface(AZ::EntityId entityId)
  57. {
  58. return m_renderMeshInterfaceBuilder(entityId);
  59. }
  60. void WhiteBoxSystemComponent::SetRenderMeshInterfaceBuilder(RenderMeshInterfaceBuilderFn builder)
  61. {
  62. m_renderMeshInterfaceBuilder = AZStd::move(builder);
  63. }
  64. } // namespace WhiteBox