AchievementsSystemComponent.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <Achievements/AchievementRequestBus.h>
  11. #include <AzCore/std/parallel/atomic.h>
  12. #include <AzCore/std/string/string.h>
  13. #include <AzCore/Component/TickBus.h>
  14. namespace Achievements
  15. {
  16. ////////////////////////////////////////////////////////////////////////////////////////
  17. // A system component providing an interface to query and unlock achievements
  18. class AchievementsSystemComponent
  19. : public AZ::Component
  20. , protected AchievementRequestBus::Handler
  21. {
  22. public:
  23. ////////////////////////////////////////////////////////////////////////////////////////
  24. // Component setup
  25. AZ_COMPONENT(AchievementsSystemComponent, "{07CFF8FE-668E-476A-95D9-A3B0CCCE2414}");
  26. ////////////////////////////////////////////////////////////////////////////////////////
  27. // Component overrides
  28. static void Reflect(AZ::ReflectContext* context);
  29. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  30. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  31. protected:
  32. ////////////////////////////////////////////////////////////////////////////////////////
  33. // AZ::Component interface implementation
  34. void Activate() override;
  35. void Deactivate() override;
  36. ////////////////////////////////////////////////////////////////////////////////////////
  37. // AchievementsRequestBus interface implementation
  38. void UnlockAchievement(const UnlockAchievementParams& params) override;
  39. void QueryAchievementDetails(const QueryAchievementParams& params) override;
  40. public:
  41. ////////////////////////////////////////////////////////////////////////////////////////
  42. // Base class for platform specific implementations
  43. class Implementation
  44. {
  45. public:
  46. AZ_CLASS_ALLOCATOR(Implementation, AZ::SystemAllocator);
  47. static Implementation* Create(AchievementsSystemComponent& achievementsSystemComponent);
  48. Implementation(AchievementsSystemComponent& achievementsSystemComponent);
  49. AZ_DISABLE_COPY_MOVE(Implementation);
  50. virtual ~Implementation();
  51. virtual void UnlockAchievement(const UnlockAchievementParams& params) = 0;
  52. virtual void QueryAchievementDetails(const QueryAchievementParams& params) = 0;
  53. static void OnUnlockAchievementComplete(const UnlockAchievementParams& params);
  54. static void OnQueryAchievementDetailsComplete(const QueryAchievementParams& params, const AchievementDetails& details);
  55. AchievementsSystemComponent& m_achievementsSystemComponent;
  56. };
  57. private:
  58. ////////////////////////////////////////////////////////////////////////////////////////
  59. // Private pointer to the platform specific implementation
  60. AZStd::unique_ptr<Implementation> m_pimpl;
  61. };
  62. }