BsCmdBreakPrefab.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 "UndoRedo/BsEditorCommand.h"
  6. #include "UndoRedo/BsUndoRedo.h"
  7. namespace bs
  8. {
  9. /** @addtogroup UndoRedo
  10. * @{
  11. */
  12. /** A command used for undo/redo purposes. It breaks a prefab link of a scene object and allows you to restore link. */
  13. class BS_ED_EXPORT CmdBreakPrefab final : public EditorCommand
  14. {
  15. public:
  16. ~CmdBreakPrefab();
  17. /**
  18. * Creates and executes the command on the provided scene object. Automatically registers the command with undo/redo
  19. * system.
  20. *
  21. * @param[in] sceneObject Scene object whose prefab link to break.
  22. * @param[in] description Optional description of what exactly the command does.
  23. */
  24. static void execute(const HSceneObject& sceneObject, const String& description = StringUtil::BLANK);
  25. /** @copydoc EditorCommand::commit */
  26. void commit() override;
  27. /** @copydoc EditorCommand::revert */
  28. void revert() override;
  29. private:
  30. friend class UndoRedo;
  31. CmdBreakPrefab(const String& description, const HSceneObject& sceneObject);
  32. /** Clears all internal cached data. Should be called whenever a change is commited. */
  33. void clear();
  34. HSceneObject mSceneObject;
  35. HSceneObject mPrefabRoot;
  36. UUID mPrefabLinkUUID;
  37. SPtr<PrefabDiff> mPrefabDiff;
  38. UnorderedMap<UINT64, UINT32> mLinkIds;
  39. };
  40. /** @} */
  41. }