/* * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include "Entity.h" namespace ScriptCanvas { static bool OldEntityIdIsValidNodeVersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& rootNodeElement) { int nodeElementIndex = rootNodeElement.FindElement(AZ_CRC("BaseClass1", 0xd4925735)); if (nodeElementIndex == -1) { AZ_Error("Script Canvas", false, "Unable to find base class node element for old EntityId::IsValid function node"); return false; } // The DataElementNode is being copied purposefully in this statement to clone the data AZ::SerializeContext::DataElementNode baseNodeElement = rootNodeElement.GetSubElement(nodeElementIndex); if (!rootNodeElement.Convert(context, azrtti_typeid())) { AZ_Error("Script Canvas", false, "Unable to convert old Entity::IsValid function node(%s) to new EntityId::IsValid function node(%s)", rootNodeElement.GetId().ToString().data(), azrtti_typeid().ToString().data()); return false; } if (rootNodeElement.AddElement(baseNodeElement) == -1) { AZ_Error("Script Canvas", false, "Unable to add base class node element to new EntityId::IsValid function node"); return false; } return true; } namespace Library { void Entity::Reflect(AZ::ReflectContext* reflection) { AZ::SerializeContext* serializeContext = azrtti_cast(reflection); if (serializeContext) { serializeContext->Class() ->Version(1) ; AZ::EditContext* editContext = serializeContext->GetEditContext(); if (editContext) { editContext->Class("Entity", "")-> ClassElement(AZ::Edit::ClassElements::EditorData, "")-> Attribute(AZ::Edit::Attributes::Icon, "Icons/ScriptCanvas/Libraries/Entity.png") ; } // Reflects the old EntityId IsValid function node const AZ::TypeId nodeFunctionGenericMultiReturnTemplateTypeId("{DC5B1799-6C5B-4190-8D90-EF0C2D1BCE4E}"); const AZ::TypeId oldEntityIdIsValidFuncSignatureTypeId = azrtti_typeid(); const AZ::TypeId oldEntityIdIsValidTypeId("{7CEC53AE-E12B-4738-B542-4587B8B95DC2}"); // Aggregate NodeFunctionGenericMultiReturn typeid // NOTE: Aggregation order addition is not commutative and must be in the added last to first: (FirstUuid + ( SecondUuid + (ThirdUuid + ... + (NthUuid)) const AZ::TypeId oldIsValidNodeAggregateTypeId = nodeFunctionGenericMultiReturnTemplateTypeId + (oldEntityIdIsValidFuncSignatureTypeId + oldEntityIdIsValidTypeId); serializeContext->ClassDeprecate("EntityId::IsValidNode", oldIsValidNodeAggregateTypeId, &OldEntityIdIsValidNodeVersionConverter); } if (AZ::BehaviorContext* behaviorContext = azrtti_cast(reflection)) { SCRIPT_CANVAS_GENERICS_TO_VM(EntityNodes::Registrar, Entity, behaviorContext, EntityNodes::k_categoryName); } ScriptCanvas::Entity::RotateMethod::Reflect(reflection); } void Entity::InitNodeRegistry(NodeRegistry& nodeRegistry) { EntityIDNodes::Registrar::AddToRegistry(nodeRegistry); EntityNodes::Registrar::AddToRegistry(nodeRegistry); } AZStd::vector Entity::GetComponentDescriptors() { AZStd::vector descriptors; EntityIDNodes::Registrar::AddDescriptors(descriptors); EntityNodes::Registrar::AddDescriptors(descriptors); return descriptors; } } }