22 world, 0, name,
"::",
"::",
false);
24 ecs_warn(
"unresolved const variable '%s', returning default", name);
29 if (value.
ptr ==
nullptr) {
30 ecs_warn(
"entity '%s' is not a const variable, returning default",
39 inline T get_const_value(
44 ecs_warn(
"cannot cast const variable '%s' from type '%s' to '%s', "
45 "returning default", name, var_type, requested_type);
46 ecs_os_free(requested_type);
47 ecs_os_free(var_type);
52 inline char get_const_value<char>(
55 (void)name; (void)type; (void)default_value;
61 inline int8_t get_const_value<int8_t>(
64 (void)name; (void)type; (void)default_value;
70 inline int16_t get_const_value<int16_t>(
73 (void)name; (void)type; (void)default_value;
79 inline int32_t get_const_value<int32_t>(
82 (void)name; (void)type; (void)default_value;
88 inline int64_t get_const_value<int64_t>(
91 (void)name; (void)type; (void)default_value;
97 inline uint8_t get_const_value<uint8_t>(
100 (void)name; (void)type; (void)default_value;
106 inline uint16_t get_const_value<uint16_t>(
109 (void)name; (void)type; (void)default_value;
115 inline uint32_t get_const_value<uint32_t>(
118 (void)name; (void)type; (void)default_value;
124 inline uint64_t get_const_value<uint64_t>(
127 (void)name; (void)type; (void)default_value;
133 inline float get_const_value<float>(
136 (void)name; (void)type; (void)default_value;
142 inline double get_const_value<double>(
145 (void)name; (void)type; (void)default_value;
152inline T world::get_const_var(
154 const T& default_value)
const
158 return default_value;
162 if (type == value.
type) {
163 return *(
static_cast<T*
>(value.
ptr));
166 return flecs::_::get_const_value<T>(
167 world_, name, value, type, default_value);
171void world::get_const_var(
174 const T& default_value)
const
183 if (type == value.
type) {
184 out = *(
static_cast<T*
>(value.
ptr));
188 out = flecs::_::get_const_value<T>(
189 world_, name, value, type, default_value);
197 world.
component<Script>(
"flecs::script::Script");
#define ecs_warn(...)
Warning macro.
FLECS_API ecs_entity_t ecs_script_init(ecs_world_t *world, const ecs_script_desc_t *desc)
Load managed script.
FLECS_API ecs_value_t ecs_const_var_get(const ecs_world_t *world, ecs_entity_t var)
Return the value for a const variable.
ecs_id_t ecs_entity_t
An entity identifier.
script_builder script(const char *name=nullptr) const
Build a script.
flecs::component< T > component(Args &&... args) const
Find or register a component.
ecs_entity_t entity_t
Entity type.
ecs_world_t world_t
World type.
#define ecs_get_path(world, child)
Get path from root.
ecs_entity_t ecs_lookup_path_w_sep(const ecs_world_t *world, ecs_entity_t parent, const char *path, const char *sep, const char *prefix, bool recursive)
Look up an entity from a path.
Utility to hold a value of a dynamic type.
void * ptr
Pointer to value.
ecs_entity_t type
Type of value.
flecs::entity run() const
Run the script and return the script entity.
world_t * world_
Pointer to the underlying C world.