MultiplayerDebugHierarchyReporter.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include <AzCore/Component/EntityBus.h>
  10. #include <AzCore/EBus/ScheduledEvent.h>
  11. #include <AzFramework/Entity/EntityDebugDisplayBus.h>
  12. #include <Multiplayer/Components/NetworkHierarchyRootComponent.h>
  13. namespace Multiplayer
  14. {
  15. /**
  16. * /brief Provides ImGui and debug draw hierarchy information at runtime.
  17. */
  18. class MultiplayerDebugHierarchyReporter
  19. : public AZ::EntitySystemBus::Handler
  20. {
  21. public:
  22. MultiplayerDebugHierarchyReporter();
  23. ~MultiplayerDebugHierarchyReporter() override;
  24. //! Main update loop.
  25. void OnImGuiUpdate();
  26. //! Draws hierarchy information over hierarchy root entities.
  27. void UpdateDebugOverlay();
  28. //! EntitySystemBus overrides.
  29. //! @{
  30. void OnEntityActivated(const AZ::EntityId& entityId) override;
  31. void OnEntityDeactivated(const AZ::EntityId& entityId) override;
  32. //! @}
  33. private:
  34. AZ::ScheduledEvent m_updateDebugOverlay;
  35. AzFramework::DebugDisplayRequests* m_debugDisplay = nullptr;
  36. struct HierarchyRootInfo
  37. {
  38. NetworkHierarchyRootComponent* m_rootComponent = nullptr;
  39. NetworkHierarchyChangedEvent::Handler m_changedEvent;
  40. NetworkHierarchyLeaveEvent::Handler m_leaveEvent;
  41. };
  42. AZStd::unordered_map<NetworkHierarchyRootComponent*, HierarchyRootInfo> m_hierarchyRoots;
  43. void CollectHierarchyRoots();
  44. char m_statusBuffer[100] = {};
  45. float m_awarenessRadius = 1000.f;
  46. };
  47. }