Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
builder.hpp
Go to the documentation of this file.
1
6#pragma once
7
8namespace flecs {
9
21 script_builder(flecs::world_t *world, const char *name = nullptr)
22 : world_(world)
23 , desc_{}
24 {
25 if (name != nullptr) {
26 ecs_entity_desc_t entity_desc = {};
27 entity_desc.name = name;
28 entity_desc.sep = "::";
29 entity_desc.root_sep = "::";
30 this->desc_.entity = ecs_entity_init(world, &entity_desc);
31 }
32 }
33
35 script_builder& code(const char *str) {
36 desc_.code = str;
37 return *this;
38 }
39
41 script_builder& filename(const char *str) {
42 desc_.filename = str;
43 return *this;
44 }
45
47 flecs::entity run() const;
48
49protected:
50 flecs::world_t *world_;
52};
53
54}
ecs_world_t world_t
World type.
Definition c_types.hpp:18
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
Used with ecs_entity_init().
Definition flecs.h:1042
const char * sep
Optional custom separator for hierarchical names.
Definition flecs.h:1054
const char * root_sep
Optional, used for identifiers relative to the root.
Definition flecs.h:1058
const char * name
Name of the entity.
Definition flecs.h:1049
Used with ecs_script_init().
Definition script.h:332
const char * code
Set to parse script from string.
Definition script.h:335
ecs_entity_t entity
Set to customize entity handle associated with script.
Definition script.h:333
const char * filename
Set to load script from file.
Definition script.h:334
Entity.
Definition entity.hpp:30
Script builder interface.
Definition builder.hpp:16
script_builder(flecs::world_t *world, const char *name=nullptr)
Construct a script builder.
Definition builder.hpp:21
flecs::entity run() const
Run the script and return the script entity.
Definition impl.hpp:13
script_builder & filename(const char *str)
Set the script filename.
Definition builder.hpp:41
script_builder & code(const char *str)
Set the script code.
Definition builder.hpp:35
The world.
Definition world.hpp:246