EnergyBallComponent.h 2.4 KB

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