Flecs: include/flecs/addons/cpp/mixins/script/builder.hpp Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
builder.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8namespace flecs {
9
14
16 struct script_builder {
17 script_builder(flecs::world_t *world, const char *name = nullptr)
18 : world_(world)
19 , desc_{}
20 {
21 if (name != nullptr) {
22 ecs_entity_desc_t entity_desc = {};
23 entity_desc.name = name;
24 entity_desc.sep = "::";
25 entity_desc.root_sep = "::";
26 this->desc_.entity = ecs_entity_init(world, &entity_desc);
27 }
28 }
29
30 script_builder& code(const char *str) {
31 desc_.code = str;
32 return *this;
33 }
34
35 script_builder& filename(const char *str) {
36 desc_.filename = str;
37 return *this;
38 }
39
40 flecs::entity run() const;
41
42protected:
43 flecs::world_t *world_;
44 ecs_script_desc_t desc_;
45};
46
47}
ecs_entity_init
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
ecs_entity_desc_t
Used with ecs_entity_init().
Definition flecs.h:1012
ecs_entity_desc_t::sep
const char * sep
Optional custom separator for hierarchical names.
Definition flecs.h:1024
ecs_entity_desc_t::root_sep
const char * root_sep
Optional, used for identifiers relative to root.
Definition flecs.h:1028
ecs_entity_desc_t::name
const char * name
Name of the entity.
Definition flecs.h:1019
ecs_script_desc_t
Used with ecs_script_init()
Definition script.h:296
flecs::entity
Entity.
Definition entity.hpp:30
flecs::world
The world.
Definition world.hpp:137