Initial prefab integration
Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
@@ -19,8 +19,15 @@ namespace ScriptCanvas
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
using LoadedInterpretedDependencies = AZStd::vector<AZStd::pair<AZStd::string, ScriptCanvas::Translation::LuaAssetResult>>;
|
||||
AZ_INLINE LoadedInterpretedDependencies LoadInterpretedDepencies(const ScriptCanvas::DependencySet& dependencySet);
|
||||
struct LoadedInterpretedDependency
|
||||
{
|
||||
AZStd::string path;
|
||||
AZ::Data::Asset<ScriptCanvas::RuntimeAsset> runtimeAsset;
|
||||
ScriptCanvas::Translation::LuaAssetResult luaAssetResult;
|
||||
AZStd::vector<LoadedInterpretedDependency> dependencies;
|
||||
};
|
||||
|
||||
AZ_INLINE AZStd::vector<LoadedInterpretedDependency> LoadInterpretedDepencies(const ScriptCanvas::DependencySet& dependencySet);
|
||||
|
||||
AZ_INLINE LoadTestGraphResult LoadTestGraph(AZStd::string_view path);
|
||||
|
||||
@@ -49,10 +56,11 @@ namespace ScriptCanvasEditor
|
||||
AZ_INLINE void RunGraphImplementation(const RunGraphSpec& runGraphSpec, Reporter& reporter);
|
||||
AZ_INLINE void RunGraphImplementation(const RunGraphSpec& runGraphSpec, LoadTestGraphResult& loadGraphResult, Reporter& reporter);
|
||||
AZ_INLINE void RunGraphImplementation(const RunGraphSpec& runGraphSpec, Reporters& reporters);
|
||||
|
||||
|
||||
AZ_INLINE void Simulate(const DurationSpec& duration);
|
||||
AZ_INLINE void SimulateDuration(const DurationSpec& duration);
|
||||
AZ_INLINE void SimulateSeconds(const DurationSpec& duration);
|
||||
AZ_INLINE void SimulateTicks(const DurationSpec& duration);
|
||||
} // ScriptCanvasEditor
|
||||
|
||||
#include <Editor/Framework/ScriptCanvasGraphUtilities.inl>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
@@ -26,9 +26,25 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
using namespace ScriptCanvas;
|
||||
|
||||
AZ_INLINE LoadedInterpretedDependencies LoadInterpretedDepencies(const ScriptCanvas::DependencySet& dependencySet)
|
||||
// The runtime context (appropriately) always assumes that EntityIds are overridden, this step copies the values from the runtime data
|
||||
// over to the override data to simulate build step that does this when building prefabs
|
||||
AZ_INLINE void CopyAssetEntityIdsToOverrides(RuntimeDataOverrides& runtimeDataOverrides)
|
||||
{
|
||||
LoadedInterpretedDependencies loadedAssets;
|
||||
runtimeDataOverrides.m_entityIds.reserve(runtimeDataOverrides.m_runtimeAsset->GetData().m_input.m_entityIds.size());
|
||||
for (auto& varEntityPar : runtimeDataOverrides.m_runtimeAsset->GetData().m_input.m_entityIds)
|
||||
{
|
||||
runtimeDataOverrides.m_entityIds.push_back(varEntityPar.second);
|
||||
}
|
||||
|
||||
for (auto& dependency : runtimeDataOverrides.m_dependencies)
|
||||
{
|
||||
CopyAssetEntityIdsToOverrides(dependency);
|
||||
}
|
||||
}
|
||||
|
||||
AZ_INLINE AZStd::vector<LoadedInterpretedDependency> LoadInterpretedDepencies(const ScriptCanvas::DependencySet& dependencySet)
|
||||
{
|
||||
AZStd::vector<LoadedInterpretedDependency> loadedAssets;
|
||||
|
||||
if (!dependencySet.empty())
|
||||
{
|
||||
@@ -41,7 +57,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AZ_Assert(namespacePath.size() >= 3, "This functions assumes unit test dependencies are in the ScriptCanvas gem unit test folder");
|
||||
AZStd::string originalPath = namespacePath[2].data();
|
||||
|
||||
|
||||
for (size_t index = 3; index < namespacePath.size(); ++index)
|
||||
{
|
||||
originalPath += "/";
|
||||
@@ -52,11 +68,11 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
originalPath.resize(originalPath.size() - AZStd::string_view(Grammar::k_internalRuntimeSuffix).size());
|
||||
}
|
||||
|
||||
|
||||
AZStd::string path = AZStd::string::format("%s/%s.scriptcanvas", k_unitTestDirPathRelative, originalPath.data());
|
||||
LoadTestGraphResult loadResult = LoadTestGraph(path);
|
||||
AZ_Assert(loadResult.m_runtimeAsset, "failed to load dependent asset");
|
||||
|
||||
|
||||
AZ::Outcome<ScriptCanvas::Translation::LuaAssetResult, AZStd::string> luaAssetOutcome = AZ::Failure(AZStd::string("lua asset creation for function failed"));
|
||||
ScriptCanvasEditor::EditorAssetConversionBus::BroadcastResult(luaAssetOutcome, &ScriptCanvasEditor::EditorAssetConversionBusTraits::CreateLuaAsset, loadResult.m_editorAsset, loadResult.m_graphPath);
|
||||
AZ_Assert(luaAssetOutcome.IsSuccess(), "failed to create Lua asset");
|
||||
@@ -69,8 +85,9 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
|
||||
const ScriptCanvas::Translation::LuaAssetResult& luaAssetResult = luaAssetOutcome.GetValue();
|
||||
loadedAssets.push_back({ modulePath, luaAssetResult });
|
||||
}
|
||||
// #functions2_recursive_unit_tests
|
||||
loadedAssets.push_back({ modulePath, loadResult.m_runtimeAsset, luaAssetResult, {} });
|
||||
}
|
||||
}
|
||||
|
||||
return loadedAssets;
|
||||
@@ -182,7 +199,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
RuntimeData runtimeDataBuffer;
|
||||
AZStd::vector<RuntimeData> dependencyDataBuffer;
|
||||
LoadedInterpretedDependencies dependencies;
|
||||
AZStd::vector<LoadedInterpretedDependency> dependencies;
|
||||
|
||||
if (runGraphSpec.runSpec.execution == ExecutionMode::Interpreted)
|
||||
{
|
||||
@@ -202,9 +219,12 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
dependencies = LoadInterpretedDepencies(luaAssetResult.m_dependencies.source.userSubgraphs);
|
||||
|
||||
RuntimeDataOverrides runtimeDataOverrides;
|
||||
runtimeDataOverrides.m_runtimeAsset = loadResult.m_runtimeAsset;
|
||||
|
||||
if (!dependencies.empty())
|
||||
{
|
||||
// eventually, this will need to be recursive, or the full asset handling system will need to be integrated into the testing framework
|
||||
// #functions2_recursive_unit_tests eventually, this will need to be recursive, or the full asset handling system will need to be integrated into the testing framework
|
||||
// in order to test functionality with a dependency stack greater than 2
|
||||
|
||||
// load all script assets, and their dependencies, initialize statics on all those dependencies if it is the first time loaded
|
||||
@@ -215,7 +235,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
for (auto& dependency : dependencies)
|
||||
{
|
||||
inMemoryModules.emplace_back(dependency.first, dependency.second.m_scriptAsset);
|
||||
inMemoryModules.emplace_back(dependency.path, dependency.luaAssetResult.m_scriptAsset);
|
||||
}
|
||||
|
||||
AZ::ScriptSystemRequestBus::Broadcast(&AZ::ScriptSystemRequests::UseInMemoryRequireHook, inMemoryModules, AZ::ScriptContextIds::DefaultScriptContextId);
|
||||
@@ -224,7 +244,11 @@ namespace ScriptCanvasEditor
|
||||
for (size_t index = 0; index < dependencies.size(); ++index)
|
||||
{
|
||||
auto& dependency = dependencies[index];
|
||||
const ScriptCanvas::Translation::LuaAssetResult& depencyAssetResult = dependency.second;
|
||||
const ScriptCanvas::Translation::LuaAssetResult& depencyAssetResult = dependency.luaAssetResult;
|
||||
|
||||
RuntimeDataOverrides dependencyRuntimeDataOverrides;
|
||||
dependencyRuntimeDataOverrides.m_runtimeAsset = dependency.runtimeAsset;
|
||||
runtimeDataOverrides.m_dependencies.push_back(dependencyRuntimeDataOverrides);
|
||||
|
||||
RuntimeData& dependencyData = dependencyDataBuffer[index];
|
||||
dependencyData.m_input = depencyAssetResult.m_runtimeInputs;
|
||||
@@ -239,7 +263,9 @@ namespace ScriptCanvasEditor
|
||||
loadResult.m_runtimeAsset.Get()->GetData().m_script = loadResult.m_scriptAsset;
|
||||
loadResult.m_runtimeAsset.Get()->GetData().m_input = luaAssetResult.m_runtimeInputs;
|
||||
loadResult.m_runtimeAsset.Get()->GetData().m_debugMap = luaAssetResult.m_debugMap;
|
||||
loadResult.m_runtimeComponent = loadResult.m_entity->CreateComponent<ScriptCanvas::RuntimeComponent>(loadResult.m_runtimeAsset);
|
||||
loadResult.m_runtimeComponent = loadResult.m_entity->CreateComponent<ScriptCanvas::RuntimeComponent>();
|
||||
CopyAssetEntityIdsToOverrides(runtimeDataOverrides);
|
||||
loadResult.m_runtimeComponent->SetRuntimeDataOverrides(runtimeDataOverrides);
|
||||
Execution::Context::InitializeActivationData(loadResult.m_runtimeAsset->GetData());
|
||||
Execution::InitializeInterpretedStatics(loadResult.m_runtimeAsset->GetData());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user