9 const std::shared_ptr<eng::IAudio> &audio)
12 auto ®istry = AScene::getRegistry();
14 registry.onComponentAdded(
15 [&renderer, &audio, ®istry](
const ecs::Entity e,
const std::type_info &type)
17 const auto *audioComp = registry.getComponent<
ecs::Audio>(e);
18 const auto *colorComp = registry.getComponent<
ecs::Color>(e);
19 const auto *fontComp = registry.getComponent<
ecs::Font>(e);
20 const auto *rectComp = registry.getComponent<
ecs::Rect>(e);
21 const auto *scaleComp = registry.getComponent<
ecs::Scale>(e);
22 const auto *textComp = registry.getComponent<
ecs::Text>(e);
23 const auto *textureComp = registry.getComponent<
ecs::Texture>(e);
28 if (textComp && transform && fontComp)
30 renderer->createFont(fontComp->
id, fontComp->path);
32 {.font_name = fontComp->
id,
33 .color = {.r = colorComp->r, .g = colorComp->g, .b = colorComp->b, .a = colorComp->a},
34 .content = textComp->content,
35 .size = textComp->font_size,
38 .name = textComp->
id});
43 const float scale_x = scaleComp ? scaleComp->x : 1.F;
44 const float scale_y = scaleComp ? scaleComp->y : 1.F;
46 renderer->createTexture(textureComp->
id, textureComp->path);
48 if (transform && textureComp)
52 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
53 transform->y, scale_x, scale_y,
static_cast<int>(rectComp->pos_x),
54 static_cast<int>(rectComp->pos_y), rectComp->size_x, rectComp->size_y);
58 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
67 audio->createAudio(audioComp->path, audioComp->volume, audioComp->loop,
68 audioComp->id + std::to_string(e));
74 registry.createEntity()
76 .with<ecs::Transform>(
"transform_title", 10.F, 10.F, 0.F)
78 .with<ecs::Text>(
"id", std::string(
"RType Client"), 50U)
82 .with<ecs::Transform>(
"transform_fps", 10.F, 70.F, 0.F)
84 .with<ecs::Text>(
"id_text", std::string(
"FPS: 0"), 20U)
89 registry.createEntity()
91 .with<ecs::Transform>(
"transform_menu", 100.F, 200.F + i * 60.F, 0.F)