PropertySubscriber.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 <AzNetworking/Utilities/NetworkCommon.h>
  10. namespace AzNetworking
  11. {
  12. class ISerializer;
  13. }
  14. namespace Multiplayer
  15. {
  16. class NetBindComponent;
  17. class EntityReplicationManager;
  18. //! @class PropertySubscriber
  19. //! @brief Private helper class for the EntityReplicator to help manage applying entity adds/updates/deletes to subscribers
  20. class PropertySubscriber
  21. {
  22. public:
  23. PropertySubscriber(EntityReplicationManager& replicationManager, NetBindComponent* netBindComponent);
  24. bool IsDeleting() const;
  25. bool IsDeleted() const;
  26. void SetDeleting();
  27. bool IsPacketIdValid(AzNetworking::PacketId packetId) const;
  28. AzNetworking::PacketId GetLastReceivedPacketId() const;
  29. bool HandlePropertyChangeMessage(AzNetworking::PacketId packetId, AzNetworking::ISerializer* serializer, bool notifyChanges = true);
  30. private:
  31. EntityReplicationManager& m_replicationManager;
  32. NetBindComponent* m_netBindComponent;
  33. // The last packet to have been received about this entity
  34. AzNetworking::PacketId m_lastReceivedPacketId = AzNetworking::InvalidPacketId;
  35. AZ::TimeMs m_markForRemovalTimeMs = AZ::Time::ZeroTimeMs;
  36. };
  37. }