ScriptableDecalComponent.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <AzCore/Component/Component.h>
  10. #include <AzCore/Component/TickBus.h>
  11. #include <AzCore/EBus/Event.h>
  12. #include <DecalBus.h>
  13. #include <Atom/Feature/Decals/DecalFeatureProcessorInterface.h>
  14. namespace MultiplayerSample
  15. {
  16. class ScriptableDecalComponent
  17. : public AZ::Component
  18. , public DecalRequestBus::Handler
  19. , public AZ::TickBus::Handler
  20. {
  21. public:
  22. AZ_COMPONENT(MultiplayerSample::ScriptableDecalComponent, "{79AEB56C-E886-4A6A-9BAA-0FE5D6D01F78}");
  23. static void Reflect(AZ::ReflectContext* context);
  24. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  25. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  26. void Activate() override;
  27. void Deactivate() override;
  28. private:
  29. using DecalHandle = AZ::Render::DecalFeatureProcessorInterface::DecalHandle;
  30. struct DecalInstance
  31. {
  32. SpawnDecalConfig m_config;
  33. DecalHandle m_handle;
  34. uint32_t m_animationStartTimeMs = 0;
  35. };
  36. // DecalRequestBus::Handler...
  37. void SpawnDecal(const AZ::Transform& worldTm, const SpawnDecalConfig& config) override;
  38. // TickBus::Handler...
  39. virtual void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  40. static bool HeapCompare(const DecalInstance& value1, const DecalInstance& value2);
  41. AZ::Render::DecalFeatureProcessorInterface* m_decalFeatureProcessor = nullptr;
  42. AZStd::vector<DecalInstance> m_decalHeap;
  43. AZStd::vector<DecalInstance> m_fadingInDecals;
  44. AZStd::vector<DecalInstance> m_fadingOutDecals;
  45. };
  46. }