EditorSpawnerComponent.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 <AzCore/Slice/SliceAsset.h>
  11. namespace LmbrCentral
  12. {
  13. /**
  14. * Editor spawner component
  15. * Spawns the entities from a ".dynamicslice" asset at runtime.
  16. */
  17. class EditorSpawnerComponent
  18. : public AzToolsFramework::Components::EditorComponentBase
  19. {
  20. public:
  21. AZ_EDITOR_COMPONENT(EditorSpawnerComponent, "{77CDE991-EC1A-B7C1-B112-7456ABAC81A1}", EditorComponentBase);
  22. static void Reflect(AZ::ReflectContext* context);
  23. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType&);
  24. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType&);
  25. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType&);
  26. bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
  27. bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
  28. void BuildGameEntity(AZ::Entity* gameEntity) override;
  29. protected:
  30. //////////////////////////////////////////////////////////////////////////
  31. // Data changed validation methods
  32. AZ::u32 SliceAssetChanged();
  33. AZ::u32 SpawnOnActivateChanged();
  34. bool HasInfiniteLoop();
  35. //////////////////////////////////////////////////////////////////////////
  36. // Serialized members
  37. AZ::Data::Asset<AZ::DynamicSliceAsset> m_sliceAsset{ AZ::Data::AssetLoadBehavior::PreLoad };
  38. bool m_spawnOnActivate = false;
  39. bool m_destroyOnDeactivate = false;
  40. };
  41. } // namespace LmbrCentral