${Name}Component.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // {BEGIN_LICENSE}
  2. /*
  3. * Copyright (c) Contributors to the Open 3D Engine Project.
  4. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. // {END_LICENSE}
  10. #include <${SanitizedCppName}Component.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. #include <AzCore/Serialization/EditContext.h>
  13. #include <AzCore/RTTI/BehaviorContext.h>
  14. namespace ${GemName}
  15. {
  16. AZ_COMPONENT_IMPL(${SanitizedCppName}Component, "${SanitizedCppName}Component", "{${Random_Uuid}}");
  17. void ${SanitizedCppName}Component::Activate()
  18. {
  19. ${SanitizedCppName}RequestBus::Handler::BusConnect(GetEntityId());
  20. }
  21. void ${SanitizedCppName}Component::Deactivate()
  22. {
  23. ${SanitizedCppName}RequestBus::Handler::BusDisconnect(GetEntityId());
  24. }
  25. void ${SanitizedCppName}Component::Reflect(AZ::ReflectContext* context)
  26. {
  27. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  28. {
  29. serializeContext->Class<${SanitizedCppName}Component, AZ::Component>()
  30. ->Version(1)
  31. ;
  32. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  33. {
  34. editContext->Class<${SanitizedCppName}Component>("${SanitizedCppName}Component", "[Description of functionality provided by this component]")
  35. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  36. ->Attribute(AZ::Edit::Attributes::Category, "ComponentCategory")
  37. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg")
  38. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  39. ;
  40. }
  41. }
  42. if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
  43. {
  44. behaviorContext->Class<${SanitizedCppName}Component>("${SanitizedCppName} Component Group")
  45. ->Attribute(AZ::Script::Attributes::Category, "${GemName} Gem Group")
  46. ;
  47. }
  48. }
  49. void ${SanitizedCppName}Component::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  50. {
  51. provided.push_back(AZ_CRC_CE("${SanitizedCppName}ComponentService"));
  52. }
  53. void ${SanitizedCppName}Component::GetIncompatibleServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  54. {
  55. }
  56. void ${SanitizedCppName}Component::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
  57. {
  58. }
  59. void ${SanitizedCppName}Component::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
  60. {
  61. }
  62. } // namespace ${GemName}