EntityReferenceComponentController.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <Scripting/EntityReferenceComponentController.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EntityReferenceComponentController::Reflect(AZ::ReflectContext* context)
  15. {
  16. EntityReferenceComponentConfig::Reflect(context);
  17. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EntityReferenceComponentController>()
  20. ->Version(0)
  21. ->Field("Configuration", &EntityReferenceComponentController::m_configuration);
  22. }
  23. }
  24. void EntityReferenceComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  25. {
  26. provided.push_back(AZ_CRC_CE("EntityReferenceService"));
  27. }
  28. void EntityReferenceComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  29. {
  30. incompatible.push_back(AZ_CRC_CE("EntityReferenceService"));
  31. }
  32. EntityReferenceComponentController::EntityReferenceComponentController(const EntityReferenceComponentConfig& config)
  33. : m_configuration(config)
  34. {
  35. }
  36. void EntityReferenceComponentController::Activate(EntityId entityId)
  37. {
  38. m_entityId = entityId;
  39. EntityReferenceRequestBus::Handler::BusConnect(m_entityId);
  40. }
  41. void EntityReferenceComponentController::Deactivate()
  42. {
  43. EntityReferenceRequestBus::Handler::BusDisconnect(m_entityId);
  44. m_entityId.SetInvalid();
  45. }
  46. void EntityReferenceComponentController::SetConfiguration(const EntityReferenceComponentConfig& config)
  47. {
  48. m_configuration = config;
  49. }
  50. AZStd::vector<EntityId> EntityReferenceComponentController::GetEntityReferences() const
  51. {
  52. return m_configuration.m_entityIdReferences;
  53. }
  54. }
  55. }