NetworkTime.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/NetworkTime/INetworkTime.h>
  10. #include <Multiplayer/NetworkEntity/NetworkEntityHandle.h>
  11. #include <AzCore/Component/Component.h>
  12. #include <AzCore/Console/IConsole.h>
  13. namespace Multiplayer
  14. {
  15. //! Implementation of the INetworkTime interface.
  16. class NetworkTime
  17. : public INetworkTime
  18. {
  19. public:
  20. NetworkTime();
  21. virtual ~NetworkTime();
  22. //! INetworkTime overrides.
  23. //! @{
  24. bool IsTimeRewound() const override;
  25. HostFrameId GetHostFrameId() const override;
  26. HostFrameId GetUnalteredHostFrameId() const override;
  27. void IncrementHostFrameId() override;
  28. AZ::TimeMs GetHostTimeMs() const override;
  29. float GetHostBlendFactor() const override;
  30. AzNetworking::ConnectionId GetRewindingConnectionId() const override;
  31. void ForceSetTime(HostFrameId frameId, AZ::TimeMs timeMs) override;
  32. void AlterTime(HostFrameId frameId, AZ::TimeMs timeMs, float blendFactor, AzNetworking::ConnectionId rewindConnectionId) override;
  33. void SyncEntitiesToRewindState(const AZ::Aabb& rewindVolume) override;
  34. void ClearRewoundEntities() override;
  35. //! @}
  36. private:
  37. AZStd::vector<NetworkEntityHandle> m_rewoundEntities;
  38. HostFrameId m_hostFrameId = HostFrameId{ 0 };
  39. HostFrameId m_unalteredFrameId = HostFrameId{ 0 };
  40. AZ::TimeMs m_hostTimeMs = AZ::Time::ZeroTimeMs;
  41. float m_hostBlendFactor = DefaultBlendFactor;
  42. AzNetworking::ConnectionId m_rewindingConnectionId = AzNetworking::InvalidConnectionId;
  43. };
  44. }