EnergyBallComponent.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/EnergyBallComponent.AutoComponent.h>
  9. #include <Source/Weapons/WeaponGathers.h>
  10. namespace MultiplayerSample
  11. {
  12. class EnergyBallComponent
  13. : public EnergyBallComponentBase
  14. {
  15. public:
  16. AZ_MULTIPLAYER_COMPONENT(MultiplayerSample::EnergyBallComponent, s_energyBallComponentConcreteUuid, MultiplayerSample::EnergyBallComponentBase);
  17. static void Reflect(AZ::ReflectContext* context);
  18. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  19. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  20. #if AZ_TRAIT_CLIENT
  21. void HandleRPC_BallLaunched(AzNetworking::IConnection* invokingConnection, const AZ::Vector3& location) override;
  22. void HandleRPC_BallExplosion(AzNetworking::IConnection* invokingConnection, const HitEvent& hitEvent) override;
  23. #endif
  24. private:
  25. GameEffect m_effect;
  26. };
  27. class EnergyBallComponentController
  28. : public EnergyBallComponentControllerBase
  29. {
  30. public:
  31. explicit EnergyBallComponentController(EnergyBallComponent& parent);
  32. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  33. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  34. #if AZ_TRAIT_SERVER
  35. void HandleRPC_LaunchBall(AzNetworking::IConnection* invokingConnection, const AZ::Vector3& startingPosition, const AZ::Vector3& direction, const Multiplayer::NetEntityId& owningNetEntityId) override;
  36. void HandleRPC_KillBall(AzNetworking::IConnection* invokingConnection) override;
  37. void CheckForCollisions();
  38. void HideEnergyBall();
  39. private:
  40. AZ::ScheduledEvent m_collisionCheckEvent{ [this]()
  41. {
  42. CheckForCollisions();
  43. }, AZ::Name("EnergyBallCheckForCollisions") };
  44. AZ::Vector3 m_direction = AZ::Vector3::CreateZero();
  45. AZ::Transform m_lastSweepTransform = AZ::Transform::CreateIdentity();
  46. Multiplayer::NetEntityId m_shooterNetEntityId = Multiplayer::InvalidNetEntityId;
  47. NetEntityIdSet m_filteredNetEntityIds;
  48. HitEvent m_hitEvent;
  49. #endif
  50. };
  51. }