diff --git a/Source/Engine/Core/Types/Variant.cpp b/Source/Engine/Core/Types/Variant.cpp index 8da9a0e9b..df044b299 100644 --- a/Source/Engine/Core/Types/Variant.cpp +++ b/Source/Engine/Core/Types/Variant.cpp @@ -255,6 +255,13 @@ bool VariantType::operator==(const VariantType& other) const return false; } +bool VariantType::operator==(const ScriptingTypeHandle& type) const +{ + if (Type == Null) + return !type; + return type && type.GetType().Fullname == GetTypeName(); +} + void VariantType::SetTypeName(const StringView& typeName) { if (StringUtils::Length(TypeName) != typeName.Length()) diff --git a/Source/Engine/Core/Types/Variant.h b/Source/Engine/Core/Types/Variant.h index 2f744ce77..8cc1e133b 100644 --- a/Source/Engine/Core/Types/Variant.h +++ b/Source/Engine/Core/Types/Variant.h @@ -10,6 +10,7 @@ struct Transform; struct CommonValue; template class AssetReference; +struct ScriptingTypeHandle; /// /// Represents an object type that can be interpreted as more than one type. @@ -120,6 +121,7 @@ public: VariantType& operator=(const VariantType& other); bool operator==(const Types& type) const; bool operator==(const VariantType& other) const; + bool operator==(const ScriptingTypeHandle& type) const; FORCE_INLINE bool operator!=(const VariantType& other) const { @@ -345,6 +347,14 @@ public: Array& AsArray(); const Array& AsArray() const; + template + const T* AsStructure() const + { + if (Type.Type == VariantType::Structure && Type == T::TypeInitializer) + return (const T*)AsBlob.Data; + return nullptr; + } + public: void SetType(const VariantType& type); void SetType(VariantType&& type);