From fe376e9c0f7cc7c779d026c2fe0ce61fa08d8651 Mon Sep 17 00:00:00 2001 From: sebastian Date: Sun, 8 Feb 2026 18:30:25 +0100 Subject: [PATCH] UPD: Introduce ECS System --- CMakeLists.txt | 22 ++++- src/engine/core/ECS/Component.cpp | 5 ++ src/engine/core/ECS/Component.h | 16 ++++ src/engine/core/ECS/EntityManager.cpp | 17 ++++ src/engine/core/ECS/EntityManager.h | 80 +++++++++++++++++++ src/engine/core/ECS/ModelComponent.cpp | 5 ++ src/engine/core/ECS/ModelComponent.h | 21 +++++ src/engine/core/ECS/RenderSystem.cpp | 24 ++++++ src/engine/core/ECS/RenderSystem.h | 18 +++++ src/engine/core/ECS/TileRenderComponent.cpp | 5 ++ src/engine/core/ECS/TileRenderComponent.h | 22 +++++ src/engine/core/ECS/TransformComponent.cpp | 5 ++ src/engine/core/ECS/TransformComponent.h | 20 +++++ src/engine/layer/entities/Entity.h | 1 - src/engine/renderer/MasterRenderer.cpp | 11 ++- src/engine/renderer/MasterRenderer.h | 9 +-- src/engine/renderer/Renderer.cpp | 4 +- src/engine/renderer/Renderer.h | 3 +- src/engine/renderer/TerrainRenderer.cpp | 8 +- src/engine/renderer/TerrainRenderer.h | 7 +- .../components/TerrainRenderingData.h | 20 +++++ src/engine/renderer/model/AssetManager.cpp | 6 ++ src/engine/renderer/model/AssetManager.h | 1 + src/game/GameLayer.cpp | 38 ++++----- src/game/GameLayer.h | 9 ++- src/game/TileInteractionSystem.cpp | 30 ------- src/game/TileInteractionSystem.h | 19 ----- src/game/hexWorld/HexModelFactory.h | 4 +- src/game/hexWorld/HexTile.h | 50 ------------ src/game/hexWorld/Map.cpp | 21 ++--- src/game/hexWorld/Map.h | 13 +-- src/game/hexWorld/MapGenerator.cpp | 57 +++++++++++++ src/game/hexWorld/MapGenerator.h | 47 +++-------- src/game/hexWorld/RessourceType.h | 8 ++ .../ecs/components/MapEntityComponent.h | 14 ++++ .../ecs/components/TileGameplayComponent.cpp | 5 ++ .../ecs/components/TileGameplayComponent.h | 29 +++++++ .../ecs/systems/TileHighlightSystem.cpp | 42 ++++++++++ .../ecs/systems/TileHighlightSystem.h | 20 +++++ .../tileGenerator/ForestTileGenerator.cpp | 32 +++++--- .../tileGenerator/ForestTileGenerator.h | 2 +- .../tileGenerator/HexTileGeneratorStrategy.h | 3 +- 42 files changed, 557 insertions(+), 216 deletions(-) create mode 100644 src/engine/core/ECS/Component.cpp create mode 100644 src/engine/core/ECS/Component.h create mode 100644 src/engine/core/ECS/EntityManager.cpp create mode 100644 src/engine/core/ECS/EntityManager.h create mode 100644 src/engine/core/ECS/ModelComponent.cpp create mode 100644 src/engine/core/ECS/ModelComponent.h create mode 100644 src/engine/core/ECS/RenderSystem.cpp create mode 100644 src/engine/core/ECS/RenderSystem.h create mode 100644 src/engine/core/ECS/TileRenderComponent.cpp create mode 100644 src/engine/core/ECS/TileRenderComponent.h create mode 100644 src/engine/core/ECS/TransformComponent.cpp create mode 100644 src/engine/core/ECS/TransformComponent.h create mode 100644 src/engine/renderer/components/TerrainRenderingData.h delete mode 100644 src/game/TileInteractionSystem.cpp delete mode 100644 src/game/TileInteractionSystem.h delete mode 100644 src/game/hexWorld/HexTile.h create mode 100644 src/game/hexWorld/RessourceType.h create mode 100644 src/game/hexWorld/ecs/components/MapEntityComponent.h create mode 100644 src/game/hexWorld/ecs/components/TileGameplayComponent.cpp create mode 100644 src/game/hexWorld/ecs/components/TileGameplayComponent.h create mode 100644 src/game/hexWorld/ecs/systems/TileHighlightSystem.cpp create mode 100644 src/game/hexWorld/ecs/systems/TileHighlightSystem.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f9aa75..5b934ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,6 @@ add_executable(Dicewars_Siedler src/main.cpp src/engine/layer/entities/Light.h src/engine/platform/glfw/MousePicker.cpp src/engine/platform/glfw/MousePicker.h - src/game/hexWorld/HexTile.h src/game/hexWorld/Map.cpp src/game/hexWorld/Map.h src/game/hexWorld/MapGenerator.cpp @@ -79,8 +78,25 @@ add_executable(Dicewars_Siedler src/main.cpp src/game/hexWorld/tileGenerator/ForestTileGenerator.h src/engine/toolbox/Random.cpp src/engine/toolbox/Random.h - src/game/TileInteractionSystem.cpp - src/game/TileInteractionSystem.h + src/engine/core/ECS/Component.cpp + src/engine/core/ECS/Component.h + src/engine/core/ECS/TransformComponent.cpp + src/engine/core/ECS/TransformComponent.h + src/engine/core/ECS/ModelComponent.cpp + src/engine/core/ECS/ModelComponent.h + src/engine/core/ECS/EntityManager.cpp + src/engine/core/ECS/EntityManager.h + src/engine/core/ECS/RenderSystem.cpp + src/engine/core/ECS/RenderSystem.h + src/engine/core/ECS/TileRenderComponent.cpp + src/engine/core/ECS/TileRenderComponent.h + src/game/hexWorld/ecs/components/TileGameplayComponent.cpp + src/game/hexWorld/ecs/components/TileGameplayComponent.h + src/game/hexWorld/ecs/components/MapEntityComponent.h + src/engine/renderer/components/TerrainRenderingData.h + src/game/hexWorld/RessourceType.h + src/game/hexWorld/ecs/systems/TileHighlightSystem.cpp + src/game/hexWorld/ecs/systems/TileHighlightSystem.h ) target_include_directories(Dicewars_Siedler PRIVATE diff --git a/src/engine/core/ECS/Component.cpp b/src/engine/core/ECS/Component.cpp new file mode 100644 index 0000000..004ac42 --- /dev/null +++ b/src/engine/core/ECS/Component.cpp @@ -0,0 +1,5 @@ +// +// Created by sebastian on 08.02.26. +// + +#include "Component.h" diff --git a/src/engine/core/ECS/Component.h b/src/engine/core/ECS/Component.h new file mode 100644 index 0000000..c510fe2 --- /dev/null +++ b/src/engine/core/ECS/Component.h @@ -0,0 +1,16 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef COMPONENT_H +#define COMPONENT_H +#include "glm/vec3.hpp" + + +class Component { +public: + virtual ~Component() = default; +}; + + +#endif //COMPONENT_H diff --git a/src/engine/core/ECS/EntityManager.cpp b/src/engine/core/ECS/EntityManager.cpp new file mode 100644 index 0000000..bad73ca --- /dev/null +++ b/src/engine/core/ECS/EntityManager.cpp @@ -0,0 +1,17 @@ +// +// Created by sebastian on 08.02.26. +// + +#include "EntityManager.h" +#include +EntityID EntityManager::createEntity() { + const EntityID id = nextID++; + entities.push_back(id); + return id; +} + +void EntityManager::destroyEntity(EntityID entity) { + entities.erase(std::remove(entities.begin(), entities.end(), entity), entities.end()); + transforms.erase(entity); + models.erase(entity); +} diff --git a/src/engine/core/ECS/EntityManager.h b/src/engine/core/ECS/EntityManager.h new file mode 100644 index 0000000..d1e4b3f --- /dev/null +++ b/src/engine/core/ECS/EntityManager.h @@ -0,0 +1,80 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef ENTITYMANAGER_H +#define ENTITYMANAGER_H +#include +#include +#include +#include + +// Forward Declarations (KEINE includes hier!) +class TransformComponent; +class ModelComponent; +class TileRenderComponent; +class TileGameplayComponent; +class MapEntityComponent; + +using EntityID = std::uint32_t; + +class EntityManager { +private: + EntityID nextID = 1; + std::vector entities; + + std::unordered_map> transforms; + std::unordered_map> models; + std::unordered_map> tileRenderComponents; + std::unordered_map> tileGameplayComponents; + std::unordered_map> mapEntityComponents; + +public: + EntityID createEntity(); + void destroyEntity(EntityID entity); + + template + void addComponent(EntityID entity, std::shared_ptr component) { + if constexpr (std::is_same_v) { + transforms[entity] = component; + } else if constexpr (std::is_same_v) { + models[entity] = component; + } else if constexpr (std::is_same_v) { + tileRenderComponents[entity] = component; + } else if constexpr (std::is_same_v) { + tileGameplayComponents[entity] = component; + } else if constexpr (std::is_same_v) { + mapEntityComponents[entity] = component; + } else { + static_assert(sizeof(T) == 0, "Component-Typ nicht unterstützt"); + } + } + + template + std::shared_ptr getComponent(EntityID entity) { + if constexpr (std::is_same_v) { + auto it = transforms.find(entity); + return (it != transforms.end()) ? it->second : nullptr; + } else if constexpr (std::is_same_v) { + auto it = models.find(entity); + return (it != models.end()) ? it->second : nullptr; + } else if constexpr (std::is_same_v) { + auto it = tileRenderComponents.find(entity); + return (it != tileRenderComponents.end()) ? it->second : nullptr; + } else if constexpr (std::is_same_v) { + auto it = tileGameplayComponents.find(entity); + return (it != tileGameplayComponents.end()) ? it->second : nullptr; + } else if constexpr (std::is_same_v) { + auto it = mapEntityComponents.find(entity); + return (it != mapEntityComponents.end()) ? it->second : nullptr; + } else { + static_assert(sizeof(T) == 0, "Component-Typ nicht unterstützt"); + } + } + + const std::vector& getAllEntities() const { return entities; } +}; + + + +#endif //ENTITYMANAGER_H diff --git a/src/engine/core/ECS/ModelComponent.cpp b/src/engine/core/ECS/ModelComponent.cpp new file mode 100644 index 0000000..5aebf03 --- /dev/null +++ b/src/engine/core/ECS/ModelComponent.cpp @@ -0,0 +1,5 @@ +// +// Created by sebastian on 08.02.26. +// + +#include "ModelComponent.h" diff --git a/src/engine/core/ECS/ModelComponent.h b/src/engine/core/ECS/ModelComponent.h new file mode 100644 index 0000000..fecb51b --- /dev/null +++ b/src/engine/core/ECS/ModelComponent.h @@ -0,0 +1,21 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef MODELCOMPONENT_H +#define MODELCOMPONENT_H +#include + +#include "Component.h" +#include "../../renderer/model/TexturedModel.h" + + +class ModelComponent: public Component { +public: + std::shared_ptr model; + ModelComponent(std::shared_ptr model) : model(std::move(model)) {}; +}; + + + +#endif //MODELCOMPONENT_H diff --git a/src/engine/core/ECS/RenderSystem.cpp b/src/engine/core/ECS/RenderSystem.cpp new file mode 100644 index 0000000..1815648 --- /dev/null +++ b/src/engine/core/ECS/RenderSystem.cpp @@ -0,0 +1,24 @@ +// +// Created by sebastian on 08.02.26. +// + +#include "RenderSystem.h" + +void RenderSystem::render(EntityManager &entityManager, MasterRenderer &renderer) { + for (auto id : entityManager.getAllEntities()) { + + auto transform = entityManager.getComponent(id); + auto model = entityManager.getComponent(id); + auto tileRenderingComponent = entityManager.getComponent(id); + + if (!transform || !model) continue; + + if (tileRenderingComponent) { + renderer.submitTerrainTile(transform, model, tileRenderingComponent); + } else { + Entity entity = Entity(model->model, transform->position, transform->rotation.x, transform->rotation.y, transform->rotation.z, transform->scale); + renderer.submitEntity(std::make_unique(entity)); + } + + } +} diff --git a/src/engine/core/ECS/RenderSystem.h b/src/engine/core/ECS/RenderSystem.h new file mode 100644 index 0000000..e2c515f --- /dev/null +++ b/src/engine/core/ECS/RenderSystem.h @@ -0,0 +1,18 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef RENDERSYSTEM_H +#define RENDERSYSTEM_H +#include "EntityManager.h" +#include "../../renderer/MasterRenderer.h" + + +class RenderSystem { +public: + void render(EntityManager &entityManager, MasterRenderer &renderer); +}; + + + +#endif //RENDERSYSTEM_H diff --git a/src/engine/core/ECS/TileRenderComponent.cpp b/src/engine/core/ECS/TileRenderComponent.cpp new file mode 100644 index 0000000..7073dda --- /dev/null +++ b/src/engine/core/ECS/TileRenderComponent.cpp @@ -0,0 +1,5 @@ +// +// Created by sebastian on 08.02.26. +// + +#include "TileRenderComponent.h" diff --git a/src/engine/core/ECS/TileRenderComponent.h b/src/engine/core/ECS/TileRenderComponent.h new file mode 100644 index 0000000..3bed3b9 --- /dev/null +++ b/src/engine/core/ECS/TileRenderComponent.h @@ -0,0 +1,22 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef TILERENDERCOMPONENT_H +#define TILERENDERCOMPONENT_H +#include + +#include "Component.h" +#include "../../renderer/model/TexturedModel.h" + + +class TileRenderComponent : public Component{ +public: + bool isHighlighted; + explicit TileRenderComponent(bool isHighlighted) : isHighlighted(isHighlighted) {}; + +}; + + + +#endif //TILERENDERCOMPONENT_H diff --git a/src/engine/core/ECS/TransformComponent.cpp b/src/engine/core/ECS/TransformComponent.cpp new file mode 100644 index 0000000..a8e5542 --- /dev/null +++ b/src/engine/core/ECS/TransformComponent.cpp @@ -0,0 +1,5 @@ +// +// Created by sebastian on 08.02.26. +// + +#include "TransformComponent.h" diff --git a/src/engine/core/ECS/TransformComponent.h b/src/engine/core/ECS/TransformComponent.h new file mode 100644 index 0000000..9bffa5b --- /dev/null +++ b/src/engine/core/ECS/TransformComponent.h @@ -0,0 +1,20 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef TRANSFORMCOMPONENT_H +#define TRANSFORMCOMPONENT_H +#include "Component.h" + + +class TransformComponent : public Component { +public: + TransformComponent(glm::vec3 position, glm::vec3 rotation, float scale) : position(position), rotation(rotation), scale(scale) {}; + glm::vec3 position; + glm::vec3 rotation; + float scale; +}; + + + +#endif //TRANSFORMCOMPONENT_H diff --git a/src/engine/layer/entities/Entity.h b/src/engine/layer/entities/Entity.h index 53468ce..c1106b4 100644 --- a/src/engine/layer/entities/Entity.h +++ b/src/engine/layer/entities/Entity.h @@ -9,7 +9,6 @@ #include "../../renderer/model/TexturedModel.h" #include "glm/vec3.hpp" - class Entity { private: std::shared_ptr model; diff --git a/src/engine/renderer/MasterRenderer.cpp b/src/engine/renderer/MasterRenderer.cpp index bbb98ea..d271a15 100644 --- a/src/engine/renderer/MasterRenderer.cpp +++ b/src/engine/renderer/MasterRenderer.cpp @@ -4,6 +4,8 @@ #include "MasterRenderer.h" +#include + #include "../core/Application.h" #include "glm/ext/matrix_clip_space.hpp" @@ -24,13 +26,14 @@ void MasterRenderer::render(const Light &light, const Camera &camera) { } -void MasterRenderer::submitEntity(Entity *entity) { +void MasterRenderer::submitEntity(std::unique_ptr entity) { TexturedModel* entityModel = entity->getModel().get(); - entities[entityModel].push_back(entity); + entities[entityModel].push_back(std::move(entity)); } -void MasterRenderer::submitTerrainTile(HexRenderData *tile) { - terrainTiles[tile->model.get()].push_back(tile); +void MasterRenderer::submitTerrainTile(std::shared_ptr transform, std::shared_ptr model, std::shared_ptr terrainTileComponent) { + TerrainRenderingData terrain = TerrainRenderingData(std::move(transform), std::move(model), std::move(terrainTileComponent)); + terrainTiles[terrain.modelComponent->model.get()].push_back(std::make_unique(std::move(terrain))); } diff --git a/src/engine/renderer/MasterRenderer.h b/src/engine/renderer/MasterRenderer.h index 848cf5f..ee1890f 100644 --- a/src/engine/renderer/MasterRenderer.h +++ b/src/engine/renderer/MasterRenderer.h @@ -9,7 +9,6 @@ #include "Renderer.h" #include "TerrainRenderer.h" -#include "../../game/hexWorld/HexTile.h" #include "../layer/entities/Entity.h" #include "model/TexturedModel.h" @@ -19,8 +18,8 @@ class Light; class MasterRenderer { private: - std::unordered_map> entities; - std::unordered_map> terrainTiles; + std::unordered_map>> entities; + std::unordered_map>> terrainTiles; glm::mat4 projectionMatrix; std::unique_ptr entityRenderer; std::unique_ptr terrainRenderer; @@ -39,8 +38,8 @@ public: }; void render(const Light &light, const Camera &camera); - void submitEntity(Entity* entity); - void submitTerrainTile(HexRenderData* tile); + void submitEntity(std::unique_ptr entity); + void submitTerrainTile(std::shared_ptr transform, std::shared_ptr model, std::shared_ptr); [[nodiscard]] glm::mat4 getProjectionMatrix() const {return projectionMatrix;} }; diff --git a/src/engine/renderer/Renderer.cpp b/src/engine/renderer/Renderer.cpp index 48e489f..c8ae19e 100644 --- a/src/engine/renderer/Renderer.cpp +++ b/src/engine/renderer/Renderer.cpp @@ -6,7 +6,6 @@ #include -#include "../../game/hexWorld/HexTile.h" #include "../core/Application.h" #include "../layer/entities/Light.h" #include "../toolbox/MathUtils.h" @@ -24,7 +23,8 @@ void Renderer::prepare(const Camera& camera, const Light& light) { } -void Renderer::renderEntities(const std::unordered_map>& entities) { +void Renderer::renderEntities(const std::unordered_map>>& entities) { + for (const auto& [texturedModel, batch] : entities) { prepareTexturedModel(*texturedModel); for (const auto& entity : batch) { diff --git a/src/engine/renderer/Renderer.h b/src/engine/renderer/Renderer.h index c8579d9..4377fe3 100644 --- a/src/engine/renderer/Renderer.h +++ b/src/engine/renderer/Renderer.h @@ -4,7 +4,6 @@ #ifndef DICEWARS_SIEDLER_RENDERER_H #define DICEWARS_SIEDLER_RENDERER_H -#include "../../game/hexWorld/HexTile.h" #include "../layer/entities/Entity.h" #include "model/RawModel.h" #include "model/TexturedModel.h" @@ -24,7 +23,7 @@ public: }; void prepare(const ::Camera &camera, const Light& light); - void renderEntities(const std::unordered_map> &entities); + void renderEntities(const std::unordered_map>> &entities); void finalizeFrame(); private: StaticShader staticShader; diff --git a/src/engine/renderer/TerrainRenderer.cpp b/src/engine/renderer/TerrainRenderer.cpp index a477b7d..dfb1cb4 100644 --- a/src/engine/renderer/TerrainRenderer.cpp +++ b/src/engine/renderer/TerrainRenderer.cpp @@ -13,7 +13,7 @@ void TerrainRenderer::prepare(const Camera &camera, const Light &light) { terrainShader.loadViewMatrix(viewMatrix); } -void TerrainRenderer::renderTerrainTiles(const std::unordered_map> &terrainTiles) { +void TerrainRenderer::renderTerrainTiles(const std::unordered_map>> &terrainTiles) { for (const auto& [texturedModel, batch] : terrainTiles) { prepareTexturedModel(*texturedModel); for (const auto& hexTile : batch) { @@ -47,9 +47,9 @@ void TerrainRenderer::unbindTexturedModel() { glBindVertexArray(0); } -void TerrainRenderer::prepareInstance(const HexRenderData &hexTile) { - glm::mat4 transformationMatrix = MathUtils::createTransformationMatrix(hexTile.position, 0,0,0,1); +void TerrainRenderer::prepareInstance(const TerrainRenderingData &hexTile) { + glm::mat4 transformationMatrix = MathUtils::createTransformationMatrix(hexTile.transform->position, 0,0,0,1); terrainShader.loadTransformationMatrix(transformationMatrix); - terrainShader.loadIsHighlighted(hexTile.highlight); + terrainShader.loadIsHighlighted(hexTile.terrainRenderComponent->isHighlighted); } diff --git a/src/engine/renderer/TerrainRenderer.h b/src/engine/renderer/TerrainRenderer.h index c4e865b..85f44f3 100644 --- a/src/engine/renderer/TerrainRenderer.h +++ b/src/engine/renderer/TerrainRenderer.h @@ -4,12 +4,13 @@ #ifndef TERRAINRENDERER_H #define TERRAINRENDERER_H -#include "../../game/hexWorld/HexTile.h" + #include "model/TexturedModel.h" #include "shaders/StaticShader.h" #include "../layer/entities/Camera.h" #include "../layer/entities/Light.h" +#include "components/TerrainRenderingData.h" #include "shaders/TerrainShader.h" @@ -22,14 +23,14 @@ public: } void prepare(const Camera &camera, const Light &light); - void renderTerrainTiles(const std::unordered_map>& terrainTiles); + void renderTerrainTiles(const std::unordered_map>>& terrainTiles); void finalizeFrame(); private: TerrainShader terrainShader; void prepareTexturedModel(const TexturedModel &texturedModel); void unbindTexturedModel(); - void prepareInstance(const HexRenderData& hexTile); + void prepareInstance(const TerrainRenderingData& hexTile); }; diff --git a/src/engine/renderer/components/TerrainRenderingData.h b/src/engine/renderer/components/TerrainRenderingData.h new file mode 100644 index 0000000..bae6fd1 --- /dev/null +++ b/src/engine/renderer/components/TerrainRenderingData.h @@ -0,0 +1,20 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef TERRAINRENDERINGDATA_H +#define TERRAINRENDERINGDATA_H +#include "../../core/ECS/ModelComponent.h" +#include "../../core/ECS/TileRenderComponent.h" +#include "../../core/ECS/TransformComponent.h" + + +struct TerrainRenderingData { + std::shared_ptr transform; + std::shared_ptr modelComponent; + std::shared_ptr terrainRenderComponent; +}; + + + +#endif //TERRAINRENDERINGDATA_H diff --git a/src/engine/renderer/model/AssetManager.cpp b/src/engine/renderer/model/AssetManager.cpp index 37e442f..1a4dbb2 100644 --- a/src/engine/renderer/model/AssetManager.cpp +++ b/src/engine/renderer/model/AssetManager.cpp @@ -5,6 +5,7 @@ #include "AssetManager.h" #include +#include #include "../loader/OBJLoader.h" @@ -23,3 +24,8 @@ std::shared_ptr AssetManager::getModel(const std::string &name) { assert(models.contains(name) && "Model not found!"); return models.at(name); } + +void AssetManager::insertGeneratedModel(const std::string &name, std::shared_ptr model) { + assert(!models.contains(name) && "Model already exists!"); + models[name] = std::move(model); +} diff --git a/src/engine/renderer/model/AssetManager.h b/src/engine/renderer/model/AssetManager.h index 171749c..842df14 100644 --- a/src/engine/renderer/model/AssetManager.h +++ b/src/engine/renderer/model/AssetManager.h @@ -15,6 +15,7 @@ class AssetManager { public: static std::shared_ptr loadModel(const std::string& name, const std::string& objPath, const std::string& texturePath, Loader& loader); static std::shared_ptr getModel(const std::string& name); + static void insertGeneratedModel(const std::string& name, std::shared_ptr model); private: static inline std::unordered_map> models; }; diff --git a/src/game/GameLayer.cpp b/src/game/GameLayer.cpp index c5296da..7f1b35c 100644 --- a/src/game/GameLayer.cpp +++ b/src/game/GameLayer.cpp @@ -38,10 +38,22 @@ void GameLayer::onAttach() //treeModel = std::make_unique(*OBJLoader::loadModel("assets/trees/lowPolyTree.obj", "assets/trees/lowPolyTree.png", loader)); //treeEntity = std::make_unique(Entity(treeModel, glm::vec3(0,0,0), 0,0,0, 0.5f)); - MapGenerator::generateHexMap(*map, 10,10,10.f, mapEntities); - printf("Generated Terrain with %lu Tiles!\n", map->tiles.size()); + MapGenerator::init(loader, 10.f); + MapGenerator::generateHexMap(*map, 10,10, *entityManager); + //printf("Generated Terrain with %lu Tiles!\n", map->tiles.size()); + + for (const auto& entity : mapEntities) { + EntityID entityID = entityManager->createEntity(); + glm::vec3 pos = entity->getPosition(); + glm::vec3 rot = glm::vec3(entity->getRotX(), entity->getRotY(), entity->getRotZ()); + float scale = entity->getScale(); + entityManager->addComponent(entityID, std::make_shared(pos, rot, scale)); + entityManager->addComponent(entityID, std::make_shared(entity->getModel())); + } + auto cabinModel = AssetManager::loadModel("cabin", "assets/cabin/cabin.obj", "assets/cabin/cabin.jpg", loader); + //entities.push_back(std::make_shared(Entity(cabinModel, glm::vec3(0,0,0), 0,0,0, 1.f))); } @@ -62,26 +74,8 @@ void GameLayer::onUpdate() camera->move(moveDir, 0.5f); - - for (const auto& entity : entities) { - renderer->submitEntity(entity.get()); - } - - tileInteractionSystem->update(*map, *camera, *mousePicker); - tileInteractionSystem->handleBuildAction(*map); - - - std::vector terrainRenderData = map->getTerrainRenderData(hexModelDefault, hexModelWood, hexModelStone); - for (auto& renderData : terrainRenderData) { - renderer->submitTerrainTile(&renderData); - } - - for (HexTile& tile : map->tiles) { - for (const auto& entity : tile.entitiesOnTile) { - renderer->submitEntity(entity.get()); - } - if (tile.building) renderer->submitEntity(tile.building.get()); - } + tileHighlightSystem->update(*entityManager, *mousePicker, *camera); + renderSystem->render(*entityManager, *renderer); renderer->render(*light, *camera); } diff --git a/src/game/GameLayer.h b/src/game/GameLayer.h index a68544c..1dd9cbf 100644 --- a/src/game/GameLayer.h +++ b/src/game/GameLayer.h @@ -4,7 +4,7 @@ #ifndef DICEWARS_SIEDLER_GAMELAYER_H #define DICEWARS_SIEDLER_GAMELAYER_H -#include "TileInteractionSystem.h" +#include "../engine/core/ECS/RenderSystem.h" #include "../engine/layer/Layer.h" #include "../engine/platform/glfw/MousePicker.h" #include "../engine/renderer/Renderer.h" @@ -13,6 +13,7 @@ #include "../engine/layer/entities/Camera.h" #include "../engine/renderer/MasterRenderer.h" #include "hexWorld/Map.h" +#include "hexWorld/ecs/systems/TileHighlightSystem.h" class GameLayer: public Layer { @@ -38,7 +39,11 @@ private: std::vector> mapEntities; std::vector> entities; - std::unique_ptr tileInteractionSystem = std::make_unique(); + + std::unique_ptr renderSystem = std::make_unique(); + std::unique_ptr tileHighlightSystem = std::make_unique(); + std::unique_ptr entityManager = std::make_unique(); + std::unique_ptr map; }; diff --git a/src/game/TileInteractionSystem.cpp b/src/game/TileInteractionSystem.cpp deleted file mode 100644 index a8f211c..0000000 --- a/src/game/TileInteractionSystem.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Created by sebastian on 08.02.26. -// - -#include "TileInteractionSystem.h" - -#include "../engine/layer/entities/Camera.h" -#include "../engine/platform/glfw/InputManager.h" -#include "../engine/renderer/model/AssetManager.h" -#include "GLFW/glfw3.h" - -void TileInteractionSystem::update(Map &map, const Camera &camera, const MousePicker &mousePicker) { - for (HexTile& tile : map.tiles) { - glm::vec3 intersectionPoint; - tile.isHighlighted = tile.intersect(camera.getPosition(), mousePicker.getCurrentRay(), intersectionPoint); - } - - -} - -void TileInteractionSystem::handleBuildAction(Map &map) { - for (HexTile& tile : map.tiles) { - if (tile.isHighlighted && InputManager::isMouseButtonPressed(GLFW_MOUSE_BUTTON_1)) { - if (!tile.building && tile.resourceType == RessourceType::WOOD) { - tile.entitiesOnTile.clear(); - tile.building = std::make_shared(AssetManager::getModel("cabin"), tile.worldPos, 0,0,0,1.f); - } - } - } -} diff --git a/src/game/TileInteractionSystem.h b/src/game/TileInteractionSystem.h deleted file mode 100644 index b12af5d..0000000 --- a/src/game/TileInteractionSystem.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Created by sebastian on 08.02.26. -// - -#ifndef TILEINTERACTIONSYSTEM_H -#define TILEINTERACTIONSYSTEM_H -#include "../engine/platform/glfw/MousePicker.h" -#include "hexWorld/Map.h" - - -class TileInteractionSystem { -public: - void update(Map& map, const Camera& camera, const MousePicker& mousePicker); - void handleBuildAction(Map& map); -}; - - - -#endif //TILEINTERACTIONSYSTEM_H diff --git a/src/game/hexWorld/HexModelFactory.h b/src/game/hexWorld/HexModelFactory.h index 7592339..42eb1fa 100644 --- a/src/game/hexWorld/HexModelFactory.h +++ b/src/game/hexWorld/HexModelFactory.h @@ -4,7 +4,9 @@ #ifndef HEXMODELFACTORY_H #define HEXMODELFACTORY_H -#include "HexTile.h" + + +#include "RessourceType.h" #include "../../engine/renderer/model/RawModel.h" #include "../../engine/renderer/model/TexturedModel.h" diff --git a/src/game/hexWorld/HexTile.h b/src/game/hexWorld/HexTile.h deleted file mode 100644 index 64739c7..0000000 --- a/src/game/hexWorld/HexTile.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// Created by sebastian on 07.02.26. -// - -#ifndef HEXTILE_H -#define HEXTILE_H -#include - -#include "../../engine/layer/entities/Entity.h" -#include "../../engine/renderer/model/TexturedModel.h" -#include "glm/vec2.hpp" -#include "glm/vec3.hpp" -#include "glm/ext/quaternion_geometric.hpp" - -enum class RessourceType { - NONE, - WOOD, - STONE -}; - -struct HexTile { - glm::vec3 worldPos; - int q, r; //Axiale Koordinaten (hex-Koordinaten) - int ownerID = -1; - RessourceType resourceType = RessourceType::NONE; - float radius; - bool isHighlighted = false; - - std::vector> entitiesOnTile; - std::shared_ptr building; - - - bool intersect(const glm::vec3& rayOrigin, const glm::vec3& rayDirection, glm::vec3& intersectionPoint) const { - float t = -rayOrigin.y / rayDirection.y; - if (t < 0) return false; // Ray zeigt nach oben, nicht getroffen - - intersectionPoint = rayOrigin + t * rayDirection; - - glm::vec2 diff(intersectionPoint.x - worldPos.x, intersectionPoint.z - worldPos.z); - return glm::length(diff) <= radius -0.1f; - } -}; - -struct HexRenderData { - std::shared_ptr model; - glm::vec3 position; - bool highlight = false; -}; - -#endif //HEXTILE_H diff --git a/src/game/hexWorld/Map.cpp b/src/game/hexWorld/Map.cpp index fb2b153..751cb20 100644 --- a/src/game/hexWorld/Map.cpp +++ b/src/game/hexWorld/Map.cpp @@ -4,20 +4,13 @@ #include "Map.h" -std::vector Map::getTerrainRenderData(const std::shared_ptr& hexModel, - const std::shared_ptr& woodModel, const std::shared_ptr& stoneModel) { - std::vector renderData; - renderData.reserve(tiles.size()); - for (auto& tile : tiles) { - HexRenderData data; - if (tile.resourceType == RessourceType::WOOD) { - data = HexRenderData(woodModel, tile.worldPos, tile.isHighlighted); - } else if (tile.resourceType == RessourceType::NONE) { - data = HexRenderData(hexModel, tile.worldPos, tile.isHighlighted); - } else if (tile.resourceType == RessourceType::STONE) { - data =HexRenderData(stoneModel, tile.worldPos, tile.isHighlighted); +#include "ecs/components/MapEntityComponent.h" +#include "ecs/components/TileGameplayComponent.h" + +void Map::clear(EntityManager &entityManager) { + for (EntityID id: entityManager.getAllEntities()) { + if (entityManager.getComponent(id)) { + entityManager.destroyEntity(id); } - renderData.push_back(data); } - return renderData; } diff --git a/src/game/hexWorld/Map.h b/src/game/hexWorld/Map.h index b6d02b2..7c527cb 100644 --- a/src/game/hexWorld/Map.h +++ b/src/game/hexWorld/Map.h @@ -4,20 +4,21 @@ #ifndef MAP_H #define MAP_H -#include "HexTile.h" +#include "../../engine/core/ECS/EntityManager.h" struct Area { int id; - std::vector tiles; + std::vector tiles; }; class Map { public: - std::vector areas; - std::vector tiles; + int width; + int height; - std::vector getTerrainRenderData(const std::shared_ptr &hexModel, const std::shared_ptr &woodModel, const std::shared_ptr< - TexturedModel> &stoneModel); + std::vector areas; + + void clear(EntityManager& entityManager); }; diff --git a/src/game/hexWorld/MapGenerator.cpp b/src/game/hexWorld/MapGenerator.cpp index 4d47824..c3da366 100644 --- a/src/game/hexWorld/MapGenerator.cpp +++ b/src/game/hexWorld/MapGenerator.cpp @@ -3,3 +3,60 @@ // #include "MapGenerator.h" + +float MapGenerator::hexRadius = 10.0f; + +void MapGenerator::init(Loader &loader, float hexRadius) { + MapGenerator::hexRadius = hexRadius; + auto hexModelNone = HexModelFactory::createTexturedHexModel(loader, hexRadius, RessourceType::NONE); + auto hexModelWood = HexModelFactory::createTexturedHexModel(loader, hexRadius, RessourceType::WOOD); + auto hexModelStone = HexModelFactory::createTexturedHexModel(loader, hexRadius, RessourceType::STONE); + + AssetManager::insertGeneratedModel("hexModelNone", std::make_shared(hexModelNone)); + AssetManager::insertGeneratedModel("hexModelWood", std::make_shared(hexModelWood)); + AssetManager::insertGeneratedModel("hexModelStone", std::make_shared(hexModelStone)); +} + +void MapGenerator::generateHexMap(Map &map, int width, int height, EntityManager &entityManager) { + Random random; + + map.clear(entityManager); + + float xOffset = hexRadius * std::sqrt(3.0f); + float zOffset = hexRadius * 1.5f; + + for (int r = 0; r < height; ++r) { + for (int q = 0; q < width; ++q) { + // Pointy-top Hexes + float x = xOffset * (q + 0.5f * (r % 2)); + float z = zOffset * r; + glm::vec3 worldPos = glm::vec3(x, 0.0f, z); + float radius = hexRadius; + + float randomValue = random.randomFloat(0.0f, 1.0f); + RessourceType resourceType = RessourceType::NONE; + std::shared_ptr hexModel = AssetManager::getModel("hexModelNone"); + if (randomValue < 0.5f) { + resourceType = RessourceType::WOOD; + ForestTileGenerator forestTileGenerator; + std::vector entities = forestTileGenerator.generateHexTile(entityManager, random, worldPos); + hexModel = AssetManager::getModel("hexModelWood"); + } else if (randomValue < 0.75f) { + resourceType = RessourceType::STONE; + hexModel = AssetManager::getModel("hexModelStone"); + } + + EntityID entityID = entityManager.createEntity(); + const auto transformComponent = std::make_shared(worldPos, glm::vec3(0), 1.0f); + const auto modelComponent = std::make_shared(hexModel); + const auto tileHighlightComponent = std::make_shared(false); + const auto tileGameplayComponent = std::make_shared(q, r, radius, resourceType); + + entityManager.addComponent(entityID, transformComponent); + entityManager.addComponent(entityID, modelComponent); + entityManager.addComponent(entityID, tileHighlightComponent); + entityManager.addComponent(entityID, tileGameplayComponent); + entityManager.addComponent(entityID, std::make_shared()); + } + } +} diff --git a/src/game/hexWorld/MapGenerator.h b/src/game/hexWorld/MapGenerator.h index 5226947..31ee217 100644 --- a/src/game/hexWorld/MapGenerator.h +++ b/src/game/hexWorld/MapGenerator.h @@ -7,48 +7,25 @@ #include #include -#include "HexTile.h" +#include "HexModelFactory.h" #include "Map.h" +#include "../../engine/core/ECS/ModelComponent.h" +#include "../../engine/core/ECS/TileRenderComponent.h" +#include "../../engine/core/ECS/TransformComponent.h" #include "../../engine/renderer/model/AssetManager.h" #include "../../engine/toolbox/Random.h" +#include "ecs/components/MapEntityComponent.h" +#include "ecs/components/TileGameplayComponent.h" #include "tileGenerator/ForestTileGenerator.h" + + class MapGenerator { +private: + static float hexRadius; public: - static void generateHexMap(Map& map, int width, int height, float hexRadius, std::vector>& mapEntities) { - // Zufallsgenerator initialisieren (einmal) - Random random; - - map.tiles.clear(); - - float xOffset = hexRadius * std::sqrt(3.0f); - float zOffset = hexRadius * 1.5f; - - for (int r = 0; r < height; ++r) { - for (int q = 0; q < width; ++q) { - HexTile tile; - tile.q = q; - tile.r = r; - - // Pointy-top Hexes - float x = xOffset * (q + 0.5f * (r % 2)); - float z = zOffset * r; - tile.worldPos = glm::vec3(x, 0.0f, z); - tile.radius = hexRadius; - - float randomValue = random.randomFloat(0.0f, 1.0f); - if (randomValue < 0.5f) { - tile.resourceType = RessourceType::WOOD; - ForestTileGenerator forestTileGenerator; - const std::vector> forestEntities = forestTileGenerator.generateHexTile(random, tile.worldPos, mapEntities); - tile.entitiesOnTile = forestEntities; - } else if (randomValue < 0.75f) { - tile.resourceType = RessourceType::STONE; - } - map.tiles.push_back(tile); - } - } - } + static void init(Loader& loader, float hexRadius); + static void generateHexMap(Map& map, int width, int height, EntityManager& entityManager); private: diff --git a/src/game/hexWorld/RessourceType.h b/src/game/hexWorld/RessourceType.h new file mode 100644 index 0000000..f140a14 --- /dev/null +++ b/src/game/hexWorld/RessourceType.h @@ -0,0 +1,8 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef RESSOURCETYPE_H +#define RESSOURCETYPE_H +enum class RessourceType {NONE, WOOD, STONE}; +#endif //RESSOURCETYPE_H diff --git a/src/game/hexWorld/ecs/components/MapEntityComponent.h b/src/game/hexWorld/ecs/components/MapEntityComponent.h new file mode 100644 index 0000000..f327df0 --- /dev/null +++ b/src/game/hexWorld/ecs/components/MapEntityComponent.h @@ -0,0 +1,14 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef MAPENTITYCOMPONENT_H +#define MAPENTITYCOMPONENT_H + + + +struct MapEntityComponent {}; + + + +#endif //MAPENTITYCOMPONENT_H diff --git a/src/game/hexWorld/ecs/components/TileGameplayComponent.cpp b/src/game/hexWorld/ecs/components/TileGameplayComponent.cpp new file mode 100644 index 0000000..e325573 --- /dev/null +++ b/src/game/hexWorld/ecs/components/TileGameplayComponent.cpp @@ -0,0 +1,5 @@ +// +// Created by sebastian on 08.02.26. +// + +#include "TileGameplayComponent.h" diff --git a/src/game/hexWorld/ecs/components/TileGameplayComponent.h b/src/game/hexWorld/ecs/components/TileGameplayComponent.h new file mode 100644 index 0000000..0bb081a --- /dev/null +++ b/src/game/hexWorld/ecs/components/TileGameplayComponent.h @@ -0,0 +1,29 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef TILEGAMEPLAYCOMPONENT_H +#define TILEGAMEPLAYCOMPONENT_H + +#include "../../../../engine/core/ECS/Component.h" +#include "../../../../engine/core/ECS/EntityManager.h" + + +enum class RessourceType; + +class TileGameplayComponent : public Component { +public: + int q, r; + float radius; + RessourceType ressourceType; + + EntityID buildingEntityID = 0; + std::vector entitiesOnTile; + + TileGameplayComponent(int q, int r, float radius, RessourceType ressourceType) : q(q), r(r), radius(radius), ressourceType(ressourceType) {}; + +}; + + + +#endif //TILEGAMEPLAYCOMPONENT_H diff --git a/src/game/hexWorld/ecs/systems/TileHighlightSystem.cpp b/src/game/hexWorld/ecs/systems/TileHighlightSystem.cpp new file mode 100644 index 0000000..0049edc --- /dev/null +++ b/src/game/hexWorld/ecs/systems/TileHighlightSystem.cpp @@ -0,0 +1,42 @@ +// +// Created by sebastian on 08.02.26. +// + +#include "TileHighlightSystem.h" + +#include "../../../../engine/core/ECS/TileRenderComponent.h" +#include "../../../../engine/core/ECS/TransformComponent.h" +#include "../components/TileGameplayComponent.h" +#include "../../../../engine/layer/entities/Camera.h" + + +void TileHighlightSystem::update(EntityManager &entityManager, const MousePicker& picker, const Camera& camera) { + for (EntityID entityID : entityManager.getAllEntities()) { + auto tileRenderComponent = entityManager.getComponent(entityID); + auto transformComponent = entityManager.getComponent(entityID); + auto tileGameplayComponent = entityManager.getComponent(entityID); + + if (!tileRenderComponent || !transformComponent || !tileGameplayComponent) { + continue; + } + + glm::vec3 rayOrigin = camera.getPosition(); + glm::vec3 rayDirection = picker.getCurrentRay(); + glm::vec3 intersectionPoint; + if (intersectTile(rayOrigin, rayDirection, transformComponent->position, tileGameplayComponent->radius, intersectionPoint)) { + tileRenderComponent->isHighlighted = true; + } else { + tileRenderComponent->isHighlighted = false; + } + } +} + +bool TileHighlightSystem::intersectTile(const glm::vec3 &rayOrigin, const glm::vec3 &rayDirection, glm::vec3 worldPos, float hexRadius, glm::vec3& intersectionPoint) { + float t = -rayOrigin.y / rayDirection.y; + if (t < 0) return false; + + intersectionPoint = rayOrigin + rayDirection * t; + + glm::vec2 diff(intersectionPoint.x - worldPos.x, intersectionPoint.z - worldPos.z); + return glm::length(diff) <= hexRadius - 0.1f; +} diff --git a/src/game/hexWorld/ecs/systems/TileHighlightSystem.h b/src/game/hexWorld/ecs/systems/TileHighlightSystem.h new file mode 100644 index 0000000..487b98a --- /dev/null +++ b/src/game/hexWorld/ecs/systems/TileHighlightSystem.h @@ -0,0 +1,20 @@ +// +// Created by sebastian on 08.02.26. +// + +#ifndef TILEHIGHLIGHTSYSTEM_H +#define TILEHIGHLIGHTSYSTEM_H +#include "../../../../engine/core/ECS/EntityManager.h" +#include "../../../../engine/platform/glfw/MousePicker.h" +class Camera; + +class TileHighlightSystem { +public: + void update(EntityManager &entityManager, const MousePicker &picker, const Camera &camera); +private: + bool intersectTile(const glm::vec3 & rayOrigin, const glm::vec3 & rayDirection, glm::vec3 worldPos, float hexRadius, glm::vec3 &interectionPoint); +}; + + + +#endif //TILEHIGHLIGHTSYSTEM_H diff --git a/src/game/hexWorld/tileGenerator/ForestTileGenerator.cpp b/src/game/hexWorld/tileGenerator/ForestTileGenerator.cpp index 86d85a2..f5a8fe9 100644 --- a/src/game/hexWorld/tileGenerator/ForestTileGenerator.cpp +++ b/src/game/hexWorld/tileGenerator/ForestTileGenerator.cpp @@ -4,17 +4,18 @@ #include "ForestTileGenerator.h" +#include "../../../engine/core/ECS/ModelComponent.h" +#include "../../../engine/core/ECS/TransformComponent.h" #include "../../../engine/renderer/model/AssetManager.h" #include "glm/detail/func_geometric.inl" -std::vector> ForestTileGenerator::generateHexTile(Random& random, glm::vec3 tilePos, std::vector> &mapEntities) const { +std::vector ForestTileGenerator::generateHexTile(EntityManager& em, Random& random, glm::vec3 tilePos) const { int treeCount = random.randomInt(minTreeCount, maxTreeCount); - - std::vector> entitiesOnTile; std::shared_ptr treeModel = AssetManager::getModel("lowPolyTree"); std::shared_ptr treeModel2 = AssetManager::getModel("lowPolyTree2"); std::vector> treeModels = {treeModel, treeModel2}; + std::vector entitiyIDs; for (int i = 0; i < treeCount; ++i) { glm::vec3 treePos; bool validPos = false; @@ -28,11 +29,15 @@ std::vector> ForestTileGenerator::generateHexTile(Random treePos.z += random.randomFloat(-hexRadius * 0.5f, hexRadius * 0.5f); validPos = true; - for (const auto& otherTree : entitiesOnTile) { - if (glm::distance(treePos, otherTree->getPosition()) < minDistance) { - validPos = false; - break; + for (const auto& otherTreeID : entitiyIDs) { + const auto otherTree = em.getComponent(otherTreeID); + if (otherTree) { + if (glm::distance(treePos, otherTree->position) < minDistance) { + validPos = false; + break; + } } + } attempts++; } @@ -40,9 +45,14 @@ std::vector> ForestTileGenerator::generateHexTile(Random if (!validPos) continue; // zu viele Versuche, überspringen int treeModelIndex = random.randomInt(0, static_cast(treeModels.size()-1)); - auto treeEntity = std::make_shared(treeModels[treeModelIndex], treePos, 0, 0, 0, 1.f); - mapEntities.push_back(treeEntity); - entitiesOnTile.push_back(treeEntity); + + const auto transformComponent = std::make_shared(treePos, glm::vec3(0), 1.f); + const auto modelComponent = std::make_shared(treeModels[treeModelIndex]); + + const EntityID entityID = em.createEntity(); + em.addComponent(entityID, transformComponent); + em.addComponent(entityID, modelComponent); + entitiyIDs.push_back(entityID); } - return entitiesOnTile; + return entitiyIDs; } diff --git a/src/game/hexWorld/tileGenerator/ForestTileGenerator.h b/src/game/hexWorld/tileGenerator/ForestTileGenerator.h index 618117d..045b991 100644 --- a/src/game/hexWorld/tileGenerator/ForestTileGenerator.h +++ b/src/game/hexWorld/tileGenerator/ForestTileGenerator.h @@ -9,7 +9,7 @@ class ForestTileGenerator : public HexTileGeneratorStrategy { public: - std::vector> generateHexTile(Random& random, glm::vec3 tilePos, std::vector>& mapEntities) const override; + std::vector generateHexTile(EntityManager& em, Random& random, glm::vec3 tilePos) const override; private: const int minTreeCount = 3; const int maxTreeCount = 5; diff --git a/src/game/hexWorld/tileGenerator/HexTileGeneratorStrategy.h b/src/game/hexWorld/tileGenerator/HexTileGeneratorStrategy.h index 9c7661b..53d0d50 100644 --- a/src/game/hexWorld/tileGenerator/HexTileGeneratorStrategy.h +++ b/src/game/hexWorld/tileGenerator/HexTileGeneratorStrategy.h @@ -7,6 +7,7 @@ #include #include +#include "../../../engine/core/ECS/EntityManager.h" #include "../../../engine/layer/entities/Entity.h" #include "../../../engine/toolbox/Random.h" @@ -15,7 +16,7 @@ class HexTileGeneratorStrategy { public: virtual ~HexTileGeneratorStrategy() = default; - virtual std::vector> generateHexTile(Random& random, glm::vec3 tilePos, std::vector>& mapEntities) const = 0; + virtual std::vector generateHexTile(EntityManager& em, Random& random, glm::vec3 tilePos) const = 0; };