39 std::vector<std::pair<Entity, int>> spritesWithLayers;
40 spritesWithLayers.reserve(
45 const auto entity = pair.first;
47 int layerValue = (layer !=
nullptr) ? layer->
layer : 0;
48 spritesWithLayers.emplace_back(entity, layerValue);
50 std::sort(spritesWithLayers.begin(), spritesWithLayers.end(),
51 [](
const auto &a,
const auto &b) { return a.second < b.second; });
52 std::string spriteName;
53 spriteName.reserve(64);
55 for (
const auto &pair : spritesWithLayers)
57 const auto entity = pair.first;
68 const float x = (transform !=
nullptr) ? transform->x : 0.F;
69 const float y = (transform !=
nullptr) ? transform->y : 0.F;
72 spriteName = sprite->id;
73 spriteName += std::to_string(entity);
77 if ((scale !=
nullptr) && !hasScrolling)
84 static_cast<int>(rect->pos_y), rect->size_x, rect->size_y);
89 {.r = color->r, .g = color->g, .b = color->b, .a = color->a});
This file contains the component definitions.
This file contains the IRenderer class declaration.
This file contains the interface for systems.
This file contains the Registry class declaration.
Abstract class for system.
Class for managing entities and their components.
bool hasComponent(Entity e)
std::unordered_map< Entity, T > & getAll()
T * getComponent(Entity e)
void update(Registry ®istry, float) override
~SpriteSystem() override=default
SpriteSystem(const SpriteSystem &)=delete
SpriteSystem & operator=(const SpriteSystem &)=delete
SpriteSystem(SpriteSystem &&)=delete
SpriteSystem & operator=(SpriteSystem &&)=delete
SpriteSystem(const std::shared_ptr< eng::IRenderer > &renderer)
const std::shared_ptr< eng::IRenderer > & m_renderer
virtual void drawSprite(const std::string &name)=0
virtual void setSpriteScale(const std::string &name, int x, int y)=0
virtual void setSpriteColor(const std::string &name, Color color)=0
virtual void setSpritePosition(const std::string &name, float x, float y)=0
virtual void setSpriteTexture(const std::string &name, const std::string &path)=0
virtual void setSpriteFrame(const std::string &name, int fx, int fy, int fnx, int fny)=0