BsPlayInEditorManager.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 "BsModule.h"
  6. namespace BansheeEngine
  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. /** @cond INTERNAL */
  41. /**
  42. * Called once per frame.
  43. *
  44. * @note Internal method.
  45. */
  46. void update();
  47. /** @endcond */
  48. private:
  49. /**
  50. * Updates the play state of the game, making the game stop or start running. Unlike setState() this will trigger
  51. * the state change right away.
  52. */
  53. void setStateImmediate(PlayInEditorState state);
  54. /** Saves the current state of the scene in memory. */
  55. void saveSceneInMemory();
  56. PlayInEditorState mState;
  57. PlayInEditorState mNextState;
  58. bool mFrameStepActive;
  59. bool mScheduledStateChange;
  60. float mPausableTime;
  61. HSceneObject mSavedScene;
  62. };
  63. /** @} */
  64. }