| 976 | } |
| 977 | |
| 978 | ScriptingObject* 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 | |
| 1014 | ScriptingObject* Scripting::TryFindObject(const MClass* type) |
| 1015 | { |