diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Libraries.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Libraries.cpp index 641bdca8f7..8c2671ac6d 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Libraries.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Libraries.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,7 @@ namespace ScriptCanvas Entity::InitNodeRegistry(*g_nodeRegistry); Comparison::InitNodeRegistry(*g_nodeRegistry); Time::InitNodeRegistry(*g_nodeRegistry); + Spawning::InitNodeRegistry(*g_nodeRegistry); String::InitNodeRegistry(*g_nodeRegistry); Operators::InitNodeRegistry(*g_nodeRegistry); @@ -61,6 +63,7 @@ namespace ScriptCanvas Entity::Reflect(reflectContext); Comparison::Reflect(reflectContext); Time::Reflect(reflectContext); + Spawning::Reflect(reflectContext); String::Reflect(reflectContext); Operators::Reflect(reflectContext); @@ -90,6 +93,9 @@ namespace ScriptCanvas componentDescriptors = Time::GetComponentDescriptors(); libraryDescriptors.insert(libraryDescriptors.end(), componentDescriptors.begin(), componentDescriptors.end()); + componentDescriptors = Spawning::GetComponentDescriptors(); + libraryDescriptors.insert(libraryDescriptors.end(), componentDescriptors.begin(), componentDescriptors.end()); + componentDescriptors = String::GetComponentDescriptors(); libraryDescriptors.insert(libraryDescriptors.end(), componentDescriptors.begin(), componentDescriptors.end()); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Libraries.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Libraries.h index 3388a029ac..67094f4db8 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Libraries.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Libraries.h @@ -143,6 +143,17 @@ namespace ScriptCanvas }; + struct Spawning : public LibraryDefinition + { + AZ_RTTI(Spawning, "{41E910AE-FBD2-41AD-9173-5105141F0466}", LibraryDefinition); + + static void Reflect(AZ::ReflectContext*); + static void InitNodeRegistry(NodeRegistry& nodeRegistry); + static AZStd::vector GetComponentDescriptors(); + + ~Spawning() override = default; + }; + struct String : public LibraryDefinition { AZ_RTTI(String, "{5B700838-21A2-4579-9303-F4A4822AFEF4}", LibraryDefinition); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.ScriptCanvasNodeable.xml b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.ScriptCanvasNodeable.xml new file mode 100644 index 0000000000..d930e16057 --- /dev/null +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.ScriptCanvasNodeable.xml @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.cpp new file mode 100644 index 0000000000..5c72f60625 --- /dev/null +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.cpp @@ -0,0 +1,42 @@ +/* +* 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 ScriptCanvas +{ + namespace Nodeables + { + namespace Spawning + { + SpawnNodeable::SpawnNodeable() + { + AZ::Data::AssetId cubeAssetId("{90552CB9-2F29-5A2E-976C-61BF7ADACB81}", 272062881); + m_spawnableAsset = AZ::Data::AssetManager::Instance().GetAsset(cubeAssetId, AZ::Data::AssetLoadBehavior::PreLoad); + AZ::Data::AssetManager::Instance().BlockUntilLoadComplete(m_spawnableAsset); + + m_spawnTicket = AzFramework::EntitySpawnTicket(m_spawnableAsset); + } + + SpawnNodeable::SpawnNodeable(const SpawnNodeable& rhs) + { + m_spawnableAsset = rhs.m_spawnableAsset; + m_spawnTicket = AzFramework::EntitySpawnTicket(rhs.m_spawnableAsset); + } + + void SpawnNodeable::Spawn() + { + AzFramework::SpawnableEntitiesInterface::Get()->SpawnAllEntities(m_spawnTicket); + } + } + } +} diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.h new file mode 100644 index 0000000000..1eb53d53a2 --- /dev/null +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.h @@ -0,0 +1,43 @@ +/* +* 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 + +namespace ScriptCanvas +{ + namespace Nodeables + { + namespace Spawning + { + class SpawnNodeable + : public ScriptCanvas::Nodeable + { + SCRIPTCANVAS_NODE(SpawnNodeable); + public: + SpawnNodeable(); + + SpawnNodeable(const SpawnNodeable& rhs); + + private: + AZ::Data::Asset m_spawnableAsset; + AzFramework::EntitySpawnTicket m_spawnTicket; + }; + } + } +} diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/Spawning.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/Spawning.cpp new file mode 100644 index 0000000000..6591950b77 --- /dev/null +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/Spawning.cpp @@ -0,0 +1,50 @@ +/* +* 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 + +namespace ScriptCanvas +{ + namespace Library + { + void Spawning::Reflect(AZ::ReflectContext* reflection) + { + if (AZ::SerializeContext* serializeContext = azrtti_cast(reflection)) + { + serializeContext->Class() + ->Version(1) + ; + + AZ::EditContext* editContext = serializeContext->GetEditContext(); + if (editContext) + { + editContext->Class("Spawning", "") + ->ClassElement(AZ::Edit::ClassElements::EditorData, "") + ->Attribute(AZ::Edit::Attributes::Icon, "Icons/ScriptCanvas/Libraries/Entity.png"); + } + } + } + + void Spawning::InitNodeRegistry(NodeRegistry& nodeRegistry) + { + AddNodeToRegistry(nodeRegistry); + } + + AZStd::vector Spawning::GetComponentDescriptors() + { + return AZStd::vector({ + ScriptCanvas::Nodes::SpawnNodeableNode::CreateDescriptor(), + }); + } + } +} diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/Spawning.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/Spawning.h new file mode 100644 index 0000000000..fa92ee97a9 --- /dev/null +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/Spawning.h @@ -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. +* +*/ + +#pragma once + +// This header is only meant to include the nodes and should not contain +// shared code +#include diff --git a/Gems/ScriptCanvas/Code/scriptcanvasgem_common_files.cmake b/Gems/ScriptCanvas/Code/scriptcanvasgem_common_files.cmake index 84391021df..f0be1accc9 100644 --- a/Gems/ScriptCanvas/Code/scriptcanvasgem_common_files.cmake +++ b/Gems/ScriptCanvas/Code/scriptcanvasgem_common_files.cmake @@ -454,6 +454,11 @@ set(FILES Include/ScriptCanvas/Libraries/Time/TimerNodeable.h Include/ScriptCanvas/Libraries/Time/TimerNodeable.cpp Include/ScriptCanvas/Libraries/Time/TimerNodeable.ScriptCanvasNodeable.xml + Include/ScriptCanvas/Libraries/Spawning/Spawning.cpp + Include/ScriptCanvas/Libraries/Spawning/Spawning.h + Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.cpp + Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.h + Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.ScriptCanvasNodeable.xml Include/ScriptCanvas/Libraries/String/Contains.cpp Include/ScriptCanvas/Libraries/String/Contains.h Include/ScriptCanvas/Libraries/String/Contains.ScriptCanvasGrammar.xml