Update Ctrl+G logic to account for prefab processing status and timing
This commit is contained in:
+2
@@ -46,6 +46,8 @@ namespace AzToolsFramework
|
||||
|
||||
virtual Prefab::InstanceOptionalReference GetRootPrefabInstance() = 0;
|
||||
|
||||
virtual const AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& GetPlayInEditorAssetData() = 0;
|
||||
|
||||
virtual bool LoadFromStream(AZ::IO::GenericStream& stream, AZStd::string_view filename) = 0;
|
||||
virtual bool SaveToStream(AZ::IO::GenericStream& stream, AZStd::string_view filename) = 0;
|
||||
|
||||
|
||||
+5
@@ -321,6 +321,11 @@ namespace AzToolsFramework
|
||||
return *m_rootInstance;
|
||||
}
|
||||
|
||||
const AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& PrefabEditorEntityOwnershipService::GetPlayInEditorAssetData()
|
||||
{
|
||||
return m_playInEditorData.m_assets;
|
||||
}
|
||||
|
||||
void PrefabEditorEntityOwnershipService::OnEntityRemoved(AZ::EntityId entityId)
|
||||
{
|
||||
AzFramework::SliceEntityRequestBus::MultiHandler::BusDisconnect(entityId);
|
||||
|
||||
+2
@@ -195,6 +195,8 @@ namespace AzToolsFramework
|
||||
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder) override;
|
||||
|
||||
Prefab::InstanceOptionalReference GetRootPrefabInstance() override;
|
||||
|
||||
const AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& GetPlayInEditorAssetData() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OnEntityRemoved(AZ::EntityId entityId);
|
||||
|
||||
@@ -119,6 +119,7 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Gem::Multiplayer.Editor.Static
|
||||
Gem::Multiplayer.Tools
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 <AzCore/RTTI/RTTI.h>
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
//! IMultiplayer provides insight into the Multiplayer session and its Agents
|
||||
class IMultiplayerTools
|
||||
{
|
||||
public:
|
||||
// NetworkPrefabProcessor is the only class that should be setting process network prefab status
|
||||
friend class NetworkPrefabProcessor;
|
||||
|
||||
AZ_RTTI(IMultiplayerTools, "{E8A80EAB-29CB-4E3B-A0B2-FFCB37060FB0}");
|
||||
|
||||
virtual ~IMultiplayerTools() = default;
|
||||
|
||||
//! Returns if network prefab processing has created currently active or pending spawnables
|
||||
//! @return If network prefab processing has created currently active or pending spawnables
|
||||
virtual bool DidProcessNetworkPrefabs() = 0;
|
||||
|
||||
private:
|
||||
//! Sets if network prefab processing has created currently active or pending spawnables
|
||||
//! @param didProcessNetPrefabs if network prefab processing has created currently active or pending spawnables
|
||||
virtual void SetDidProcessNetworkPrefabs(bool didProcessNetPrefabs) = 0;
|
||||
};
|
||||
}
|
||||
@@ -10,12 +10,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Include/IMultiplayerTools.h>
|
||||
#include <Source/Editor/MultiplayerEditorSystemComponent.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Console/ILogger.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
@@ -57,12 +59,14 @@ namespace Multiplayer
|
||||
|
||||
void MultiplayerEditorSystemComponent::Activate()
|
||||
{
|
||||
AzFramework::GameEntityContextEventBus::Handler::BusConnect();
|
||||
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void MultiplayerEditorSystemComponent::Deactivate()
|
||||
{
|
||||
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
|
||||
AzFramework::GameEntityContextEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void MultiplayerEditorSystemComponent::NotifyRegisterViews()
|
||||
@@ -77,11 +81,42 @@ namespace Multiplayer
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case eNotify_OnBeginGameMode:
|
||||
{
|
||||
case eNotify_OnQuit:
|
||||
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
|
||||
if (m_serverProcess)
|
||||
{
|
||||
m_serverProcess->TerminateProcess(0);
|
||||
m_serverProcess = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MultiplayerEditorSystemComponent::OnGameEntitiesStarted()
|
||||
{
|
||||
// BeginGameMode and Prefab Processing have completed at this point
|
||||
IMultiplayerTools* mpTools = AZ::Interface<IMultiplayerTools>::Get();
|
||||
if (editorsv_enabled && mpTools != nullptr && mpTools->DidProcessNetworkPrefabs())
|
||||
{
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
|
||||
if (editorsv_enabled)
|
||||
auto prefabEditorEntityOwnershipInterface = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
|
||||
if (!prefabEditorEntityOwnershipInterface)
|
||||
{
|
||||
AZ_Error("MultiplayerEditor", prefabEditorEntityOwnershipInterface != nullptr, "PrefabEditorEntityOwnershipInterface unavailable");
|
||||
}
|
||||
const AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& assetData = prefabEditorEntityOwnershipInterface->GetPlayInEditorAssetData();
|
||||
|
||||
if (assetData.size() > 0)
|
||||
{
|
||||
// Assemble the server's path
|
||||
AZ::CVarFixedString serverProcess = editorsv_process;
|
||||
@@ -111,33 +146,13 @@ namespace Multiplayer
|
||||
|
||||
// Start the configured server if it's available
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
processLaunchInfo.m_commandlineParameters =
|
||||
AZStd::string::format("\"%s\"", serverPath.c_str());
|
||||
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:
|
||||
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
|
||||
if (m_serverProcess)
|
||||
{
|
||||
m_serverProcess->TerminateProcess(0);
|
||||
m_serverProcess = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Console/ILogger.h>
|
||||
|
||||
#include <AzFramework/Entity/GameEntityContextBus.h>
|
||||
#include <AzFramework/Process/ProcessWatcher.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
|
||||
@@ -34,6 +35,7 @@ namespace Multiplayer
|
||||
class MultiplayerEditorSystemComponent final
|
||||
: public AZ::Component
|
||||
, private AZ::TickBus::Handler
|
||||
, private AzFramework::GameEntityContextEventBus::Handler
|
||||
, private AzToolsFramework::EditorEvents::Bus::Handler
|
||||
, private IEditorNotifyListener
|
||||
{
|
||||
@@ -66,8 +68,16 @@ namespace Multiplayer
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
int GetTickOrder() override;
|
||||
//! @}
|
||||
//!
|
||||
|
||||
//! EditorEvents::Handler overrides
|
||||
//! @{
|
||||
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
|
||||
//! @}
|
||||
|
||||
//! GameEntityContextEventBus::Handler overrides
|
||||
//! @{
|
||||
void OnGameEntitiesStarted() override;
|
||||
//! @}
|
||||
|
||||
IEditor* m_editor = nullptr;
|
||||
AzFramework::ProcessWatcher* m_serverProcess = nullptr;
|
||||
|
||||
@@ -18,32 +18,21 @@
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
//! Multiplayer Tools system component provides serialize context reflection for tools-only systems.
|
||||
class MultiplayerToolsSystemComponent final
|
||||
: public AZ::Component
|
||||
|
||||
void MultiplayerToolsSystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(MultiplayerToolsSystemComponent, "{65AF5342-0ECE-423B-B646-AF55A122F72B}");
|
||||
NetworkPrefabProcessor::Reflect(context);
|
||||
}
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
NetworkPrefabProcessor::Reflect(context);
|
||||
}
|
||||
bool MultiplayerToolsSystemComponent::DidProcessNetworkPrefabs()
|
||||
{
|
||||
return m_didProcessNetPrefabs;
|
||||
}
|
||||
|
||||
MultiplayerToolsSystemComponent() = default;
|
||||
~MultiplayerToolsSystemComponent() override = default;
|
||||
|
||||
/// AZ::Component overrides.
|
||||
void Activate() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Deactivate() override
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
void MultiplayerToolsSystemComponent::SetDidProcessNetworkPrefabs(bool didProcessNetPrefabs)
|
||||
{
|
||||
m_didProcessNetPrefabs = didProcessNetPrefabs;
|
||||
}
|
||||
|
||||
MultiplayerToolsModule::MultiplayerToolsModule()
|
||||
: AZ::Module()
|
||||
|
||||
@@ -12,10 +12,37 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/Module/Module.h>
|
||||
#include <Include/IMultiplayerTools.h>
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
class MultiplayerToolsSystemComponent final
|
||||
: public AZ::Component
|
||||
, public IMultiplayerTools
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(MultiplayerToolsSystemComponent, "{65AF5342-0ECE-423B-B646-AF55A122F72B}");
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
MultiplayerToolsSystemComponent() = default;
|
||||
~MultiplayerToolsSystemComponent() override = default;
|
||||
|
||||
/// AZ::Component overrides.
|
||||
void Activate() override {};
|
||||
|
||||
void Deactivate() override {};
|
||||
|
||||
bool DidProcessNetworkPrefabs() override;
|
||||
|
||||
private:
|
||||
void SetDidProcessNetworkPrefabs(bool didProcessNetPrefabs) override;
|
||||
|
||||
bool m_didProcessNetPrefabs = false;
|
||||
};
|
||||
|
||||
class MultiplayerToolsModule
|
||||
: public AZ::Module
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <AzToolsFramework/Prefab/Instance/Instance.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
|
||||
#include <Prefab/Spawnable/SpawnableUtils.h>
|
||||
#include <Include/IMultiplayerTools.h>
|
||||
#include <Source/Components/NetBindComponent.h>
|
||||
#include <Source/Pipeline/NetBindMarkerComponent.h>
|
||||
#include <Source/Pipeline/NetworkSpawnableHolderComponent.h>
|
||||
@@ -29,6 +30,8 @@ namespace Multiplayer
|
||||
|
||||
void NetworkPrefabProcessor::Process(PrefabProcessorContext& context)
|
||||
{
|
||||
IMultiplayerTools* mpTools = AZ::Interface<IMultiplayerTools>::Get();
|
||||
mpTools->SetDidProcessNetworkPrefabs(false);
|
||||
context.ListPrefabs([&context](AZStd::string_view prefabName, PrefabDom& prefab) {
|
||||
ProcessPrefab(context, prefabName, prefab);
|
||||
});
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Include/IMultiplayerTools.h
|
||||
Source/Multiplayer_precompiled.cpp
|
||||
Source/Multiplayer_precompiled.h
|
||||
Source/Pipeline/NetworkPrefabProcessor.cpp
|
||||
|
||||
Reference in New Issue
Block a user