ApplePickerComponent.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #include "ApplePickerComponent.h"
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <AzCore/Serialization/EditContextConstants.inl>
  11. namespace AppleKraken
  12. {
  13. namespace Internal
  14. {
  15. AZStd::string TaskString(const PickAppleTask& task)
  16. {
  17. if (!task.m_appleEntityId.IsValid())
  18. {
  19. return "|Task for an unspecified apple|";
  20. }
  21. return AZStd::string::format("|Task for entity id %s|", task.m_appleEntityId.ToString().c_str());
  22. }
  23. AZStd::string CurrentTaskString(const AZStd::queue<PickAppleTask>& taskQueue)
  24. {
  25. if (taskQueue.empty())
  26. {
  27. return "|No task, pick queue empty!|";
  28. }
  29. const auto& currentTask = taskQueue.front();
  30. return TaskString(currentTask);
  31. }
  32. } // namespace Internal
  33. void ApplePickerComponent::StartAutomatedOperation()
  34. {
  35. }
  36. float ApplePickerComponent::ReportProgress()
  37. {
  38. return 0.0f;
  39. }
  40. void ApplePickerComponent::Activate()
  41. {
  42. }
  43. void ApplePickerComponent::Deactivate()
  44. {
  45. }
  46. void ApplePickerComponent::Reflect(AZ::ReflectContext* context)
  47. {
  48. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  49. {
  50. serialize->Class<ApplePickerComponent, AZ::Component>()->Version(1);
  51. if (AZ::EditContext* ec = serialize->GetEditContext())
  52. {
  53. ec->Class<ApplePickerComponent>("Apple picking component", "A demo component for apple picking")
  54. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  55. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game"))
  56. ->Attribute(AZ::Edit::Attributes::Category, "AppleKraken");
  57. }
  58. }
  59. }
  60. void ApplePickerComponent::ApplePicked()
  61. {
  62. AZ_TracePrintf("ApplePicker", "%s. Picked apple\n", Internal::CurrentTaskString(m_currentAppleTasks).c_str());
  63. }
  64. void ApplePickerComponent::AppleRetrieved()
  65. {
  66. AZ_TracePrintf(
  67. "ApplePicker", "%s. An apple has been retrieved and stored\n", Internal::CurrentTaskString(m_currentAppleTasks).c_str());
  68. }
  69. void ApplePickerComponent::PickingFailed(const AZStd::string& reason)
  70. {
  71. AZ_TracePrintf(
  72. "ApplePicker", "%s. Picking failed due to: %s\n", Internal::CurrentTaskString(m_currentAppleTasks).c_str(), reason.c_str());
  73. }
  74. } // namespace AppleKraken