MultiplayerSampleSystemComponent.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #include "MultiplayerSampleSystemComponent.h"
  8. #include <AzCore/Console/ILogger.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/Serialization/EditContext.h>
  11. #include <AzCore/Serialization/EditContextConstants.inl>
  12. #include <AzNetworking/Framework/INetworking.h>
  13. #include <Source/AutoGen/AutoComponentTypes.h>
  14. namespace MultiplayerSample
  15. {
  16. using namespace AzNetworking;
  17. void MultiplayerSampleSystemComponent::Reflect(AZ::ReflectContext* context)
  18. {
  19. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  20. {
  21. serialize->Class<MultiplayerSampleSystemComponent, AZ::Component>()
  22. ->Version(0)
  23. ;
  24. if (AZ::EditContext* ec = serialize->GetEditContext())
  25. {
  26. ec->Class<MultiplayerSampleSystemComponent>("MultiplayerSample", "[Description of functionality provided by this System Component]")
  27. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  28. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
  29. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  30. ;
  31. }
  32. }
  33. }
  34. void MultiplayerSampleSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  35. {
  36. provided.push_back(AZ_CRC_CE("MultiplayerSampleService"));
  37. }
  38. void MultiplayerSampleSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  39. {
  40. incompatible.push_back(AZ_CRC_CE("MultiplayerSampleService"));
  41. }
  42. void MultiplayerSampleSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  43. {
  44. required.push_back(AZ_CRC_CE("NetworkingService"));
  45. required.push_back(AZ_CRC_CE("MultiplayerService"));
  46. }
  47. void MultiplayerSampleSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  48. {
  49. AZ_UNUSED(dependent);
  50. }
  51. void MultiplayerSampleSystemComponent::Init()
  52. {
  53. ;
  54. }
  55. void MultiplayerSampleSystemComponent::Activate()
  56. {
  57. AZ::TickBus::Handler::BusConnect();
  58. //! Register our gems multiplayer components to assign NetComponentIds
  59. RegisterMultiplayerComponents();
  60. }
  61. void MultiplayerSampleSystemComponent::Deactivate()
  62. {
  63. AZ::TickBus::Handler::BusDisconnect();
  64. }
  65. void MultiplayerSampleSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
  66. {
  67. ;
  68. }
  69. int MultiplayerSampleSystemComponent::GetTickOrder()
  70. {
  71. // Tick immediately after the multiplayer system component
  72. return AZ::TICK_PLACEMENT + 2;
  73. }
  74. }