NetworkSimplePlayerCameraComponent.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/NetworkSimplePlayerCameraComponent.AutoComponent.h>
  9. #include <AzCore/Component/TickBus.h>
  10. #include <AzFramework/Physics/Common/PhysicsTypes.h>
  11. namespace AzPhysics
  12. {
  13. class SceneInterface;
  14. }
  15. namespace MultiplayerSample
  16. {
  17. class NetworkSimplePlayerCameraComponentController
  18. : public NetworkSimplePlayerCameraComponentControllerBase
  19. , private AZ::TickBus::Handler
  20. {
  21. public:
  22. NetworkSimplePlayerCameraComponentController(NetworkSimplePlayerCameraComponent& parent);
  23. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating);
  24. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating);
  25. float GetCameraYaw() const;
  26. float GetCameraPitch() const;
  27. float GetCameraRoll() const;
  28. float GetCameraYawPrevious() const;
  29. float GetCameraPitchPrevious() const;
  30. float GetCameraRollPrevious() const;
  31. AZ::Transform GetCameraTransform(bool collisionEnabled) const;
  32. void SetSprintMode(bool sprintMode);
  33. private:
  34. //! AZ::TickBus interface
  35. //! @{
  36. void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  37. int GetTickOrder() override;
  38. //! @}
  39. void ApplySpringArm(AZ::Transform& inOutTransform) const;
  40. AZ::Entity* m_activeCameraEntity = nullptr;
  41. bool m_aiEnabled = false;
  42. bool m_sprinting = false;
  43. float m_originalFov = 0.0f;
  44. float m_currentFov = 0.0f;
  45. float m_currentZoom = 0.0f;
  46. AzPhysics::SceneInterface* m_physicsSceneInterface = nullptr;
  47. AzPhysics::SceneHandle m_physicsSceneHandle = AzPhysics::InvalidSceneHandle;
  48. mutable float m_springArmDist = 0.0f;
  49. };
  50. }