PyObject *py_ue_get_actor_components_by_type(ue_PyUObject * self, PyObject * args) { ue_py_check(self); PyObject *obj; if (!PyArg_ParseTuple(args, "O:get_actor_components_by_type", &obj)) { return NULL; } ue_PyUObject *py_obj = nullptr; if (ue_is_pyuobject(obj)) { py_obj = (ue_PyUObject *)obj; } // shortcut for finding class by string else if (PyUnicodeOrString_Check(obj)) { char *class_name = PyUnicode_AsUTF8(obj); UClass *u_class = FindObject<UClass>(ANY_PACKAGE, UTF8_TO_TCHAR(class_name)); if (u_class) { py_obj = ue_get_python_uobject(u_class); } } if (!py_obj) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); if (!py_obj->ue_object->IsA<UClass>()) return PyErr_Format(PyExc_Exception, "argument is not a UClass"); AActor *actor = ue_get_actor(self); if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); PyObject *components = PyList_New(0); for (UActorComponent *component : actor->GetComponentsByClass((UClass *)py_obj->ue_object)) { ue_PyUObject *item = ue_get_python_uobject(component); if (item) PyList_Append(components, (PyObject *)item); } return components; }
void FPythonSmartDelegate::PyFOnAssetPostImport(UFactory *factory, UObject *u_object) { FScopePythonGIL gil; PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OO", ue_get_python_uobject((UObject *)factory), ue_get_python_uobject(u_object)); if (!ret) { unreal_engine_py_log_error(); return; } Py_DECREF(ret); }
PyObject *py_ue_get_overlapping_actors(ue_PyUObject * self, PyObject * args) { ue_py_check(self); AActor *actor = ue_get_actor(self); if (!actor) return PyErr_Format(PyExc_Exception, "cannot retrieve actor from UObject"); PyObject *class_filter = nullptr; if (!PyArg_ParseTuple(args, "|O:get_overlapping_actors", &class_filter)) { return NULL; } UClass *filtering = AActor::StaticClass(); if (class_filter) { if (!ue_is_pyuobject(class_filter)) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); ue_PyUObject *py_obj = (ue_PyUObject *)class_filter; if (!py_obj->ue_object->IsA((UClass *)py_obj->ue_object)) return PyErr_Format(PyExc_Exception, "argument is not a UClass"); filtering = (UClass *)py_obj->ue_object; } PyObject *py_overlapping_actors = PyList_New(0); TArray<AActor *> overalpping_actors; actor->GetOverlappingActors(overalpping_actors, filtering); for (AActor *overlapping_actor : overalpping_actors) { ue_PyUObject *item = ue_get_python_uobject(overlapping_actor); if (item) { PyList_Append(py_overlapping_actors, (PyObject *)item); } } return py_overlapping_actors; }
PyObject *py_ue_actor_components(ue_PyUObject * self, PyObject * args) { ue_py_check(self); AActor *actor = ue_get_actor(self); if (!actor) return PyErr_Format(PyExc_Exception, "cannot retrieve Actor from uobject"); PyObject *ret = PyList_New(0); for (UActorComponent *component : actor->GetComponents()) { ue_PyUObject *py_obj = ue_get_python_uobject(component); if (!py_obj) continue; PyList_Append(ret, (PyObject *)py_obj); } return ret; }