Flecs
v4.1
A fast entity component system (ECS) for C & C++
Toggle main menu visibility
Loading...
Searching...
No Matches
builder.hpp
Go to the documentation of this file.
1
5
6
#pragma once
7
8
namespace
flecs {
9
14
16
struct
script_builder
{
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
49
protected
:
50
flecs::world_t
*world_;
51
ecs_script_desc_t
desc_;
52
};
53
54
}
flecs::world_t
ecs_world_t world_t
World type.
Definition
c_types.hpp:18
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:1046
ecs_entity_desc_t::sep
const char * sep
Optional custom separator for hierarchical names.
Definition
flecs.h:1058
ecs_entity_desc_t::root_sep
const char * root_sep
Optional, used for identifiers relative to the root.
Definition
flecs.h:1062
ecs_entity_desc_t::name
const char * name
Name of the entity.
Definition
flecs.h:1053
ecs_script_desc_t
Used with ecs_script_init().
Definition
script.h:336
flecs::entity
Entity.
Definition
entity.hpp:30
flecs::script_builder::script_builder
script_builder(flecs::world_t *world, const char *name=nullptr)
Construct a script builder.
Definition
builder.hpp:21
flecs::script_builder::run
flecs::entity run() const
Run the script and return the script entity.
Definition
impl.hpp:13
flecs::script_builder::filename
script_builder & filename(const char *str)
Set the script filename.
Definition
builder.hpp:41
flecs::script_builder::code
script_builder & code(const char *str)
Set the script code.
Definition
builder.hpp:35
flecs::world
The world.
Definition
world.hpp:246