diff --git a/Source/Engine/AI/BehaviorKnowledge.cpp b/Source/Engine/AI/BehaviorKnowledge.cpp index 4d8e2eed9..872a12834 100644 --- a/Source/Engine/AI/BehaviorKnowledge.cpp +++ b/Source/Engine/AI/BehaviorKnowledge.cpp @@ -205,10 +205,9 @@ bool BehaviorKnowledge::Set(const StringAnsiView& path, const Variant& value) bool BehaviorKnowledge::HasGoal(ScriptingTypeHandle type) const { - for (int32 i = 0; i < Goals.Count(); i++) + for (const Variant& goal : Goals) { - const ScriptingTypeHandle goalType = Scripting::FindScriptingType(Goals[i].Type.GetTypeName()); - if (goalType == type) + if (goal.Type.GetScriptingType() == type) return true; } return false; @@ -218,8 +217,7 @@ const Variant& BehaviorKnowledge::GetGoal(ScriptingTypeHandle type) const { for (const Variant& goal : Goals) { - const ScriptingTypeHandle goalType = Scripting::FindScriptingType(goal.Type.GetTypeName()); - if (goalType == type) + if (goal.Type.GetScriptingType() == type) return goal; } return Variant::Null; @@ -242,10 +240,9 @@ void BehaviorKnowledge::RemoveGoal(ScriptingTypeHandle type) { for (int32 i = 0; i < Goals.Count(); i++) { - const ScriptingTypeHandle goalType = Scripting::FindScriptingType(Goals[i].Type.GetTypeName()); - if (goalType == type) + if (Goals[i].Type.GetScriptingType() == type) { - Goals.RemoveAt(i); + Goals.RemoveAtKeepOrder(i); break; } } diff --git a/Source/Engine/Content/Assets/VisualScript.cpp b/Source/Engine/Content/Assets/VisualScript.cpp index 62d901b6f..26b896b02 100644 --- a/Source/Engine/Content/Assets/VisualScript.cpp +++ b/Source/Engine/Content/Assets/VisualScript.cpp @@ -339,7 +339,7 @@ void VisualScriptExecutor::ProcessGroupTools(Box* box, Node* node, Value& value) obj = Value::Null; #else const ScriptingTypeHandle type = Scripting::FindScriptingType(StringAnsiView(typeNameAnsi.Get(), typeName.Length())); - const ScriptingTypeHandle objType = Scripting::FindScriptingType(obj.Type.GetTypeName()); + const ScriptingTypeHandle objType = obj.Type.GetScriptingType(); if (!type || !objType || !objType.IsSubclassOf(type)) obj = Value::Null; #endif diff --git a/Source/Engine/Core/Types/Variant.cpp b/Source/Engine/Core/Types/Variant.cpp index 7f805f9e3..78b506b58 100644 --- a/Source/Engine/Core/Types/Variant.cpp +++ b/Source/Engine/Core/Types/Variant.cpp @@ -362,6 +362,11 @@ const char* VariantType::GetTypeName() const return InBuiltTypesTypeNames[Type]; } +ScriptingTypeHandle VariantType::GetScriptingType() const +{ + return Scripting::FindScriptingType(GetTypeName()); +} + VariantType VariantType::GetElementType() const { if (Type == Array) diff --git a/Source/Engine/Core/Types/Variant.h b/Source/Engine/Core/Types/Variant.h index 13b928171..530a4da76 100644 --- a/Source/Engine/Core/Types/Variant.h +++ b/Source/Engine/Core/Types/Variant.h @@ -151,6 +151,7 @@ public: void SetTypeName(const ScriptingType& type); void SetTypeName(const MClass& klass); const char* GetTypeName() const; + ScriptingTypeHandle GetScriptingType() const; VariantType GetElementType() const; // Drops custom type name into the name allocated by the scripting module to reduce memory allocations when referencing types. void Inline(); diff --git a/Source/Engine/Debug/DebugCommands.cpp b/Source/Engine/Debug/DebugCommands.cpp index feb985cd4..ac6e55de7 100644 --- a/Source/Engine/Debug/DebugCommands.cpp +++ b/Source/Engine/Debug/DebugCommands.cpp @@ -85,7 +85,7 @@ struct CommandData else if (value.Type.Type == VariantType::Structure) { // Prettify structure printing - ScriptingTypeHandle resultType = Scripting::FindScriptingType(value.Type.GetTypeName()); + ScriptingTypeHandle resultType = value.Type.GetScriptingType(); if (resultType) { Array fields; diff --git a/Source/Engine/Level/Prefabs/Prefab.cpp b/Source/Engine/Level/Prefabs/Prefab.cpp index 80120ea87..a14eae500 100644 --- a/Source/Engine/Level/Prefabs/Prefab.cpp +++ b/Source/Engine/Level/Prefabs/Prefab.cpp @@ -64,7 +64,7 @@ Actor* Prefab::GetDefaultInstance() // Skip if not loaded if (!IsLoaded()) { - LOG(Warning, "Cannot instantiate object from not loaded prefab asset."); + LOG(Warning, "Cannot instantiate object from not loaded prefab asset ({}, {})", GetPath(), GetID()); return nullptr; } diff --git a/Source/Engine/Visject/VisjectGraph.cpp b/Source/Engine/Visject/VisjectGraph.cpp index 8b8c27010..2b18a7d71 100644 --- a/Source/Engine/Visject/VisjectGraph.cpp +++ b/Source/Engine/Visject/VisjectGraph.cpp @@ -766,7 +766,7 @@ void VisjectExecutor::ProcessGroupPacking(Box* box, Node* node, Value& value) structureValue = Variant::Cast(structureValue, typeVariantType); } structureValue.InvertInline(); // Extract any Float3/Int32 into Structure type from inlined format - const ScriptingTypeHandle structureValueTypeHandle = Scripting::FindScriptingType(structureValue.Type.GetTypeName()); + const ScriptingTypeHandle structureValueTypeHandle = structureValue.Type.GetScriptingType(); if (structureValue.Type.Type != VariantType::Structure || typeHandle != structureValueTypeHandle) { OnError(node, box, String::Format(TEXT("Cannot unpack value of type {0} to structure of type {1}"), structureValue.Type, typeName));