MultiplayerEditorAutomation.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #include "MultiplayerEditorAutomation.h"
  9. namespace Multiplayer::Automation
  10. {
  11. void MultiplayerEditorAutomationHandler::Reflect(AZ::ReflectContext* context)
  12. {
  13. if (auto* behaviorContext = azdynamic_cast<AZ::BehaviorContext*>(context))
  14. {
  15. // Exposes bus handler to Python automation in the form of azlmbr.<module name>.<ebus name>Handler()
  16. // Example Python code:
  17. // handler = azlmbr.multiplayer.MultiplayerEditorServerNotificationBusHandler()
  18. // handler.connect()
  19. // handler.add_callback("OnServerLaunched", _on_server_launched)
  20. behaviorContext->EBus<MultiplayerEditorServerNotificationBus>("MultiplayerEditorServerNotificationBus")
  21. ->Attribute(AZ::Script::Attributes::Module, "multiplayer")
  22. ->Attribute(AZ::Script::Attributes::Category, "Multiplayer")
  23. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
  24. ->Handler<MultiplayerEditorAutomationHandler>();
  25. }
  26. }
  27. void MultiplayerEditorAutomationHandler::OnServerLaunched()
  28. {
  29. Call(FN_OnServerLaunched);
  30. }
  31. void MultiplayerEditorAutomationHandler::OnServerLaunchFail()
  32. {
  33. Call(FN_OnServerLaunchFail);
  34. }
  35. void MultiplayerEditorAutomationHandler::OnEditorConnectionAttempt(uint16_t connectionAttempts, uint16_t maxAttempts)
  36. {
  37. Call(FN_OnEditorConnectionAttempt, connectionAttempts, maxAttempts);
  38. }
  39. void MultiplayerEditorAutomationHandler::OnEditorConnectionAttemptsFailed(uint16_t failedAttempts)
  40. {
  41. Call(FN_OnEditorConnectionAttemptsFailed, failedAttempts);
  42. }
  43. void MultiplayerEditorAutomationHandler::OnEditorSendingLevelData(uint32_t bytesSent, uint32_t bytesTotal)
  44. {
  45. Call(FN_OnEditorSendingLevelData, bytesSent, bytesTotal);
  46. }
  47. void MultiplayerEditorAutomationHandler::OnEditorSendingLevelDataFailed()
  48. {
  49. Call(FN_OnEditorSendingLevelDataFailed);
  50. }
  51. void MultiplayerEditorAutomationHandler::OnEditorSendingLevelDataSuccess()
  52. {
  53. Call(FN_OnEditorSendingLevelDataSuccess);
  54. }
  55. void MultiplayerEditorAutomationHandler::OnConnectToSimulationSuccess()
  56. {
  57. Call(FN_OnConnectToSimulationSuccess);
  58. }
  59. void MultiplayerEditorAutomationHandler::OnConnectToSimulationFail(uint16_t serverPort)
  60. {
  61. Call(FN_OnConnectToSimulationFail, serverPort);
  62. }
  63. void MultiplayerEditorAutomationHandler::OnPlayModeEnd()
  64. {
  65. Call(FN_OnPlayModeEnd);
  66. }
  67. void MultiplayerEditorAutomationHandler::OnEditorServerProcessStoppedUnexpectedly()
  68. {
  69. Call(FN_OnEditorServerProcessStoppedUnexpectedly);
  70. }
  71. } // namespace Multiplayer::Automation