BsCmdBreakPrefab.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "BsEditorCommand.h"
  6. #include "BsUndoRedo.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief A command used for undo/redo purposes. It breaks a prefab link of a scene object
  11. * and allows you to restore link.
  12. */
  13. class BS_ED_EXPORT CmdBreakPrefab : public EditorCommand
  14. {
  15. public:
  16. ~CmdBreakPrefab();
  17. /**
  18. * @brief Creates and executes the command on the provided scene object.
  19. * Automatically registers the command with undo/redo system.
  20. *
  21. * @param sceneObject Scene object whose prefab link to break.
  22. * @param description Optional description of what exactly the command does.
  23. */
  24. static void execute(const HSceneObject& sceneObject, const WString& description = StringUtil::WBLANK);
  25. /**
  26. * @copydoc EditorCommand::commit
  27. */
  28. void commit() override;
  29. /**
  30. * @copydoc EditorCommand::revert
  31. */
  32. void revert() override;
  33. private:
  34. friend class UndoRedo;
  35. CmdBreakPrefab(const WString& description, const HSceneObject& sceneObject);
  36. /**
  37. * @brief Clears all internal cached data. Should be called whenever a change is commited.
  38. */
  39. void clear();
  40. HSceneObject mSceneObject;
  41. HSceneObject mPrefabRoot;
  42. String mPrefabLinkUUID;
  43. PrefabDiffPtr mPrefabDiff;
  44. UnorderedMap<UINT64, UINT32> mLinkIds;
  45. };
  46. }