NetworkRigidBodyComponent.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 this distribution.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0 OR MIT
  5. *
  6. */
  7. #pragma once
  8. #include <Source/AutoGen/NetworkRigidBodyComponent.AutoComponent.h>
  9. #include <AzCore/Component/TransformBus.h>
  10. #include <Multiplayer/Components/NetBindComponent.h>
  11. namespace Physics
  12. {
  13. class RigidBodyRequests;
  14. }
  15. namespace MultiplayerSample
  16. {
  17. class NetworkRigidBodyComponent final : public NetworkRigidBodyComponentBase
  18. {
  19. public:
  20. AZ_MULTIPLAYER_COMPONENT(
  21. MultiplayerSample::NetworkRigidBodyComponent, s_networkRigidBodyComponentConcreteUuid, MultiplayerSample::NetworkRigidBodyComponentBase);
  22. static void Reflect(AZ::ReflectContext* context);
  23. NetworkRigidBodyComponent();
  24. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  25. {
  26. required.push_back(AZ_CRC_CE("PhysXRigidBodyService"));
  27. }
  28. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  29. {
  30. required.push_back(AZ_CRC_CE("TransformService"));
  31. required.push_back(AZ_CRC_CE("PhysXRigidBodyService"));
  32. }
  33. void OnInit() override;
  34. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  35. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  36. private:
  37. void OnTransformUpdate(const AZ::Transform& worldTm);
  38. void OnSyncRewind();
  39. Multiplayer::EntitySyncRewindEvent::Handler m_syncRewindHandler;
  40. AZ::TransformChangedEvent::Handler m_transformChangedHandler;
  41. Physics::RigidBodyRequests* m_physicsRigidBodyComponent = nullptr;
  42. Multiplayer::RewindableObject<AZ::Transform, Multiplayer::RewindHistorySize> m_transform;
  43. };
  44. } // namespace MultiplayerSample