NetworkStressTestComponent.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of
  3. * this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <Source/AutoGen/NetworkStressTestComponent.AutoComponent.h>
  10. #if defined(IMGUI_ENABLED)
  11. #include <imgui/imgui.h>
  12. #include <ImGuiBus.h>
  13. #endif
  14. namespace MultiplayerSample
  15. {
  16. class NetworkStressTestComponent
  17. : public NetworkStressTestComponentBase
  18. {
  19. public:
  20. AZ_MULTIPLAYER_COMPONENT(MultiplayerSample::NetworkStressTestComponent, s_networkStressTestComponentConcreteUuid, MultiplayerSample::NetworkStressTestComponentBase);
  21. static void Reflect(AZ::ReflectContext* context);
  22. void OnInit() override;
  23. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  24. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  25. };
  26. class NetworkStressTestComponentController
  27. : public NetworkStressTestComponentControllerBase
  28. #if defined(IMGUI_ENABLED)
  29. , public ImGui::ImGuiUpdateListenerBus::Handler
  30. #endif
  31. {
  32. public:
  33. using NetworkStressTestComponentControllerBase::NetworkStressTestComponentControllerBase;
  34. NetworkStressTestComponentController(NetworkStressTestComponent& owner);
  35. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  36. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  37. #if AZ_TRAIT_SERVER
  38. void HandleSpawnAiEntity();
  39. void HandleSpawnAIEntity(
  40. AzNetworking::IConnection* invokingConnection,
  41. const float& fireIntervalMinMs,
  42. const float& fireIntervalMaxMs,
  43. const float& actionIntervalMinMs,
  44. const float& actionIntervalMaxMs,
  45. const int& teamId);
  46. #endif
  47. #if defined(IMGUI_ENABLED)
  48. void OnImGuiMainMenuUpdate() override;
  49. void OnImGuiUpdate() override;
  50. #endif
  51. private:
  52. #if defined(IMGUI_ENABLED)
  53. void DrawEntitySpawner();
  54. bool m_displayEntitySpawner = false;
  55. #endif
  56. [[maybe_unused]] bool m_isServer = false;
  57. [[maybe_unused]] int m_quantity = 1;
  58. [[maybe_unused]] float m_fireIntervalMinMs = 100.f;
  59. [[maybe_unused]] float m_fireIntervalMaxMs = 10000.f;
  60. [[maybe_unused]] float m_actionIntervalMinMs = 500.f;
  61. [[maybe_unused]] float m_actionIntervalMaxMs = 10000.f;
  62. [[maybe_unused]] int m_teamID = 0;
  63. #if AZ_TRAIT_SERVER
  64. AZ::ScheduledEvent m_autoSpawnTimer;
  65. #endif
  66. };
  67. } // namespace MultiplayerSample