From fa781fabc51691eff176b7edc1ffcc2a991e5327 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Wed, 14 Apr 2021 16:20:45 -0700 Subject: [PATCH 1/6] Add MultiplayerGem Editor components for Ctrl+G support --- Gems/Multiplayer/Code/CMakeLists.txt | 50 ++++++ .../Editor/MultiplayerEditorDispatcher.cpp | 21 +++ .../Editor/MultiplayerEditorDispatcher.h | 36 +++++ .../MultiplayerEditorSystemComponent.cpp | 149 ++++++++++++++++++ .../Editor/MultiplayerEditorSystemComponent.h | 75 +++++++++ .../Code/Source/MultiplayerGem.cpp | 12 +- .../Code/multiplayer_editor_files.cmake | 15 ++ .../multiplayer_editor_shared_files.cmake | 17 ++ 8 files changed, 374 insertions(+), 1 deletion(-) create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h create mode 100644 Gems/Multiplayer/Code/multiplayer_editor_files.cmake create mode 100644 Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt index f811ac64b3..c95afbbb74 100644 --- a/Gems/Multiplayer/Code/CMakeLists.txt +++ b/Gems/Multiplayer/Code/CMakeLists.txt @@ -59,6 +59,56 @@ ly_add_target( Gem::CertificateManager ) +if(PAL_TRAIT_BUILD_HOST_TOOLS) + + ly_add_target( + NAME Multiplayer.Editor.Static STATIC + NAMESPACE Gem + FILES_CMAKE + multiplayer_editor_files.cmake + COMPILE_DEFINITIONS + PUBLIC + MULTIPLAYER_EDITOR + INCLUDE_DIRECTORIES + PRIVATE + . + Source + ${pal_source_dir} + PUBLIC + Include + BUILD_DEPENDENCIES + PUBLIC + Legacy::CryCommon + Legacy::Editor.Headers + AZ::AzCore + AZ::AzFramework + AZ::AzNetworking + AZ::AzToolsFramework + AZ::GFxFramework + Gem::Multiplayer.Static + ) + + ly_add_target( + NAME Multiplayer.Editor GEM_MODULE + NAMESPACE Gem + FILES_CMAKE + multiplayer_editor_shared_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + . + Source + ${pal_source_dir} + PUBLIC + Include + BUILD_DEPENDENCIES + PRIVATE + Gem::Multiplayer.Editor.Static + RUNTIME_DEPENDENCIES + Gem::LmbrCentral.Editor + ) + +endif() + ################################################################################ # Tests ################################################################################ diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp new file mode 100644 index 0000000000..470aa61cd0 --- /dev/null +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp @@ -0,0 +1,21 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + +#include + +namespace Multiplayer +{ + MultiplayerEditorDispatcher::MultiplayerEditorDispatcher() + { + ; + } +} diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h new file mode 100644 index 0000000000..c1058dc8a0 --- /dev/null +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h @@ -0,0 +1,36 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#pragma once + +#include + +#include +#include +#include +#include + +#include + + +namespace Multiplayer +{ + //! MultiplayerEditorDispatcher is responsible for dispatching delta from the Editor to an Editor launched local server + class MultiplayerEditorDispatcher final + { + public: + MultiplayerEditorDispatcher(); + ~MultiplayerEditorDispatcher() = default; + + private: + }; +} diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp new file mode 100644 index 0000000000..0227d8b159 --- /dev/null +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp @@ -0,0 +1,149 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + +#include +#include +#include +#include +#include +#include + +namespace Multiplayer +{ + using namespace AzNetworking; + + AZ_CVAR(bool, editorsv_enabled, true, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, + "Whether Editor launching a local server to connect to is supported"); + AZ_CVAR(AZ::CVarFixedString, editorsv_process, "", nullptr, AZ::ConsoleFunctorFlags::DontReplicate, + "The server executable that should be run. Empty to use the current project's ServerLauncher"); + + void MultiplayerEditorSystemComponent::Reflect(AZ::ReflectContext* context) + { + if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Version(1); + } + } + + void MultiplayerEditorSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) + { + required.push_back(AZ_CRC_CE("MultiplayerService")); + } + + void MultiplayerEditorSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) + { + provided.push_back(AZ_CRC_CE("MultiplayerEditorService")); + } + + void MultiplayerEditorSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) + { + incompatible.push_back(AZ_CRC_CE("MultiplayerEditorService")); + } + + MultiplayerEditorSystemComponent::MultiplayerEditorSystemComponent() + { + ; + } + + void MultiplayerEditorSystemComponent::Activate() + { + AzToolsFramework::EditorEvents::Bus::Handler::BusConnect(); + } + + void MultiplayerEditorSystemComponent::Deactivate() + { + AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect(); + } + + void MultiplayerEditorSystemComponent::NotifyRegisterViews() + { + m_editor = nullptr; + AzToolsFramework::EditorRequests::Bus::BroadcastResult(m_editor, &AzToolsFramework::EditorRequests::GetEditor); + m_editor->RegisterNotifyListener(this); + } + + void MultiplayerEditorSystemComponent::OnEditorNotifyEvent(EEditorNotifyEvent event) + { + switch (event) + { + case eNotify_OnBeginGameMode: + { + AZ::TickBus::Handler::BusConnect(); + + if (editorsv_enabled) + { + // Assemble the server's path + AZ::CVarFixedString serverProcess = editorsv_process; + if (serverProcess.empty()) + { + // If enabled but no process name is supplied, try this project's ServerLauncher + serverProcess = AZ::Utils::GetProjectName() + ".ServerLauncher"; + } + + AZ::IO::FixedMaxPathString serverPath = AZ::Utils::GetExecutableDirectory(); + if (!serverProcess.contains(AZ_TRAIT_OS_PATH_SEPARATOR)) + { + // If only the process name is specified, append that as well + serverPath.append(AZ_TRAIT_OS_PATH_SEPARATOR + serverProcess); + } + else + { + // If any path was already specified, then simply assign + serverPath = serverProcess; + } + + if (!serverProcess.ends_with(AZ_TRAIT_OS_EXECUTABLE_EXTENSION)) + { + // Add this platform's exe extension if it's not specified + serverPath.append(AZ_TRAIT_OS_EXECUTABLE_EXTENSION); + } + + // Start the configured server if it's available + AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo; + processLaunchInfo.m_commandlineParameters = + AZStd::string::format("\"%s\"", serverPath.c_str()); + processLaunchInfo.m_showWindow = true; + processLaunchInfo.m_processPriority = AzFramework::ProcessPriority::PROCESSPRIORITY_NORMAL; + + m_serverProcess = AzFramework::ProcessWatcher::LaunchProcess( + processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE); + } + break; + } + case eNotify_OnQuit: + m_editor->UnregisterNotifyListener(this); + m_editor = nullptr; + // Fall through here as the cleanup steps in EndGameMode are good sanity + case eNotify_OnEndGameMode: + AZ::TickBus::Handler::BusDisconnect(); + // Kill the configured server if it's active + if (m_serverProcess) + { + m_serverProcess->TerminateProcess(0); + m_serverProcess = nullptr; + } + break; + } + } + + void MultiplayerEditorSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) + { + + } + + int MultiplayerEditorSystemComponent::GetTickOrder() + { + // Tick immediately after the network system component + return AZ::TICK_PLACEMENT + 1; + } +} diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h new file mode 100644 index 0000000000..8c18a2e57a --- /dev/null +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h @@ -0,0 +1,75 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#pragma once + +#include + +#include +#include +#include +#include + +#include +#include + + +namespace AzNetworking +{ + class INetworkInterface; +} + +namespace Multiplayer +{ + //! Multiplayer system component wraps the bridging logic between the game and transport layer. + class MultiplayerEditorSystemComponent final + : public AZ::Component + , private AZ::TickBus::Handler + , private AzToolsFramework::EditorEvents::Bus::Handler + , private IEditorNotifyListener + { + public: + AZ_COMPONENT(MultiplayerEditorSystemComponent, "{9F335CC0-5574-4AD3-A2D8-2FAEF356946C}"); + + static void Reflect(AZ::ReflectContext* context); + static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided); + static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); + + MultiplayerEditorSystemComponent(); + ~MultiplayerEditorSystemComponent() override = default; + + //! AZ::Component overrides. + //! @{ + void Activate() override; + void Deactivate() override; + //! @} + + //! EditorEvents::Bus::Handler overrides. + //! @{ + void NotifyRegisterViews() override; + //! @} + + private: + + //! AZ::TickBus::Handler overrides. + //! @{ + void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; + int GetTickOrder() override; + //! @} + //! + void OnEditorNotifyEvent(EEditorNotifyEvent event) override; + + IEditor* m_editor = nullptr; + AzFramework::ProcessWatcher* m_serverProcess = nullptr; + }; +} diff --git a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp index 80f1635bdc..424cb5b14f 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp @@ -15,6 +15,10 @@ #include #include +#ifdef MULTIPLAYER_EDITOR + #include +#endif + namespace Multiplayer { MultiplayerModule::MultiplayerModule() @@ -23,6 +27,9 @@ namespace Multiplayer m_descriptors.insert(m_descriptors.end(), { AzNetworking::NetworkingSystemComponent::CreateDescriptor(), MultiplayerSystemComponent::CreateDescriptor(), +#ifdef MULTIPLAYER_EDITOR + MultiplayerEditorSystemComponent::CreateDescriptor(), +#endif }); } @@ -32,8 +39,11 @@ namespace Multiplayer { azrtti_typeid(), azrtti_typeid(), +#ifdef MULTIPLAYER_EDITOR + azrtti_typeid(), +#endif }; } } -AZ_DECLARE_MODULE_CLASS(Gem_Multiplayer2, Multiplayer::MultiplayerModule); +AZ_DECLARE_MODULE_CLASS(Gem_Multiplayer, Multiplayer::MultiplayerModule); diff --git a/Gems/Multiplayer/Code/multiplayer_editor_files.cmake b/Gems/Multiplayer/Code/multiplayer_editor_files.cmake new file mode 100644 index 0000000000..ce3e3227e0 --- /dev/null +++ b/Gems/Multiplayer/Code/multiplayer_editor_files.cmake @@ -0,0 +1,15 @@ +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + +set(FILES + Source/Editor/MultiplayerEditorDispatcher.cpp + Source/Editor/MultiplayerEditorDispatcher.h +) diff --git a/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake b/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake new file mode 100644 index 0000000000..e0c50f864e --- /dev/null +++ b/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake @@ -0,0 +1,17 @@ +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + +set(FILES + Source/MultiplayerGem.cpp + Source/MultiplayerGem.h + Source/Editor/MultiplayerEditorSystemComponent.cpp + Source/Editor/MultiplayerEditorSystemComponent.h +) From 2309c06709856f0b47e8f2b7e15c905a4ab18a0c Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 15 Apr 2021 14:37:15 -0700 Subject: [PATCH 2/6] Fix merge error in MP Gem Module --- Gems/Multiplayer/Code/Source/MultiplayerGem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp index 13dcf47d04..da199670ea 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp @@ -36,7 +36,6 @@ namespace Multiplayer }); CreateComponentDescriptors(m_descriptors); - }); } AZ::ComponentTypeList MultiplayerModule::GetRequiredSystemComponents() const From 98c8e0780468294e4fbf2b8860bb4b8e6504f383 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 22 Apr 2021 17:54:21 -0700 Subject: [PATCH 3/6] Fixing a white space issue --- Gems/Multiplayer/Code/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt index b5588aecf7..a26f286264 100644 --- a/Gems/Multiplayer/Code/CMakeLists.txt +++ b/Gems/Multiplayer/Code/CMakeLists.txt @@ -58,7 +58,7 @@ ly_add_target( Gem::CertificateManager ) -if(PAL_TRAIT_BUILD_HOST_TOOLS) +if (PAL_TRAIT_BUILD_HOST_TOOLS) ly_add_target( NAME Multiplayer.Tools MODULE From 8d8473774313c6ba9643b71d634d528f20d8d181 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 22 Apr 2021 17:57:54 -0700 Subject: [PATCH 4/6] Disable Ctrl+G server launch by default --- .../Code/Source/Editor/MultiplayerEditorSystemComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp index 0227d8b159..1e2a55c2a6 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp @@ -21,7 +21,7 @@ namespace Multiplayer { using namespace AzNetworking; - AZ_CVAR(bool, editorsv_enabled, true, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, + AZ_CVAR(bool, editorsv_enabled, false, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Whether Editor launching a local server to connect to is supported"); AZ_CVAR(AZ::CVarFixedString, editorsv_process, "", nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The server executable that should be run. Empty to use the current project's ServerLauncher"); From 925928bb20b46bb7ca06b96a077e2ffcf3c6ab06 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Mon, 26 Apr 2021 17:28:49 -0700 Subject: [PATCH 5/6] Add MultiplayerEditorGem to clean up logic plus misc. cleanup --- Gems/Multiplayer/Code/CMakeLists.txt | 3 -- .../MultiplayerEditorSystemComponent.cpp | 11 +++-- .../Code/Source/MultiplayerEditorGem.cpp | 49 +++++++++++++++++++ .../Code/Source/MultiplayerEditorGem.h | 30 ++++++++++++ .../Code/Source/MultiplayerGem.cpp | 12 +---- .../multiplayer_editor_shared_files.cmake | 2 + 6 files changed, 91 insertions(+), 16 deletions(-) create mode 100644 Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp create mode 100644 Gems/Multiplayer/Code/Source/MultiplayerEditorGem.h diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt index a26f286264..4eeee15c47 100644 --- a/Gems/Multiplayer/Code/CMakeLists.txt +++ b/Gems/Multiplayer/Code/CMakeLists.txt @@ -101,7 +101,6 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) AZ::AzFramework AZ::AzNetworking AZ::AzToolsFramework - AZ::GFxFramework Gem::Multiplayer.Static ) @@ -120,8 +119,6 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) BUILD_DEPENDENCIES PRIVATE Gem::Multiplayer.Editor.Static - RUNTIME_DEPENDENCIES - Gem::LmbrCentral.Editor ) endif() diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp index 1e2a55c2a6..aec3e7870f 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp @@ -67,6 +67,7 @@ namespace Multiplayer void MultiplayerEditorSystemComponent::NotifyRegisterViews() { + AZ_Assert(m_editor == nullptr, "NotifyRegisterViews occurred twice!"); m_editor = nullptr; AzToolsFramework::EditorRequests::Bus::BroadcastResult(m_editor, &AzToolsFramework::EditorRequests::GetEditor); m_editor->RegisterNotifyListener(this); @@ -121,9 +122,13 @@ namespace Multiplayer break; } case eNotify_OnQuit: - m_editor->UnregisterNotifyListener(this); - m_editor = nullptr; - // Fall through here as the cleanup steps in EndGameMode are good sanity + AZ_Warning("Multiplayer Editor", m_editor != nullptr, "Multiplayer Editor received On Quit without an Editor pointer."); + if (m_editor) + { + m_editor->UnregisterNotifyListener(this); + m_editor = nullptr; + } + [[fallthrough]]; case eNotify_OnEndGameMode: AZ::TickBus::Handler::BusDisconnect(); // Kill the configured server if it's active diff --git a/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp b/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp new file mode 100644 index 0000000000..29ef0e216f --- /dev/null +++ b/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp @@ -0,0 +1,49 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#include +#include +#include +#include +#include + +#include + +namespace Multiplayer +{ + AZ_CLASS_ALLOCATOR_IMPL(MultiplayerEditorModule, AZ::SystemAllocator, 0) + + MultiplayerEditorModule::MultiplayerEditorModule() + : MultiplayerModule() + { + // Append Editor specific descriptors + m_descriptors.insert( + m_descriptors.end(), + { + MultiplayerEditorSystemComponent::CreateDescriptor(), + }); + } + + MultiplayerEditorModule::~MultiplayerEditorModule() = default; + + AZ::ComponentTypeList MultiplayerEditorModule::GetRequiredSystemComponents() const + { + return AZ::ComponentTypeList + { + azrtti_typeid(), + azrtti_typeid(), + azrtti_typeid(), + }; + } +} // namespace Multiplayer + +AZ_DECLARE_MODULE_CLASS(Gem_MultiplayerEditor, Multiplayer::MultiplayerEditorModule) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.h b/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.h new file mode 100644 index 0000000000..706a87691e --- /dev/null +++ b/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.h @@ -0,0 +1,30 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + +#pragma once + +#include "MultiplayerGem.h" + +namespace Multiplayer +{ + class MultiplayerEditorModule: public MultiplayerModule + { + public: + AZ_CLASS_ALLOCATOR_DECL + AZ_RTTI(MultiplayerEditorModule, "{50273605-2BBF-4D43-A42D-ED140B92B4D4}", MultiplayerModule); + + MultiplayerEditorModule(); + ~MultiplayerEditorModule(); + + AZ::ComponentTypeList GetRequiredSystemComponents() const override; + }; +} // namespace Multiplayer diff --git a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp index d934b30ddc..cafdbf2a09 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp @@ -19,10 +19,6 @@ #include #include -#ifdef MULTIPLAYER_EDITOR - #include -#endif - namespace Multiplayer { MultiplayerModule::MultiplayerModule() @@ -32,9 +28,6 @@ namespace Multiplayer AzNetworking::NetworkingSystemComponent::CreateDescriptor(), MultiplayerSystemComponent::CreateDescriptor(), NetBindComponent::CreateDescriptor(), -#ifdef MULTIPLAYER_EDITOR - MultiplayerEditorSystemComponent::CreateDescriptor(), -#endif NetBindMarkerComponent::CreateDescriptor(), NetworkSpawnableHolderComponent::CreateDescriptor(), }); @@ -48,11 +41,10 @@ namespace Multiplayer { azrtti_typeid(), azrtti_typeid(), -#ifdef MULTIPLAYER_EDITOR - azrtti_typeid(), -#endif }; } } +#if !defined(MULTIPLAYER_EDITOR) AZ_DECLARE_MODULE_CLASS(Gem_Multiplayer, Multiplayer::MultiplayerModule); +#endif diff --git a/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake b/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake index e0c50f864e..2d5611d4b6 100644 --- a/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake +++ b/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake @@ -12,6 +12,8 @@ set(FILES Source/MultiplayerGem.cpp Source/MultiplayerGem.h + Source/MultiplayerEditorGem.cpp + Source/MultiplayerEditorGem.h Source/Editor/MultiplayerEditorSystemComponent.cpp Source/Editor/MultiplayerEditorSystemComponent.h ) From bd435e2abb8b25663135790d36b0674edea246db Mon Sep 17 00:00:00 2001 From: puvvadar Date: Wed, 28 Apr 2021 15:11:35 -0700 Subject: [PATCH 6/6] Build MP Editor RequiredSystem Components off standard version --- Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp b/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp index 29ef0e216f..97c5e4d105 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerEditorGem.cpp @@ -37,12 +37,9 @@ namespace Multiplayer AZ::ComponentTypeList MultiplayerEditorModule::GetRequiredSystemComponents() const { - return AZ::ComponentTypeList - { - azrtti_typeid(), - azrtti_typeid(), - azrtti_typeid(), - }; + AZ::ComponentTypeList requiredComponents = MultiplayerModule::GetRequiredSystemComponents(); + requiredComponents.push_back(azrtti_typeid()); + return requiredComponents; } } // namespace Multiplayer