Merge pull request #720 from bruvzg/get_instance

pull/725/head
Rémi Verschelde 2022-03-09 17:51:32 +01:00 committed by GitHub
commit 5f1030d119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -134,6 +134,17 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const char *p_name, const Args
arguments = { args... };
}
class ObjectDB {
public:
static Object *get_instance(uint64_t p_object_id) {
GDNativeObjectPtr obj = internal::gdn_interface->object_get_instance_from_id(p_object_id);
if (obj == nullptr) {
return nullptr;
}
return reinterpret_cast<Object *>(internal::gdn_interface->object_get_instance_binding(obj, internal::token, &Object::___binding_callbacks));
}
};
template <class T>
T *Object::cast_to(Object *p_object) {
GDNativeObjectPtr casted = internal::gdn_interface->object_cast_to(p_object->_owner, internal::gdn_interface->classdb_get_class_tag(T::get_class_static()));