DemoStatisticsComponent.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 "DemoStatisticsNotifications.h"
  10. #include <AzCore/Component/Component.h>
  11. #include <AzCore/Component/EntityId.h>
  12. namespace AppleKraken
  13. {
  14. //! Component responsible for holding simulation statistics such as failed and picked apples, globally.
  15. class DemoStatisticsComponent
  16. : public AZ::Component
  17. , private DemoStatisticsNotificationBus::Handler
  18. {
  19. public:
  20. AZ_COMPONENT(DemoStatisticsComponent, "{C421B635-8B7A-479A-8617-86F5F1ACC4AE}");
  21. DemoStatisticsComponent() = default;
  22. ~DemoStatisticsComponent() = default;
  23. void Activate() override;
  24. void Deactivate() override;
  25. static void Reflect(AZ::ReflectContext* context);
  26. private:
  27. void DisplayNumberOfApples();
  28. void DisplayStatus();
  29. void AddApple(const AppleEvent& appleEvent) override;
  30. void OnApplePickerSpawned(const AZ::EntityId& entityId) override;
  31. void SetApplePickerStatus(const AZ::EntityId& entityId, const AZStd::string& status) override;
  32. bool HasTag(const AppleEvent& appleEvent, const AZStd::string& tag);
  33. bool IsFailed(const Tags& tags);
  34. bool IsAutomated(const Tags& tags);
  35. void UpdateTextField(const AZStd::string& fieldName, const AZStd::string& label, uint16_t counter, bool labelOnly = false);
  36. const AZStd::string m_appleGatheredElementName = "ApplesGathered";
  37. const AZStd::string m_appleFailedElementName = "ApplesFailed";
  38. const AZStd::string m_applePickerCountElementName = "ApplePickerCount";
  39. const AZStd::string m_applePickerStatusElementName = "ApplePickerStatus";
  40. AZ::EntityId m_uiEntity;
  41. struct ApplePickerStatus
  42. {
  43. AZ::EntityId m_entityId;
  44. AZStd::string m_status;
  45. };
  46. AZStd::list<ApplePickerStatus> m_applePickerStatus;
  47. uint16_t m_applesGathered = 0;
  48. uint16_t m_applesFailed = 0;
  49. };
  50. } // namespace AppleKraken