EventData.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <AzCore/Serialization/SerializeContext.h>
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <AzCore/StringFunc/StringFunc.h>
  11. #include <EventData.h>
  12. #include <Allocators.h>
  13. namespace EMotionFX::MotionMatching
  14. {
  15. AZ_CLASS_ALLOCATOR_IMPL(DiscardFrameEventData, MotionEventAllocator)
  16. bool DiscardFrameEventData::Equal([[maybe_unused]]const EventData& rhs, [[maybe_unused]] bool ignoreEmptyFields) const
  17. {
  18. return true;
  19. }
  20. void DiscardFrameEventData::Reflect(AZ::ReflectContext* context)
  21. {
  22. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  23. if (!serializeContext)
  24. {
  25. return;
  26. }
  27. serializeContext->Class<DiscardFrameEventData, EventData>()
  28. ->Version(1)
  29. ;
  30. AZ::EditContext* editContext = serializeContext->GetEditContext();
  31. if (!editContext)
  32. {
  33. return;
  34. }
  35. editContext->Class<DiscardFrameEventData>("[Motion Matching] Discard Frame", "Event used for discarding ranges of the animation..")
  36. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  37. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  38. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  39. ->Attribute(AZ_CRC_CE("Creatable"), true)
  40. ;
  41. }
  42. ///////////////////////////////////////////////////////////////////////////
  43. AZ_CLASS_ALLOCATOR_IMPL(TagEventData, MotionEventAllocator)
  44. bool TagEventData::Equal(const EventData& rhs, [[maybe_unused]] bool ignoreEmptyFields) const
  45. {
  46. const TagEventData* other = azdynamic_cast<const TagEventData*>(&rhs);
  47. if (other)
  48. {
  49. return AZ::StringFunc::Equal(m_tag.c_str(), other->m_tag.c_str(), /*caseSensitive=*/false);
  50. }
  51. return false;
  52. }
  53. void TagEventData::Reflect(AZ::ReflectContext* context)
  54. {
  55. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  56. if (!serializeContext)
  57. {
  58. return;
  59. }
  60. serializeContext->Class<TagEventData, EventData>()
  61. ->Version(1)
  62. ->Field("tag", &TagEventData::m_tag)
  63. ;
  64. AZ::EditContext* editContext = serializeContext->GetEditContext();
  65. if (!editContext)
  66. {
  67. return;
  68. }
  69. editContext->Class<TagEventData>("[Motion Matching] Tag", "")
  70. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  71. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  72. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  73. ->Attribute(AZ_CRC_CE("Creatable"), true)
  74. ->DataElement(AZ::Edit::UIHandlers::Default, &TagEventData::m_tag, "Tag", "The tag that should be active.")
  75. ;
  76. }
  77. } // namespace EMotionFX::MotionMatching