ScriptedEntityTweenerModule.cpp 2.1 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 <IGem.h>
  9. #include <ScriptedEntityTweener/ScriptedEntityTweenerBus.h>
  10. #include "ScriptedEntityTweenerSystemComponent.h"
  11. namespace ScriptedEntityTweener
  12. {
  13. class ScriptedEntityTweenerModule
  14. : public CryHooksModule
  15. {
  16. public:
  17. AZ_RTTI(ScriptedEntityTweenerModule, "{A6A93611-5E4D-4EB5-BFB9-00031F73F59B}", CryHooksModule);
  18. ScriptedEntityTweenerModule()
  19. : CryHooksModule()
  20. {
  21. // Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
  22. m_descriptors.insert(m_descriptors.end(), {
  23. ScriptedEntityTweenerSystemComponent::CreateDescriptor(),
  24. });
  25. }
  26. /**
  27. * Add required SystemComponents to the SystemEntity.
  28. */
  29. AZ::ComponentTypeList GetRequiredSystemComponents() const override
  30. {
  31. return AZ::ComponentTypeList{
  32. azrtti_typeid<ScriptedEntityTweenerSystemComponent>(),
  33. };
  34. }
  35. void OnSystemEvent(ESystemEvent systemEvent, UINT_PTR wparam, UINT_PTR lparam) override
  36. {
  37. CryHooksModule::OnSystemEvent(systemEvent, wparam, lparam);
  38. switch (systemEvent)
  39. {
  40. // In editor mode, ensure ending editor mode clears any in-flight animations
  41. case ESYSTEM_EVENT_GAME_MODE_SWITCH_END:
  42. {
  43. bool inGame = wparam == 1;
  44. if (!inGame)
  45. {
  46. ScriptedEntityTweenerBus::Broadcast(&ScriptedEntityTweenerBus::Events::Reset);
  47. }
  48. } break;
  49. default:
  50. break;
  51. }
  52. }
  53. };
  54. }
  55. #if defined(O3DE_GEM_NAME)
  56. AZ_DECLARE_MODULE_CLASS(AZ_JOIN(Gem_, O3DE_GEM_NAME), ScriptedEntityTweener::ScriptedEntityTweenerModule)
  57. #else
  58. AZ_DECLARE_MODULE_CLASS(Gem_ScriptedEntityTweener, ScriptedEntityTweener::ScriptedEntityTweenerModule)
  59. #endif