IMultiplayerSpawnerMock.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 <Multiplayer/IMultiplayerSpawner.h>
  10. #include <gmock/gmock.h>
  11. // The following is a mock of IMultiplayerSpawner used to test join/leave in MultiplayerSystemComponent
  12. class IMultiplayerSpawnerMock : public Multiplayer::IMultiplayerSpawner
  13. {
  14. public:
  15. IMultiplayerSpawnerMock()
  16. {
  17. ;
  18. }
  19. ~IMultiplayerSpawnerMock() override{};
  20. Multiplayer::NetworkEntityHandle OnPlayerJoin(
  21. [[maybe_unused]] uint64_t userId,
  22. [[maybe_unused]] const Multiplayer::MultiplayerAgentDatum& agentDatum) override
  23. {
  24. ++m_playerCount;
  25. ++m_playerEntityRequestedCount;
  26. return m_networkEntityHandle;
  27. }
  28. void OnPlayerLeave(
  29. [[maybe_unused]] Multiplayer::ConstNetworkEntityHandle entityHandle,
  30. [[maybe_unused]] const Multiplayer::ReplicationSet& replicationSet,
  31. [[maybe_unused]] AzNetworking::DisconnectReason reason) override
  32. {
  33. --m_playerCount;
  34. }
  35. int32_t m_playerCount = 0;
  36. int32_t m_playerEntityRequestedCount = 0;
  37. Multiplayer::NetworkEntityHandle m_networkEntityHandle;
  38. };