// // Created by sebastian on 13.02.26. // #include "BuildingFactory.h" #include "../../../engine/core/ECS/ModelComponent.h" #include "../../../engine/core/ECS/ModelStateComponent.h" #include "../../../engine/core/ECS/TransformComponent.h" #include "../../../engine/renderer/loader/AssetManager.h" #include "../ecs/components/ProducingComponent.h" EntityID BuildingFactory::create(EntityManager &em, const BuildingDefinition &def, const TransformComponent &tileTransform, EntityID tileEntity, PlayerID owner) { EntityID e = em.createEntity(); em.addComponent(e, std::make_shared(AssetManager::getModelStages(def.model), def.model)); if (def.type == BuildingType::FOREST_HUT) { em.addComponent(e, std::make_shared( tileTransform.position, glm::vec3(0), 1.f )); } else { em.addComponent(e, std::make_shared( tileTransform.position, glm::vec3(0), 2.f )); } em.addComponent(e, std::make_shared(def.type, tileEntity)); em.addComponent(e, std::make_shared(owner)); auto modelStateComponent = std::make_shared(); modelStateComponent->params["fillRatio"] = 0.f; auto producingComponent = std::make_shared( ProducingComponent(def.produces, def.baseAmountPerTurn, false)); producingComponent->setMaxStorage(def.maxStorage); em.addComponent(e, modelStateComponent); em.addComponent(e, producingComponent); return e; }