Refactor GetChildByPrefabObjectId/GetScriptByPrefabObjectId from Actor to be private
This commit is contained in:
@@ -32,6 +32,37 @@
|
||||
#define CHECK_EXECUTE_IN_EDITOR
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
Actor* GetChildByPrefabObjectId(Actor* a, const Guid& prefabObjectId)
|
||||
{
|
||||
Actor* result = nullptr;
|
||||
for (int32 i = 0; i < a->Children.Count(); i++)
|
||||
{
|
||||
if (a->Children[i]->GetPrefabObjectID() == prefabObjectId)
|
||||
{
|
||||
result = a->Children[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Script* GetScriptByPrefabObjectId(Actor* a, const Guid& prefabObjectId)
|
||||
{
|
||||
Script* result = nullptr;
|
||||
for (int32 i = 0; i < a->Scripts.Count(); i++)
|
||||
{
|
||||
if (a->Scripts[i]->GetPrefabObjectID() == prefabObjectId)
|
||||
{
|
||||
result = a->Scripts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Actor::Actor(const SpawnParams& params)
|
||||
: SceneObject(params)
|
||||
, _isActive(true)
|
||||
@@ -385,20 +416,6 @@ Array<Actor*> Actor::GetChildren(const MClass* type) const
|
||||
return result;
|
||||
}
|
||||
|
||||
Actor* Actor::GetChildByPrefabObjectId(const Guid& prefabObjectId) const
|
||||
{
|
||||
Actor* result = nullptr;
|
||||
for (int32 i = 0; i < Children.Count(); i++)
|
||||
{
|
||||
if (Children[i]->GetPrefabObjectID() == prefabObjectId)
|
||||
{
|
||||
result = Children[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Actor::HasTag(const StringView& tag) const
|
||||
{
|
||||
return HasTag() && tag == Level::Tags[_tag];
|
||||
@@ -919,7 +936,7 @@ void Actor::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
for (int32 i = 0; i < other->Children.Count(); i++)
|
||||
{
|
||||
const Guid prefabObjectId = other->Children[i]->GetPrefabObjectID();
|
||||
if (GetChildByPrefabObjectId(prefabObjectId) == nullptr)
|
||||
if (GetChildByPrefabObjectId(this, prefabObjectId) == nullptr)
|
||||
{
|
||||
if (!hasRemovedObjects)
|
||||
{
|
||||
@@ -934,7 +951,7 @@ void Actor::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
for (int32 i = 0; i < other->Scripts.Count(); i++)
|
||||
{
|
||||
const Guid prefabObjectId = other->Scripts[i]->GetPrefabObjectID();
|
||||
if (GetScriptByPrefabObjectId(prefabObjectId) == nullptr)
|
||||
if (GetScriptByPrefabObjectId(this, prefabObjectId) == nullptr)
|
||||
{
|
||||
if (!hasRemovedObjects)
|
||||
{
|
||||
@@ -1295,20 +1312,6 @@ Script* Actor::GetScriptByID(const Guid& id) const
|
||||
return result;
|
||||
}
|
||||
|
||||
Script* Actor::GetScriptByPrefabObjectId(const Guid& prefabObjectId) const
|
||||
{
|
||||
Script* result = nullptr;
|
||||
for (int32 i = 0; i < Scripts.Count(); i++)
|
||||
{
|
||||
if (Scripts[i]->GetPrefabObjectID() == prefabObjectId)
|
||||
{
|
||||
result = Scripts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Actor::IsPrefabRoot() const
|
||||
{
|
||||
return _isPrefabRoot != 0;
|
||||
|
||||
@@ -240,13 +240,6 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the child actor by its prefab object identifier.
|
||||
/// </summary>
|
||||
/// <param name="prefabObjectId">The prefab object identifier.</param>
|
||||
/// <returns>The actor or null.</returns>
|
||||
Actor* GetChildByPrefabObjectId(const Guid& prefabObjectId) const;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
@@ -692,13 +685,6 @@ public:
|
||||
/// <returns>The script or null.</returns>
|
||||
Script* GetScriptByID(const Guid& id) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the script by its prefab object identifier.
|
||||
/// </summary>
|
||||
/// <param name="prefabObjectId">The prefab object identifier.</param>
|
||||
/// <returns>The script or null.</returns>
|
||||
Script* GetScriptByPrefabObjectId(const Guid& prefabObjectId) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this actor is a prefab instance root object.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user