Fixed missing move semantics in script object reference

This commit is contained in:
Michael Herzog
2025-11-25 17:33:11 +01:00
parent 2a55cda583
commit a62ca5452e

View File

@@ -33,6 +33,13 @@ public:
{
}
ScriptingObjectReferenceBase(ScriptingObjectReferenceBase&& other) noexcept
: _object(nullptr)
{
OnSet(other._object);
other.OnSet(nullptr);
}
/// <summary>
/// Initializes a new instance of the <see cref="ScriptingObjectReferenceBase"/> class.
/// </summary>
@@ -96,6 +103,16 @@ protected:
void OnSet(ScriptingObject* object);
void OnDeleted(ScriptingObject* obj);
ScriptingObjectReferenceBase& operator=(ScriptingObjectReferenceBase&& other) noexcept
{
if (this != &other)
{
OnSet(other._object);
other.OnSet(nullptr);
}
return *this;
}
};
/// <summary>
@@ -133,6 +150,11 @@ public:
{
}
ScriptingObjectReference(ScriptingObjectReference&& other) noexcept
: ScriptingObjectReferenceBase(MoveTemp(other))
{
}
/// <summary>
/// Finalizes an instance of the <see cref="ScriptingObjectReference"/> class.
/// </summary>
@@ -173,6 +195,12 @@ public:
return *this;
}
ScriptingObjectReference& operator=(ScriptingObjectReference&& other) noexcept
{
ScriptingObjectReferenceBase::operator=(MoveTemp(other));
return *this;
}
FORCE_INLINE ScriptingObjectReference& operator=(const Guid& id)
{
OnSet(static_cast<ScriptingObject*>(FindObject(id, T::GetStaticClass())));