|
3 | 3 | #include "pyunrealsdk/static_py_object.h" |
4 | 4 | #include "pyunrealsdk/unreal_bindings/uenum.h" |
5 | 5 | #include "pyunrealsdk/unreal_bindings/wrapped_array.h" |
| 6 | +#include "pyunrealsdk/unreal_bindings/wrapped_struct.h" |
6 | 7 | #include "unrealsdk/unreal/cast.h" |
7 | 8 | #include "unrealsdk/unreal/classes/properties/uarrayproperty.h" |
| 9 | +#include "unrealsdk/unreal/classes/properties/ustructproperty.h" |
8 | 10 | #include "unrealsdk/unreal/classes/uconst.h" |
9 | 11 | #include "unrealsdk/unreal/classes/uenum.h" |
10 | 12 | #include "unrealsdk/unreal/classes/ufield.h" |
@@ -140,6 +142,9 @@ py::object py_getattr(UField* field, |
140 | 142 | field->Name, field->Class->Name)); |
141 | 143 | } |
142 | 144 |
|
| 145 | +// The templated lambda and all the if constexprs make everything have a really high penalty |
| 146 | +// Yes it's probably a bit complex, but it's also a bit awkward trying to split it up |
| 147 | +// NOLINTNEXTLINE(readability-function-cognitive-complexity) |
143 | 148 | void py_setattr_direct(UField* field, uintptr_t base_addr, const py::object& value) { |
144 | 149 | if (!field->is_instance(find_class<UProperty>())) { |
145 | 150 | throw py::attribute_error(unrealsdk::fmt::format( |
@@ -204,6 +209,13 @@ void py_setattr_direct(UField* field, uintptr_t base_addr, const py::object& val |
204 | 209 | } |
205 | 210 |
|
206 | 211 | for (size_t i = 0; i < seq_size; i++) { |
| 212 | + // If we're setting a struct property, we might be being told to ignore it |
| 213 | + if constexpr (std::is_base_of_v<UStructProperty, T>) { |
| 214 | + if (is_ignore_struct_sentinel(value_seq[i])) { |
| 215 | + continue; |
| 216 | + } |
| 217 | + } |
| 218 | + |
207 | 219 | set_property<T>(prop, i, base_addr, py::cast<value_type>(value_seq[i])); |
208 | 220 | } |
209 | 221 | }); |
|
0 commit comments