FruitStorageComponent.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 "FruitStorageBus.h"
  10. #include <AzFramework/Physics/PhysicsSystem.h>
  11. #include <AzCore/Component/Component.h>
  12. #include <AzFramework/AzFrameworkModule.h>
  13. #include <AzFramework/Spawnable/SpawnableEntitiesInterface.h>
  14. namespace AppleKraken
  15. {
  16. //! Component responsible for storing counters of apples gathered by Kraken.
  17. class FruitStorageComponent
  18. : public AZ::Component
  19. , public FruitStorageRequestsBus::Handler
  20. {
  21. public:
  22. AZ_COMPONENT(FruitStorageComponent, "{9AC0B456-9C29-4EDD-AD25-6FAA57D253C5}", AZ::Component);
  23. FruitStorageComponent() = default;
  24. ~FruitStorageComponent() = default;
  25. void Activate() override;
  26. void Deactivate() override;
  27. static void Reflect(AZ::ReflectContext* context);
  28. ApplesGatheredByTag GetTotalGatheredAppleCount(const Tags& tags = {}) const override;
  29. uint32_t GetCurrentStorageAppleCount() const override;
  30. void AddApple(const Tags& tags = {}) override;
  31. private:
  32. void SpawnCrate();
  33. void PreSpawn(AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableEntityContainerView);
  34. AZ::Data::Asset<AzFramework::Spawnable> m_crateSpawnable;
  35. AzFramework::EntitySpawnTicket m_crateTicket;
  36. AZ::EntityId m_crateDropPoint;
  37. uint32_t m_crateCapacity = 0;
  38. uint32_t m_applesGathered = 0;
  39. uint32_t m_applesInStorage = 0;
  40. ApplesGatheredByTag m_tagsStored;
  41. };
  42. } // namespace AppleKraken