From ec7edac932365af5ac9fde3391f5c9a63585bb93 Mon Sep 17 00:00:00 2001 From: chcurran <82187351+carlitosan@users.noreply.github.com> Date: Wed, 9 Jun 2021 12:43:43 -0700 Subject: [PATCH 1/4] Hide the raw input handler bus from the SC node palette list --- Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp b/Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp index c08cac0188..28ca91976b 100644 --- a/Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp +++ b/Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp @@ -167,6 +167,7 @@ namespace StartingPointInput { "actionName", "The name of the Input event action used to create an InputEventNotificationId" } } }); behaviorContext->EBus("InputEventNotificationBus") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::List) ->Handler() ->Event("OnPressed", &InputEventNotificationBus::Events::OnPressed) ->Event("OnHeld", &InputEventNotificationBus::Events::OnHeld) From 8ab2752f4271107f14d6e7371b0d3f3559ddd3c0 Mon Sep 17 00:00:00 2001 From: chcurran Date: Wed, 9 Jun 2021 14:52:33 -0700 Subject: [PATCH 2/4] Fix for using BC class constants LYN-3777 --- .../ScriptCanvas/Translation/GraphToLua.cpp | 52 +- .../ScriptCanvas/Translation/GraphToLua.h | 2 +- ...eBehaviorContextClassConstant.scriptcanvas | 1173 +++++++++++++++++ 3 files changed, 1210 insertions(+), 17 deletions(-) create mode 100644 Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_UseBehaviorContextClassConstant.scriptcanvas diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/GraphToLua.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/GraphToLua.cpp index 905f68604a..a5e9c179e6 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/GraphToLua.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/GraphToLua.cpp @@ -1220,8 +1220,18 @@ namespace ScriptCanvas void GraphToLua::WriteClassPropertyRead(Grammar::ExecutionTreeConstPtr execution) { - WriteFunctionCallInput(execution, 0, IsFormatStringInput::No); - m_dotLua.Write(".%s", Grammar::ToIdentifier(execution->GetName()).c_str()); + if (execution->GetInputCount() > 0) + { + WriteFunctionCallInput(execution, 0, IsFormatStringInput::No); + m_dotLua.Write("."); + } + else + { + // it's a constant + WriteResolvedScope(execution, execution->GetNameLexicalScope()); + } + + m_dotLua.Write(Grammar::ToIdentifier(execution->GetName()).c_str()); } void GraphToLua::WriteClassPropertyWrite(Grammar::ExecutionTreeConstPtr execution) @@ -1509,20 +1519,7 @@ namespace ScriptCanvas } else { - const AZStd::string resolvedScope = ResolveScope(lexicalScope.m_namespaces); - - auto& abbreviation = FindAbbreviation(resolvedScope); - - if (!abbreviation.empty()) - { - m_dotLua.Write("%s%.*s", abbreviation.c_str(), - aznumeric_cast(m_configuration.m_lexicalScopeDelimiter.size()), m_configuration.m_lexicalScopeDelimiter.data()); - } - else if (!resolvedScope.empty()) - { - m_dotLua.Write("%s%.*s", resolvedScope.c_str(), - aznumeric_cast(m_configuration.m_lexicalScopeDelimiter.size()), m_configuration.m_lexicalScopeDelimiter.data()); - } + WriteResolvedScope(execution, lexicalScope); } } break; @@ -2413,5 +2410,28 @@ namespace ScriptCanvas } } + void GraphToLua::WriteResolvedScope(Grammar::ExecutionTreeConstPtr execution, const Grammar::LexicalScope& lexicalScope) + { + if (lexicalScope.m_type != Grammar::LexicalScopeType::Class && lexicalScope.m_type != Grammar::LexicalScopeType::Namespace) + { + AddError(execution, aznew Internal::ParseError(execution->GetNodeId(), "Invalid arguments to WriteResolvedScope.")); + return; + } + + const AZStd::string resolvedScope = ResolveScope(lexicalScope.m_namespaces); + + auto& abbreviation = FindAbbreviation(resolvedScope); + + if (!abbreviation.empty()) + { + m_dotLua.Write("%s%.*s", abbreviation.c_str(), + aznumeric_cast(m_configuration.m_lexicalScopeDelimiter.size()), m_configuration.m_lexicalScopeDelimiter.data()); + } + else if (!resolvedScope.empty()) + { + m_dotLua.Write("%s%.*s", resolvedScope.c_str(), + aznumeric_cast(m_configuration.m_lexicalScopeDelimiter.size()), m_configuration.m_lexicalScopeDelimiter.data()); + } + } } } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/GraphToLua.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/GraphToLua.h index 82c865da8c..9894a30841 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/GraphToLua.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/GraphToLua.h @@ -160,6 +160,7 @@ namespace ScriptCanvas void WriteOperatorArithmetic(Grammar::ExecutionTreeConstPtr execution); void WriteOutputAssignments(Grammar::ExecutionTreeConstPtr execution); void WriteOutputAssignments(Grammar::ExecutionTreeConstPtr execution, const AZStd::vector>& output); + void WriteResolvedScope(Grammar::ExecutionTreeConstPtr execution, const Grammar::LexicalScope& lexicalScope); void WriteReturnStatement(Grammar::ExecutionTreeConstPtr execution); void WriteReturnValueInitialization(Grammar::ExecutionTreeConstPtr execution); void WriteStaticInitializerInput(IsLeadingCommaRequired commaRequired); @@ -170,7 +171,6 @@ namespace ScriptCanvas void WriteVariableWrite(Grammar::ExecutionTreeConstPtr execution, const AZStd::vector>& output); void WriteWrittenMathExpression(Grammar::ExecutionTreeConstPtr execution); - private: }; } diff --git a/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_UseBehaviorContextClassConstant.scriptcanvas b/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_UseBehaviorContextClassConstant.scriptcanvas new file mode 100644 index 0000000000..d80e4dcac8 --- /dev/null +++ b/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_UseBehaviorContextClassConstant.scriptcanvas @@ -0,0 +1,1173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c4ab5fff9ada6b2d903719dd6a0052d76a57c23d Mon Sep 17 00:00:00 2001 From: chcurran Date: Wed, 9 Jun 2021 14:52:55 -0700 Subject: [PATCH 3/4] testing code files for fixes for LYN-3777 --- .../Code/Source/Nodes/BehaviorContextObjectTestNode.h | 1 + .../Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Gems/ScriptCanvasTesting/Code/Source/Nodes/BehaviorContextObjectTestNode.h b/Gems/ScriptCanvasTesting/Code/Source/Nodes/BehaviorContextObjectTestNode.h index 7fa3896ff1..eba6b71169 100644 --- a/Gems/ScriptCanvasTesting/Code/Source/Nodes/BehaviorContextObjectTestNode.h +++ b/Gems/ScriptCanvasTesting/Code/Source/Nodes/BehaviorContextObjectTestNode.h @@ -53,6 +53,7 @@ namespace ScriptCanvasTestingNodes ->Method("SetString", &BehaviorContextObjectTest::SetString) ->Method("GetString", &BehaviorContextObjectTest::GetString) ->Property("Name", BehaviorValueProperty(&BehaviorContextObjectTest::m_name)) + ->Constant("Always24", BehaviorConstant(24)) ; } } diff --git a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp index 5bda0f3941..e2665f31cf 100644 --- a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp +++ b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp @@ -90,6 +90,11 @@ public: } }; +TEST_F(ScriptCanvasTestFixture, UseBehaviorContextClassConstant) +{ + RunUnitTestGraph("LY_SC_UnitTest_UseBehaviorContextClassConstant"); +} + TEST_F(ScriptCanvasTestFixture, ParseFunctionIfBranchWithConnectedInput) { RunUnitTestGraph("LY_SC_UnitTest_ParseFunctionIfBranchWithConnectedInput"); From d1a5fb651b6377bd5945645a4a9914c7f528671e Mon Sep 17 00:00:00 2001 From: chcurran Date: Wed, 9 Jun 2021 15:14:23 -0700 Subject: [PATCH 4/4] Fixes for reflection code that hides itself frm Script explicitly but NOT from ScriptCanvas --- .../Source/Integration/Components/SimpleMotionComponent.cpp | 2 -- .../Editor/Components/EditorSimpleMotionComponent.cpp | 1 - Gems/LmbrCentral/Code/Source/Scripting/TagComponent.cpp | 1 - 3 files changed, 4 deletions(-) diff --git a/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp index 2e0ca16af2..633cb5ed1d 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp @@ -103,9 +103,7 @@ namespace EMotionFX ->Attribute("Hidden", AZ::Edit::Attributes::PropertyHidden) ->VirtualProperty("PlayTime", "GetPlayTime", "PlayTime") ->Event("Motion", &SimpleMotionComponentRequestBus::Events::Motion) - ->Attribute(AZ::Script::Attributes::Ignore, true) ->Event("GetMotion", &SimpleMotionComponentRequestBus::Events::GetMotion) - ->Attribute(AZ::Script::Attributes::Ignore, true) ->VirtualProperty("Motion", "GetMotion", "Motion") ->Event("BlendInTime", &SimpleMotionComponentRequestBus::Events::BlendInTime) ->Event("GetBlendInTime", &SimpleMotionComponentRequestBus::Events::GetBlendInTime) diff --git a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorSimpleMotionComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorSimpleMotionComponent.cpp index 4b463958af..ee8a0f7821 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorSimpleMotionComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorSimpleMotionComponent.cpp @@ -70,7 +70,6 @@ namespace EMotionFX ->Attribute("Hidden", AZ::Edit::Attributes::PropertyHidden) ->VirtualProperty("PreviewInEditor", "GetPreviewInEditor", "SetPreviewInEditor") ->Event("GetAssetDuration", &EditorSimpleMotionComponentRequestBus::Events::GetAssetDuration) - ->Attribute(AZ::Script::Attributes::Ignore, true) ; behaviorContext->Class() diff --git a/Gems/LmbrCentral/Code/Source/Scripting/TagComponent.cpp b/Gems/LmbrCentral/Code/Source/Scripting/TagComponent.cpp index 931ec8041e..ad5c2e499e 100644 --- a/Gems/LmbrCentral/Code/Source/Scripting/TagComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Scripting/TagComponent.cpp @@ -86,7 +86,6 @@ namespace LmbrCentral { behaviorContext->Class("Tag Helper") ->Method("Get Entities by Tag", &TagComponentBehaviorHelper::FindTaggedEntities) - ->Attribute(AZ::Script::Attributes::Ignore, 0) ->Attribute(AZ::Script::Attributes::Category, "Gameplay/Tag") ->Attribute(AZ::ScriptCanvasAttributes::FloatingFunction, 0) ;