11 auto ®istry = AScene::getRegistry();
13 registry.onComponentAdded(
14 [&renderer, &audio, ®istry](
const ecs::Entity e,
const std::type_info &type)
16 const auto *audioComp = registry.getComponent<
ecs::Audio>(e);
17 const auto *colorComp = registry.getComponent<
ecs::Color>(e);
18 const auto *fontComp = registry.getComponent<
ecs::Font>(e);
19 const auto *rectComp = registry.getComponent<
ecs::Rect>(e);
20 const auto *scaleComp = registry.getComponent<
ecs::Scale>(e);
21 const auto *textComp = registry.getComponent<
ecs::Text>(e);
22 const auto *textureComp = registry.getComponent<
ecs::Texture>(e);
27 if (textComp && transform && fontComp)
29 renderer->createFont(fontComp->
id, fontComp->path);
31 {.font_name = fontComp->
id,
32 .color = {.r = colorComp->r, .g = colorComp->g, .b = colorComp->b, .a = colorComp->a},
33 .content = textComp->content,
34 .size = textComp->font_size,
37 .name = textComp->
id});
42 const float scale_x = scaleComp ? scaleComp->x : 1.F;
43 const float scale_y = scaleComp ? scaleComp->y : 1.F;
45 renderer->createTexture(textureComp->
id, textureComp->path);
47 if (transform && textureComp)
51 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
52 transform->y, scale_x, scale_y,
static_cast<int>(rectComp->pos_x),
53 static_cast<int>(rectComp->pos_y), rectComp->size_x, rectComp->size_y);
57 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
66 audio->createAudio(audioComp->path, audioComp->volume, audioComp->loop,
67 audioComp->id + std::to_string(e));
73 registry.createEntity()
75 .with<ecs::Transform>(
"transform_title", 10.F, 10.F, 0.F)
77 .with<ecs::Text>(
"id", std::string(
"RType Client"), 50U)
81 .with<ecs::Transform>(
"transform_fps", 10.F, 70.F, 0.F)
83 .with<ecs::Text>(
"id_text", std::string(
"FPS: 0"), 20U)
88 registry.createEntity()
90 .with<ecs::Transform>(
"transform_menu", 100.F, 200.F + i * 60.F, 0.F)