EditorRandomTimedSpawnerComponent.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
  10. #include <LmbrCentral/Scripting/RandomTimedSpawnerComponentBus.h>
  11. #include "RandomTimedSpawnerComponent.h"
  12. namespace LmbrCentral
  13. {
  14. class EditorRandomTimedSpawnerConfiguration
  15. : public RandomTimedSpawnerConfiguration
  16. {
  17. public:
  18. AZ_TYPE_INFO(EditorRandomTimedSpawnerConfiguration, "{AA68F544-917B-4F72-AEA7-3A906B9DEB2B}");
  19. AZ_CLASS_ALLOCATOR(EditorRandomTimedSpawnerConfiguration, AZ::SystemAllocator);
  20. static void Reflect(AZ::ReflectContext* context);
  21. };
  22. class EditorRandomTimedSpawnerComponent
  23. : public AzToolsFramework::Components::EditorComponentBase
  24. , public RandomTimedSpawnerComponentRequestBus::Handler
  25. {
  26. public:
  27. AZ_COMPONENT(EditorRandomTimedSpawnerComponent, "{6D3E32F0-1971-416B-86DE-4B5EB6E2139E}", AzToolsFramework::Components::EditorComponentBase);
  28. static void Reflect(AZ::ReflectContext* context);
  29. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  30. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  31. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  32. // AZ::Component
  33. void Activate() override;
  34. void Deactivate() override;
  35. // RandomTimedSpawnerComponentRequestBus
  36. void Enable() override { m_config.m_enabled = true; }
  37. void Disable() override { m_config.m_enabled = false; }
  38. void Toggle() override { m_config.m_enabled = !m_config.m_enabled; }
  39. bool IsEnabled() override { return m_config.m_enabled; }
  40. void SetRandomDistribution(AZ::RandomDistributionType randomDistribution) override { m_config.m_randomDistribution = randomDistribution; }
  41. AZ::RandomDistributionType GetRandomDistribution() override { return m_config.m_randomDistribution; }
  42. void SetSpawnDelay(double spawnDelay) override { m_config.m_spawnDelay = spawnDelay; }
  43. double GetSpawnDelay() override { return m_config.m_spawnDelay; }
  44. void SetSpawnDelayVariation(double spawnDelayVariation) override { m_config.m_spawnDelayVariation = spawnDelayVariation; }
  45. double GetSpawnDelayVariation() override { return m_config.m_spawnDelayVariation; }
  46. void BuildGameEntity(AZ::Entity* gameEntity) override;
  47. private:
  48. //Reflected members
  49. EditorRandomTimedSpawnerConfiguration m_config;
  50. };
  51. } //namespace LmbrCentral