|
8 | 8 | #include <flecs.h> |
9 | 9 | #include <godot_cpp/variant/utility_functions.hpp> |
10 | 10 |
|
11 | | -#define ERR(return_value, ...) \ |
12 | | - UtilityFunctions::printerr(__VA_ARGS__); \ |
13 | | - UtilityFunctions::push_error(__VA_ARGS__); \ |
| 11 | +#define WARN(...) \ |
| 12 | + UtilityFunctions::print_rich("[color='INDIAN_RED']GLECS: ", __VA_ARGS__); \ |
| 13 | + UtilityFunctions::push_error(__VA_ARGS__); |
| 14 | +#define ERR(return_value, ...) \ |
| 15 | + WARN(__VA_ARGS__); \ |
14 | 16 | return return_value; |
15 | 17 |
|
16 | | -#define CHECK_ENTITY_ALIVE(entity, gf_world, return_value, ...) \ |
17 | | - if (!gf_world->is_id_alive(entity)) { \ |
18 | | - ERR(return_value, \ |
19 | | - __VA_ARGS__, \ |
20 | | - " ID ", entity, " is not alive" \ |
21 | | - ); \ |
| 18 | +#define CHECK_ENTITY_ALIVE(entity, gf_world, return_value, ...) \ |
| 19 | + if (!gf_world->is_id_alive(entity)) { \ |
| 20 | + ERR(return_value, \ |
| 21 | + __VA_ARGS__, \ |
| 22 | + " ID ", entity, " is not alive" \ |
| 23 | + ); \ |
22 | 24 | } |
23 | 25 |
|
24 | | -#define CHECK_NOT_HAS_CHILD(entity, child_name, gf_world, return_value, err) \ |
25 | | - if (gf_world->id_has_child(entity, child_name)) { \ |
26 | | - ERR(return_value, \ |
27 | | - err, \ |
28 | | - " ", gf_world->id_to_text(entity) ," already has a child named \"", child_name, "\"" \ |
29 | | - ); \ |
| 26 | +#define CHECK_NOT_HAS_CHILD(entity, child_name, gf_world, return_value, err) \ |
| 27 | + if (gf_world->id_has_child(entity, child_name)) { \ |
| 28 | + ERR(return_value, \ |
| 29 | + err, \ |
| 30 | + " ", gf_world->id_to_text(entity) ," already has a child named \"", child_name, "\"" \ |
| 31 | + ); \ |
30 | 32 | } |
31 | 33 |
|
32 | | -#define CHECK_NOT_PAIR(entity, gf_world, return_value, ...) \ |
33 | | - if (!gf_world->is_id_alive(entity)) { \ |
34 | | - ERR(return_value, \ |
35 | | - __VA_ARGS__, \ |
36 | | - " Entity ", gf_world->id_to_text(entity), " is a pair" \ |
37 | | - ); \ |
| 34 | +#define CHECK_NOT_PAIR(entity, gf_world, return_value, ...) \ |
| 35 | + if (!gf_world->is_id_alive(entity)) { \ |
| 36 | + ERR(return_value, \ |
| 37 | + __VA_ARGS__, \ |
| 38 | + " Entity ", gf_world->id_to_text(entity), " is a pair" \ |
| 39 | + ); \ |
38 | 40 | } |
39 | 41 |
|
40 | 42 | template <typename T, typename E> |
@@ -86,12 +88,6 @@ class Result { |
86 | 88 | }; |
87 | 89 | }; |
88 | 90 |
|
89 | | -#define CHECK_VARIANT(VALUE, VARIANT_TYPE) \ |
90 | | - if (value.get_type() != VARIANT_TYPE) { ERR(/**/, \ |
91 | | - "Expected variant value, ", VALUE, ", to be of type ", \ |
92 | | - Variant::get_type_name(VARIANT_TYPE), \ |
93 | | - ", but is of type ", Variant::get_type_name(VALUE.get_type()) \ |
94 | | - ); } \ |
95 | 91 |
|
96 | 92 | namespace godot { |
97 | 93 | typedef Result<ecs_entity_t, String> EntityResult; |
|
0 commit comments