LoadScreenBus.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #pragma once
  9. #define AZ_LOADSCREENCOMPONENT_ENABLED (1)
  10. #if AZ_LOADSCREENCOMPONENT_ENABLED
  11. #include <AzCore/Component/ComponentBus.h>
  12. class LoadScreenInterface
  13. : public AZ::ComponentBus
  14. {
  15. public:
  16. using MutexType = AZStd::recursive_mutex;
  17. //! Invoked when the load screen should be updated and rendered. Single threaded loading only.
  18. virtual void UpdateAndRender() = 0;
  19. //! Invoked when the game load screen should become visible.
  20. virtual void GameStart() = 0;
  21. //! Invoked when the level load screen should become visible.
  22. virtual void LevelStart() = 0;
  23. //! Invoked when the load screen should be paused.
  24. virtual void Pause() = 0;
  25. //! Invoked when the load screen should be resumed.
  26. virtual void Resume() = 0;
  27. //! Invoked when the load screen should be stopped.
  28. virtual void Stop() = 0;
  29. //! Invoked to find out if loading screen is playing.
  30. virtual bool IsPlaying() = 0;
  31. };
  32. using LoadScreenBus = AZ::EBus<LoadScreenInterface>;
  33. //! Interface for notifying load screen providers that specific load events are happening.
  34. //! This is meant to notify systems to connect/disconnect to the LoadScreenUpdateNotificationBus if necessary.
  35. struct LoadScreenNotifications
  36. : public AZ::EBusTraits
  37. {
  38. //! Invoked when the game/engine loading starts. Returns true if any provider handles this.
  39. virtual bool NotifyGameLoadStart(bool usingLoadingThread) = 0;
  40. //! Invoked when level loading starts. Returns true if any provider handles this.
  41. virtual bool NotifyLevelLoadStart(bool usingLoadingThread) = 0;
  42. //! Invoked when loading finishes.
  43. virtual void NotifyLoadEnd() = 0;
  44. };
  45. using LoadScreenNotificationBus = AZ::EBus<LoadScreenNotifications>;
  46. //! Interface for triggering load screen updates and renders. Has different methods for single threaded vs multi threaded.
  47. //! This is a separate bus from the LoadScreenNotificationBus to avoid threading issues and to allow implementers to conditionally attach
  48. //! from inside LoadScreenNotificationBus::NotifyGameLoadStart/NotifyLevelLoadStart
  49. struct LoadScreenUpdateNotifications
  50. : public AZ::EBusTraits
  51. {
  52. //! Invoked when the load screen should be updated and rendered. Single threaded loading only.
  53. virtual void UpdateAndRender(float deltaTimeInSeconds) = 0;
  54. //! Invoked when the load screen should be updated. Multi-threaded loading only.
  55. virtual void LoadThreadUpdate(float deltaTimeInSeconds) = 0;
  56. //! Invoked when the load screen should be updated. Multi-threaded loading only.
  57. virtual void LoadThreadRender() = 0;
  58. };
  59. using LoadScreenUpdateNotificationBus = AZ::EBus<LoadScreenUpdateNotifications>;
  60. #endif // if AZ_LOADSCREENCOMPONENT_ENABLED