EmptyInstanceSpawner.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <Vegetation/EmptyInstanceSpawner.h>
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <AzCore/RTTI/BehaviorContext.h>
  11. #include <AzFramework/StringFunc/StringFunc.h>
  12. #include <Vegetation/Ebuses/DescriptorNotificationBus.h>
  13. #include <Vegetation/Ebuses/InstanceSystemRequestBus.h>
  14. #include <Vegetation/InstanceData.h>
  15. namespace Vegetation
  16. {
  17. void EmptyInstanceSpawner::Reflect(AZ::ReflectContext* context)
  18. {
  19. AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
  20. if (serialize)
  21. {
  22. serialize->Class<EmptyInstanceSpawner, InstanceSpawner>()
  23. ->Version(1)
  24. ;
  25. AZ::EditContext* edit = serialize->GetEditContext();
  26. if (edit)
  27. {
  28. edit->Class<EmptyInstanceSpawner>(
  29. "Empty Space", "Empty Space Instance")
  30. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  31. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  32. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  33. ;
  34. }
  35. }
  36. if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
  37. {
  38. behaviorContext->Class<EmptyInstanceSpawner>()
  39. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
  40. ->Attribute(AZ::Script::Attributes::Category, "Vegetation")
  41. ->Attribute(AZ::Script::Attributes::Module, "vegetation")
  42. ->Constructor()
  43. // Dummy method needed for Python binding system to correctly register the type
  44. ->Method("IsEmpty", [](EmptyInstanceSpawner*) -> bool { return true; } )
  45. ;
  46. }
  47. }
  48. bool EmptyInstanceSpawner::DataIsEquivalent(const InstanceSpawner & baseRhs) const
  49. {
  50. if (azrtti_cast<const EmptyInstanceSpawner*>(&baseRhs))
  51. {
  52. return true;
  53. }
  54. // Not the same subtypes, so definitely not a data match.
  55. return false;
  56. }
  57. } // namespace Vegetation