BsPlayInEditorManager.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEnginePrerequisites.h"
  5. #include "Utility/BsModule.h"
  6. namespace bs
  7. {
  8. /** @addtogroup SBansheeEngine
  9. * @{
  10. */
  11. /** States the game in editor can be in. */
  12. enum class PlayInEditorState
  13. {
  14. Stopped,
  15. Playing,
  16. Paused
  17. };
  18. /**
  19. * Handles functionality specific to running the game in editor.
  20. *
  21. * @note
  22. * Play-in-editor functionality is only available for managed code, but can be easily extended to native code if needed
  23. * (this would involve moving play in editor code into BansheeEngine library).
  24. */
  25. class BS_SCR_BE_EXPORT PlayInEditorManager : public Module<PlayInEditorManager>
  26. {
  27. public:
  28. PlayInEditorManager();
  29. /** Returns the current play state of the game. */
  30. PlayInEditorState getState() const { return mState; }
  31. /** Updates the play state of the game, making the game stop or start running. */
  32. void setState(PlayInEditorState state);
  33. /**
  34. * Gets the number of seconds that have elapsed since the game was started. This time does not include time passed
  35. * while the game is paused.
  36. */
  37. float getPausableTime() const { return mPausableTime; }
  38. /** Runs the game for a single frame and then pauses it. */
  39. void frameStep();
  40. /** @name Internal
  41. * @{
  42. */
  43. /**
  44. * Called once per frame.
  45. *
  46. * @note Internal method.
  47. */
  48. void update();
  49. /** @} */
  50. private:
  51. /**
  52. * Updates the play state of the game, making the game stop or start running. Unlike setState() this will trigger
  53. * the state change right away.
  54. */
  55. void setStateImmediate(PlayInEditorState state);
  56. /** Saves the current state of the scene in memory. */
  57. void saveSceneInMemory();
  58. /** Pauses or unpauses all pausable engine systems. */
  59. void setSystemsPauseState(bool paused);
  60. PlayInEditorState mState;
  61. PlayInEditorState mNextState;
  62. bool mFrameStepActive;
  63. bool mScheduledStateChange;
  64. float mPausableTime;
  65. HSceneObject mSavedScene;
  66. };
  67. /** @} */
  68. }