MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / TryFindObject

Method TryFindObject

Source/Engine/Scripting/Scripting.cpp:978–1012  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

976}
977
978ScriptingObject* Scripting::TryFindObject(Guid id, const MClass* type)
979{
980 if (!id.IsValid())
981 return nullptr;
982 PROFILE_CPU();
983
984 // Try to map object id
985 const auto idsMapping = ObjectsLookupIdMapping.Get();
986 if (idsMapping)
987 {
988 idsMapping->TryGet(id, id);
989 }
990
991 // Try to find it
992#if USE_OBJECTS_DISPOSE_CRASHES_DEBUGGING
993 ScriptingObjectData data;
994 _objectsLocker.Lock();
995 _objectsDictionary.TryGet(id, data);
996 _objectsLocker.Unlock();
997 auto result = data.Ptr;
998#else
999 ScriptingObject* result = nullptr;
1000 _objectsLocker.Lock();
1001 _objectsDictionary.TryGet(id, result);
1002 _objectsLocker.Unlock();
1003#endif
1004
1005 // Check type
1006 if (result && type && !result->Is(type))
1007 {
1008 result = nullptr;
1009 }
1010
1011 return result;
1012}
1013
1014ScriptingObject* Scripting::TryFindObject(const MClass* type)
1015{

Callers

nothing calls this directly

Calls 9

LockMethod · 0.80
UnlockMethod · 0.80
IsValidMethod · 0.45
GetMethod · 0.45
TryGetMethod · 0.45
IsMethod · 0.45
BeginMethod · 0.45
IsNotEndMethod · 0.45
GetClassMethod · 0.45

Tested by

no test coverage detected