| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a61f5f9 commit 3995c39
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1250,6 +1250,48 @@ static PyObject *py_ue_line_trace_multi_by_channel(ue_PyUObject * self, PyObject | |||
| 1250 | 1250 | ||
| 1251 | 1251 | } | |
| 1252 | 1252 | ||
| 1253 | + static PyObject *py_ue_get_hit_result_under_cursor(ue_PyUObject * self, PyObject * args) { | ||
| 1254 | + | ||
| 1255 | + ue_py_check(self); | ||
| 1256 | + | ||
| 1257 | + int channel; | ||
| 1258 | + PyObject *trace_complex = NULL; | ||
| 1259 | + | ||
| 1260 | + UWorld *world = ue_get_uworld(self); | ||
| 1261 | + if (!world) | ||
| 1262 | + return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject"); | ||
| 1263 | + | ||
| 1264 | + | ||
| 1265 | + if (!PyArg_ParseTuple(args, "i|O:get_hit_result_under_cursor", &channel, &trace_complex)) { | ||
| 1266 | + return NULL; | ||
| 1267 | + } | ||
| 1268 | + | ||
| 1269 | + | ||
| 1270 | + bool complex = false; | ||
| 1271 | + if (trace_complex && PyObject_IsTrue(trace_complex)) { | ||
| 1272 | + complex = true; | ||
| 1273 | + } | ||
| 1274 | + | ||
| 1275 | + APlayerController *controller = world->GetFirstPlayerController(); | ||
| 1276 | + | ||
| 1277 | + if (!controller) | ||
| 1278 | + return PyErr_Format(PyExc_Exception, "unable to find first player controller"); | ||
| 1279 | + | ||
| 1280 | + FHitResult hit; | ||
| 1281 | + | ||
| 1282 | + bool got_hit = controller->GetHitResultUnderCursor((ECollisionChannel)channel, complex, hit); | ||
| 1283 | + | ||
| 1284 | + if (got_hit) { | ||
| 1285 | + PyObject *ret = (PyObject *)ue_get_python_wrapper(hit.GetActor()); | ||
| 1286 | + if (!ret) | ||
| 1287 | + return PyErr_Format(PyExc_Exception, "uobject is in invalid state"); | ||
| 1288 | + return Py_BuildValue("Offffff", ret, hit.ImpactPoint.X, hit.ImpactPoint.Y, hit.ImpactPoint.Z, hit.ImpactNormal.X, hit.ImpactNormal.Y, hit.ImpactNormal.Z); | ||
| 1289 | + } | ||
| 1290 | + | ||
| 1291 | + return Py_BuildValue("Offffff", Py_None, 0, 0, 0, 0, 0, 0); | ||
| 1292 | + | ||
| 1293 | + } | ||
| 1294 | + | ||
| 1253 | 1295 | ||
| 1254 | 1296 | ||
| 1255 | 1297 | static PyObject *py_ue_is_a(ue_PyUObject *, PyObject *); | |
@@ -1299,6 +1341,7 @@ static PyMethodDef ue_PyUObject_methods[] = { | |||
| 1299 | 1341 | { "get_actor_bounds", (PyCFunction)py_ue_get_actor_bounds, METH_VARARGS, "" }, | |
| 1300 | 1342 | { "line_trace_single_by_channel", (PyCFunction)py_ue_line_trace_single_by_channel, METH_VARARGS, "" }, | |
| 1301 | 1343 | { "line_trace_multi_by_channel", (PyCFunction)py_ue_line_trace_multi_by_channel, METH_VARARGS, "" }, | |
| 1344 | + { "get_hit_result_under_cursor", (PyCFunction)py_ue_get_hit_result_under_cursor, METH_VARARGS, "" }, | ||
| 1302 | 1345 | { "show_mouse_cursor", (PyCFunction)py_ue_show_mouse_cursor, METH_VARARGS, "" }, | |
| 1303 | 1346 | { "enable_click_events", (PyCFunction)py_ue_enable_click_events, METH_VARARGS, "" }, | |
| 1304 | 1347 | { "enable_mouse_over_events", (PyCFunction)py_ue_enable_mouse_over_events, METH_VARARGS, "" }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,9 @@ void APyPawn::BeginPlay() | |||
| 75 | 75 | UE_LOG(LogPython, Error, TEXT("Unable to set 'uobject' field in pawn wrapper class")); | |
| 76 | 76 | } | |
| 77 | 77 | ||
| 78 | + if (!PyObject_HasAttrString(py_pawn_instance, "begin_play")) | ||
| 79 | + return; | ||
| 80 | + | ||
| 78 | 81 | PyObject *bp_ret = PyObject_CallMethod(py_pawn_instance, "begin_play", NULL); | |
| 79 | 82 | if (!bp_ret) { | |
| 80 | 83 | unreal_engine_py_log_error(); | |
@@ -92,6 +95,9 @@ void APyPawn::Tick(float DeltaTime) | |||
| 92 | 95 | if (!py_pawn_instance) | |
| 93 | 96 | return; | |
| 94 | 97 | ||
| 98 | + if (!PyObject_HasAttrString(py_pawn_instance, "tick")) | ||
| 99 | + return; | ||
| 100 | + | ||
| 95 | 101 | PyObject *ret = PyObject_CallMethod(py_pawn_instance, "tick", "f", DeltaTime); | |
| 96 | 102 | if (!ret) { | |
| 97 | 103 | unreal_engine_py_log_error(); | |
@@ -107,6 +113,9 @@ void APyPawn::PyOnActorBeginOverlap(AActor *overlapped, AActor *other) | |||
| 107 | 113 | if (!py_pawn_instance) | |
| 108 | 114 | return; | |
| 109 | 115 | ||
| 116 | + if (!PyObject_HasAttrString(py_pawn_instance, "on_actor_begin_overlap")) | ||
| 117 | + return; | ||
| 118 | + | ||
| 110 | 119 | PyObject *ret = PyObject_CallMethod(py_pawn_instance, "on_actor_begin_overlap", "O", (PyObject *)ue_get_python_wrapper(other)); | |
| 111 | 120 | if (!ret) { | |
| 112 | 121 | unreal_engine_py_log_error(); | |
@@ -120,6 +129,9 @@ void APyPawn::PyOnActorClicked(AActor *touched_actor, FKey button_pressed) | |||
| 120 | 129 | if (!py_pawn_instance) | |
| 121 | 130 | return; | |
| 122 | 131 | ||
| 132 | + if (!PyObject_HasAttrString(py_pawn_instance, "on_actor_clicked")) | ||
| 133 | + return; | ||
| 134 | + | ||
| 123 | 135 | PyObject *ret = PyObject_CallMethod(py_pawn_instance, "on_actor_clicked", "Os", (PyObject *)ue_get_python_wrapper(touched_actor), TCHAR_TO_UTF8(*button_pressed.ToString())); | |
| 124 | 136 | if (!ret) { | |
| 125 | 137 | unreal_engine_py_log_error(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments