#pragma once #include "ECS.h" #include "TransformComponent.h" #include "SDL.h" #include "TextureDict.h" class TileComponent : public Component { public: TransformComponent* transform; SpriteComponent* sprite; SDL_Rect tileRect; int tileID; const char* path; TileComponent() = default; TileComponent(int x, int y, int w, int h, int id) { this->tileRect.x = x; this->tileRect.y = y; this->tileRect.w = w; this->tileRect.h = h; tileID = id; auto it = textureDict.find(tileID)->second; this->path = it; } ~TileComponent() = default; void init() override { this->entity->addComponent(this->tileRect.x, this->tileRect.y, this->tileRect.w, this->tileRect.h, 1); this->transform = &entity->getComponent(); this->entity->addComponent(this->path); this->sprite = &entity->getComponent(); } };