From e475405850d8ed562397e578dbbbb04ab449c2e2 Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Mon, 16 Aug 2021 15:53:55 -0700 Subject: [PATCH 1/2] Updating multiplayer auto-components to require the LocalPredictionPlayerInputComponent service if they use NetworkInputs. Without LocalPredictionPlayerInputComponent CreateInput and ProcessInput will never be called Signed-off-by: Gene Walters --- .../Code/Source/AutoGen/AutoComponent_Source.jinja | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index d2be2f682a..595efd76f4 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -1465,6 +1465,11 @@ namespace {{ Component.attrib['Namespace'] }} {% call(ComponentService) ParseComponentServiceNames(Component, ClassType, 'Required') %} required.push_back(AZ_CRC_CE("{{ ComponentService }}")); {% endcall %} + +{% if NetworkInputCount > 0 %} + // This component uses NetworkInputs so it requires LocalPredictionPlayerInputComponent which is responsible for calling CreateInput and ProcessInput + required.push_back(AZ_CRC_CE("LocalPredictionPlayerInputComponent")); +{% endif %} } void {{ ComponentBaseName }}::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent) From 4374e6177e90c2381dc8bae357be8d82a23d9d5f Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Mon, 16 Aug 2021 20:46:34 -0700 Subject: [PATCH 2/2] Updating service requirement to use a generic 'MultiplayerInputDrive', that way if other developers want to make a non-local predictition player controller that calls create/process on the server they can do so as long as there custom component provides this 'MultiplayerInputDriver' service Signed-off-by: Gene Walters --- .../Components/LocalPredictionPlayerInputComponent.h | 1 + .../Code/Source/AutoGen/AutoComponent_Source.jinja | 6 +++--- .../Components/LocalPredictionPlayerInputComponent.cpp | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Gems/Multiplayer/Code/Include/Multiplayer/Components/LocalPredictionPlayerInputComponent.h b/Gems/Multiplayer/Code/Include/Multiplayer/Components/LocalPredictionPlayerInputComponent.h index fbb7131f76..932418b111 100644 --- a/Gems/Multiplayer/Code/Include/Multiplayer/Components/LocalPredictionPlayerInputComponent.h +++ b/Gems/Multiplayer/Code/Include/Multiplayer/Components/LocalPredictionPlayerInputComponent.h @@ -22,6 +22,7 @@ namespace Multiplayer AZ_MULTIPLAYER_COMPONENT(Multiplayer::LocalPredictionPlayerInputComponent, s_localPredictionPlayerInputComponentConcreteUuid, Multiplayer::LocalPredictionPlayerInputComponentBase); static void Reflect([[maybe_unused]] AZ::ReflectContext* context); + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided); void OnInit() override; void OnActivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override; diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index 595efd76f4..83830fad5f 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -1465,10 +1465,10 @@ namespace {{ Component.attrib['Namespace'] }} {% call(ComponentService) ParseComponentServiceNames(Component, ClassType, 'Required') %} required.push_back(AZ_CRC_CE("{{ ComponentService }}")); {% endcall %} - {% if NetworkInputCount > 0 %} - // This component uses NetworkInputs so it requires LocalPredictionPlayerInputComponent which is responsible for calling CreateInput and ProcessInput - required.push_back(AZ_CRC_CE("LocalPredictionPlayerInputComponent")); + + // This component uses NetworkInputs so it requires a MultiplayerInputDriver service which is responsible for calling CreateInput and ProcessInput + required.push_back(AZ_CRC_CE("MultiplayerInputDriver")); {% endif %} } diff --git a/Gems/Multiplayer/Code/Source/Components/LocalPredictionPlayerInputComponent.cpp b/Gems/Multiplayer/Code/Source/Components/LocalPredictionPlayerInputComponent.cpp index 242db95ecb..a1238c378d 100644 --- a/Gems/Multiplayer/Code/Source/Components/LocalPredictionPlayerInputComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/LocalPredictionPlayerInputComponent.cpp @@ -56,6 +56,12 @@ namespace Multiplayer LocalPredictionPlayerInputComponentBase::Reflect(context); } + void LocalPredictionPlayerInputComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) + { + LocalPredictionPlayerInputComponentBase::GetProvidedServices(provided); + provided.push_back(AZ_CRC_CE("MultiplayerInputDriver")); + } + void LocalPredictionPlayerInputComponent::OnInit() { ;