diff --git a/.idea/Dicewars-Siedler.iml b/.idea/Dicewars-Siedler.iml
index 4c94235..f08604b 100644
--- a/.idea/Dicewars-Siedler.iml
+++ b/.idea/Dicewars-Siedler.iml
@@ -1,2 +1,2 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
index 5e7b172..8a5949c 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -17,7 +17,7 @@
-
+
@@ -257,7 +257,6 @@
-
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2cfd79..34c0c7b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -289,6 +289,8 @@ if(BUILD_GAME)
src/game/GameWorldSystems.cpp
src/game/GameWorldSystems.h
src/engine/core/gui/uiComponent/layout/LayoutEngine.h
+ src/engine/renderer/config/MinimapConfig.h
+ src/engine/core/Types.h
)
target_compile_options(Dicewars_Siedler PRIVATE
-Wall
diff --git a/src/engine/core/Types.h b/src/engine/core/Types.h
new file mode 100644
index 0000000..c575b78
--- /dev/null
+++ b/src/engine/core/Types.h
@@ -0,0 +1,13 @@
+//
+// Created by sebastian on 20.04.26.
+//
+
+#ifndef TYPES_H
+#define TYPES_H
+#include
+
+namespace Engine {
+ using PlayerID = std::uint32_t;
+}
+
+#endif //TYPES_H
diff --git a/src/engine/renderer/MasterRenderer.cpp b/src/engine/renderer/MasterRenderer.cpp
index 5d56033..810fa76 100644
--- a/src/engine/renderer/MasterRenderer.cpp
+++ b/src/engine/renderer/MasterRenderer.cpp
@@ -29,7 +29,7 @@ void MasterRenderer::render(const Light &light, const Camera &camera) {
worldSpriteRenderer->finalize();
worldSprites.clear();
- std::unordered_map colorMapping;
+ std::unordered_map colorMapping;
colorMapping[0] = glm::vec3(1.0f, 0.0f, 0.0f);
colorMapping[1] = glm::vec3(0.0f, 1.0f, 0.0f);
colorMapping[2] = glm::vec3(0.0f, 0.0f, 1.0f);
diff --git a/src/engine/renderer/MinimapRenderer.cpp b/src/engine/renderer/MinimapRenderer.cpp
index 61a2b69..f78f5de 100644
--- a/src/engine/renderer/MinimapRenderer.cpp
+++ b/src/engine/renderer/MinimapRenderer.cpp
@@ -13,7 +13,7 @@
#include "glm/ext/matrix_transform.hpp"
-void MinimapRenderer::render(const std::vector &renderData, std::unordered_map colorMapping) {
+void MinimapRenderer::render(const std::vector &renderData, std::unordered_map colorMapping) {
minimapFBO->bind();
glViewport(0,0, width, height);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -92,7 +92,7 @@ void MinimapRenderer::finalizeShader() {
minimapShader.stop();
}
-void MinimapRenderer::prepareInstance(const MinimapRenderData &data, const std::unordered_map& colorMapping) {
+void MinimapRenderer::prepareInstance(const MinimapRenderData &data, const std::unordered_map& colorMapping) {
glm::mat4 model = MathUtils::createTransformationMatrix(data.transform->position, data.transform->rotation.x, data.transform->rotation.y, data.transform->rotation.z, data.transform->scale);
minimapShader.loadTransformationMatrix(model);
diff --git a/src/engine/renderer/MinimapRenderer.h b/src/engine/renderer/MinimapRenderer.h
index 47bd63e..f4a03e0 100644
--- a/src/engine/renderer/MinimapRenderer.h
+++ b/src/engine/renderer/MinimapRenderer.h
@@ -19,7 +19,7 @@ public:
minimapFBO = std::make_unique(width, height);
}
- void render(const std::vector &renderData, std::unordered_map colorMapping);
+ void render(const std::vector &renderData, std::unordered_map colorMapping);
GLuint getMinimapTexture();
@@ -30,7 +30,7 @@ private:
void prepareShader();
void finalizeShader();
- void prepareInstance(const MinimapRenderData &data, const std::unordered_map& colorMapping);
+ void prepareInstance(const MinimapRenderData &data, const std::unordered_map& colorMapping);
};
diff --git a/src/engine/renderer/config/MinimapConfig.h b/src/engine/renderer/config/MinimapConfig.h
new file mode 100644
index 0000000..ed73a11
--- /dev/null
+++ b/src/engine/renderer/config/MinimapConfig.h
@@ -0,0 +1,16 @@
+//
+// Created by sebastian on 20.04.26.
+//
+
+#ifndef MINIMAPCONFIG_H
+#define MINIMAPCONFIG_H
+#include
+
+#include "../../../game/player/Player.h"
+
+struct MinimapConfig {
+ int resolution;
+
+ std::unordered_map playerColors;
+};
+#endif //MINIMAPCONFIG_H
diff --git a/src/game/GameMode.cpp b/src/game/GameMode.cpp
index 401b496..cc1b59f 100644
--- a/src/game/GameMode.cpp
+++ b/src/game/GameMode.cpp
@@ -15,7 +15,7 @@ GameMode::GameMode() {
addPlayer(1, "Player 2");
}
-bool GameMode::canBuild(PlayerID player, BuildingType buildingType) const {
+bool GameMode::canBuild(Engine::PlayerID player, BuildingType buildingType) const {
const auto def = BuildingConfig::get(buildingType);
const auto buildingCosts = def.resourceCosts;
@@ -27,33 +27,33 @@ bool GameMode::canBuild(PlayerID player, BuildingType buildingType) const {
return true;
}
-bool GameMode::canAfford(const PlayerID player_id, RessourceType ressource, int amount) const {
+bool GameMode::canAfford(const Engine::PlayerID player_id, RessourceType ressource, int amount) const {
if (players.contains(player_id)) {
return players.at(player_id).getInventory()->getAmount(ressource) >= amount;
}
return false;
}
-void GameMode::build(PlayerID player, EntityID tileEntity, BuildingType buildingType) {
+void GameMode::build(Engine::PlayerID player, EntityID tileEntity, BuildingType buildingType) {
if (canBuild(player, buildingType)) {
players[player].getInventory()->spend(RessourceType::WOOD, 10);
}
}
-void GameMode::addPlayer(PlayerID playerID, std::string name) {
- PlayerID id = static_cast(players.size());
+void GameMode::addPlayer(Engine::PlayerID playerID, std::string name) {
+ Engine::PlayerID id = static_cast(players.size());
players[id] = Player(id, name);
}
-PlayerID GameMode::getCurrentPlayer() {
+Engine::PlayerID GameMode::getCurrentPlayer() {
return 0;
}
-PlayerInventory& GameMode::getPlayerInventory(PlayerID playerID) {
+PlayerInventory& GameMode::getPlayerInventory(Engine::PlayerID playerID) {
return *players[playerID].getInventory();
}
-void GameMode::pay(PlayerID playerID, const std::unordered_map &costs) {
+void GameMode::pay(Engine::PlayerID playerID, const std::unordered_map &costs) {
for (const auto &[resourceType, amount] : costs) {
players[playerID].getInventory()->spend(resourceType, amount);
}
@@ -75,15 +75,15 @@ size_t GameMode::getPlayerCount() const {
return players.size();
}
-bool GameMode::hasTurn(PlayerID playerID, int turn) const {
+bool GameMode::hasTurn(Engine::PlayerID playerID, int turn) const {
return turn % static_cast(getPlayerCount()) == static_cast(playerID);
}
-void GameMode::addResource(PlayerID playerID, RessourceType ressource, int amount) {
+void GameMode::addResource(Engine::PlayerID playerID, RessourceType ressource, int amount) {
players[playerID].getInventory()->add(ressource, amount);
}
-glm::vec3 GameMode::getColorOfPlayer(PlayerID playerID) {
+glm::vec3 GameMode::getColorOfPlayer(Engine::PlayerID playerID) {
return players[playerID].getColor();
}
diff --git a/src/game/GameMode.h b/src/game/GameMode.h
index 0a870a1..bad4982 100644
--- a/src/game/GameMode.h
+++ b/src/game/GameMode.h
@@ -18,27 +18,27 @@ public:
GameMode();
bool canBuild(EntityID player, BuildingType buildingType) const;
- bool canAfford(PlayerID player_id, RessourceType ressource, int amount) const;
+ bool canAfford(Engine::PlayerID player_id, RessourceType ressource, int amount) const;
void build(EntityID player, EntityID tileEntity, BuildingType buildingType);
- void addPlayer(PlayerID playerID, std::string name);
+ void addPlayer(Engine::PlayerID playerID, std::string name);
- PlayerID getCurrentPlayer();
- PlayerInventory& getPlayerInventory(PlayerID playerID);
+ Engine::PlayerID getCurrentPlayer();
+ PlayerInventory& getPlayerInventory(Engine::PlayerID playerID);
- void pay(PlayerID uint32, const std::unordered_map & pairs);
+ void pay(Engine::PlayerID uint32, const std::unordered_map & pairs);
std::optional getActiveBuilding() const;
void clearActiveBuilding();
void setActiveBuilding(BuildingType buildingType);
size_t getPlayerCount() const;
- bool hasTurn(PlayerID playerID, int turn) const;
+ bool hasTurn(Engine::PlayerID playerID, int turn) const;
bool getCurrentTurnPlayer(int turn) const;
- void addResource(PlayerID uint32, RessourceType ressource, int get_storage);
- glm::vec3 getColorOfPlayer(PlayerID playerID);
+ void addResource(Engine::PlayerID uint32, RessourceType ressource, int get_storage);
+ glm::vec3 getColorOfPlayer(Engine::PlayerID playerID);
void setUpgradeMode(bool upgradeMode);
bool isUpgradeMode() const;
@@ -46,7 +46,7 @@ public:
void resetActiveBuilding();
private:
- std::unordered_map players;
+ std::unordered_map players;
std::optional activeBuilding;
bool upgradeMode = false;
diff --git a/src/game/hexWorld/MapGenerator.cpp b/src/game/hexWorld/MapGenerator.cpp
index 30cd41e..222470f 100644
--- a/src/game/hexWorld/MapGenerator.cpp
+++ b/src/game/hexWorld/MapGenerator.cpp
@@ -122,7 +122,7 @@ void MapGenerator::assignOwners(EntityManager &entityManager, int numPlayers) {
bool changed = true;
while (changed) {
changed = false;
- for (PlayerID player = 0; player < static_cast(numPlayers); ++player) {
+ for (Engine::PlayerID player = 0; player < static_cast(numPlayers); ++player) {
// Finde alle Tiles des Spielers
int ownedCount = 0;
for (TileInfo& tile : allTiles) {
diff --git a/src/game/hexWorld/building/BuildingFactory.cpp b/src/game/hexWorld/building/BuildingFactory.cpp
index afbe814..569e6ea 100644
--- a/src/game/hexWorld/building/BuildingFactory.cpp
+++ b/src/game/hexWorld/building/BuildingFactory.cpp
@@ -16,7 +16,7 @@
#include "../ecs/components/ProducingComponent.h"
EntityID BuildingFactory::create(EntityManager &em, const BuildingDefinition &def,
- const TransformComponent &tileTransform, EntityID tileEntity, PlayerID owner) {
+ const TransformComponent &tileTransform, EntityID tileEntity, Engine::PlayerID owner) {
EntityID e = em.createEntity();
diff --git a/src/game/hexWorld/building/BuildingFactory.h b/src/game/hexWorld/building/BuildingFactory.h
index 341d054..37bcd6f 100644
--- a/src/game/hexWorld/building/BuildingFactory.h
+++ b/src/game/hexWorld/building/BuildingFactory.h
@@ -10,7 +10,7 @@
class BuildingFactory {
public:
- static EntityID create(EntityManager& em, const BuildingDefinition& def, const TransformComponent& tileTransform, EntityID tileEntity, PlayerID owner);
+ static EntityID create(EntityManager& em, const BuildingDefinition& def, const TransformComponent& tileTransform, EntityID tileEntity, Engine::PlayerID owner);
static EntityID createPreview(EntityManager& em, BuildingType buildingType, const TransformComponent& tileTransform, EntityID tileEntity);
};
diff --git a/src/game/hexWorld/building/BuildingRules.cpp b/src/game/hexWorld/building/BuildingRules.cpp
index 7cab748..50be0fe 100644
--- a/src/game/hexWorld/building/BuildingRules.cpp
+++ b/src/game/hexWorld/building/BuildingRules.cpp
@@ -9,7 +9,7 @@
#include "../ecs/components/TileGameplayComponent.h"
bool BuildingRules::canPlace(const BuildingDefinition &def, const TileGameplayComponent &tile, const GameMode &gameMode,
- PlayerID playerID) {
+ Engine::PlayerID playerID) {
if (tile.hasBuilding()) return false;
diff --git a/src/game/hexWorld/building/BuildingRules.h b/src/game/hexWorld/building/BuildingRules.h
index 49e898a..254c46e 100644
--- a/src/game/hexWorld/building/BuildingRules.h
+++ b/src/game/hexWorld/building/BuildingRules.h
@@ -10,7 +10,7 @@
class BuildingRules {
public:
- static bool canPlace(const BuildingDefinition& def, const TileGameplayComponent& tile, const GameMode& gameMode, PlayerID playerID);
+ static bool canPlace(const BuildingDefinition& def, const TileGameplayComponent& tile, const GameMode& gameMode, Engine::PlayerID playerID);
};
diff --git a/src/game/hexWorld/ecs/components/OwnerComponent.h b/src/game/hexWorld/ecs/components/OwnerComponent.h
index b48918e..e7c1810 100644
--- a/src/game/hexWorld/ecs/components/OwnerComponent.h
+++ b/src/game/hexWorld/ecs/components/OwnerComponent.h
@@ -10,8 +10,8 @@
class OwnerComponent : public Component{
public:
- PlayerID playerID;
- explicit OwnerComponent(PlayerID playerID) : playerID(playerID) {};
+ Engine::PlayerID playerID;
+ explicit OwnerComponent(Engine::PlayerID playerID) : playerID(playerID) {};
};
diff --git a/src/game/hexWorld/ecs/systems/BuildPreviewSystem.cpp b/src/game/hexWorld/ecs/systems/BuildPreviewSystem.cpp
index 9745f8a..5de8845 100644
--- a/src/game/hexWorld/ecs/systems/BuildPreviewSystem.cpp
+++ b/src/game/hexWorld/ecs/systems/BuildPreviewSystem.cpp
@@ -16,7 +16,7 @@
EntityID BuildPreviewSystem::previewEntity = 0;
-void BuildPreviewSystem::updateBuildPreview(EntityManager &em, GameMode &gameMode, PlayerID player, const TurnState &turnState) {
+void BuildPreviewSystem::updateBuildPreview(EntityManager &em, GameMode &gameMode, Engine::PlayerID player, const TurnState &turnState) {
if (gameMode.isUpgradeMode() || !gameMode.getActiveBuilding().has_value() || !gameMode.hasTurn(player, turnState.currentTurn)) {
for (EntityID e : em.getAllEntities()) {
const auto tileRenderComponent = em.getComponent(e);
diff --git a/src/game/hexWorld/ecs/systems/BuildPreviewSystem.h b/src/game/hexWorld/ecs/systems/BuildPreviewSystem.h
index a653248..f5d1358 100644
--- a/src/game/hexWorld/ecs/systems/BuildPreviewSystem.h
+++ b/src/game/hexWorld/ecs/systems/BuildPreviewSystem.h
@@ -12,7 +12,7 @@ class EntityManager;
class BuildPreviewSystem {
public:
- static void updateBuildPreview(EntityManager& em, GameMode& gameMode, PlayerID player, const TurnState& turnState);
+ static void updateBuildPreview(EntityManager& em, GameMode& gameMode, Engine::PlayerID player, const TurnState& turnState);
static void disableBuildPreview(EntityManager& em);
private:
static EntityID previewEntity;
diff --git a/src/game/hexWorld/ecs/systems/BuildingPlacementSystem.cpp b/src/game/hexWorld/ecs/systems/BuildingPlacementSystem.cpp
index 6624bd5..b2afa5f 100644
--- a/src/game/hexWorld/ecs/systems/BuildingPlacementSystem.cpp
+++ b/src/game/hexWorld/ecs/systems/BuildingPlacementSystem.cpp
@@ -21,7 +21,7 @@
#include "../components/UpgradeComponent.h"
#include "GLFW/glfw3.h"
-void BuildingPlacementSystem::update(EntityManager& entityManager, GameMode& gameMode, PlayerID player, const TurnState& turnState) {
+void BuildingPlacementSystem::update(EntityManager& entityManager, GameMode& gameMode, Engine::PlayerID player, const TurnState& turnState) {
if (!gameMode.hasTurn(player, turnState.currentTurn)) {
return;
}
diff --git a/src/game/hexWorld/ecs/systems/UpgradeSystem.cpp b/src/game/hexWorld/ecs/systems/UpgradeSystem.cpp
index eede14b..33d2ac7 100644
--- a/src/game/hexWorld/ecs/systems/UpgradeSystem.cpp
+++ b/src/game/hexWorld/ecs/systems/UpgradeSystem.cpp
@@ -23,7 +23,7 @@
class AnimationComponent;
class WorldSpriteComponent;
-void UpgradeSystem::tryUpdate(EntityManager &em, GameMode &gm, PlayerID player, const TurnState &turnState) {
+void UpgradeSystem::tryUpdate(EntityManager &em, GameMode &gm, Engine::PlayerID player, const TurnState &turnState) {
EntityID tileEntityID = SelectionSystem::selectedEntity;
auto tileComponent = em.getComponent(tileEntityID);
@@ -61,7 +61,7 @@ void UpgradeSystem::tryUpdate(EntityManager &em, GameMode &gm, PlayerID player,
}
-void UpgradeSystem::enableUpgradeMode(EntityManager &em, PlayerID player, GameMode& gameMode, const TurnState &turnState) {
+void UpgradeSystem::enableUpgradeMode(EntityManager &em, Engine::PlayerID player, GameMode& gameMode, const TurnState &turnState) {
for (EntityID entityID : em.getAllEntities()) {
auto buildingComponent = em.getComponent(entityID);
auto ownerComponent = em.getComponent(entityID);
@@ -75,7 +75,7 @@ void UpgradeSystem::enableUpgradeMode(EntityManager &em, PlayerID player, GameMo
}
}
-void UpgradeSystem::disableUpgradeMode(EntityManager &em, PlayerID player, GameMode &gameMode) {
+void UpgradeSystem::disableUpgradeMode(EntityManager &em, Engine::PlayerID player, GameMode &gameMode) {
for (EntityID entityID : em.getAllEntities()) {
const auto buildingComponent = em.getComponent(entityID);
const auto ownerComponent = em.getComponent(entityID);
@@ -89,7 +89,7 @@ void UpgradeSystem::disableUpgradeMode(EntityManager &em, PlayerID player, GameM
}
}
-UpgradeResult UpgradeSystem::canUpgrade(EntityManager &em, PlayerID player, GameMode& gameMode, EntityID buildingEntity, const TurnState &turnState) {
+UpgradeResult UpgradeSystem::canUpgrade(EntityManager &em, Engine::PlayerID player, GameMode& gameMode, EntityID buildingEntity, const TurnState &turnState) {
if (!gameMode.hasTurn(player, turnState.currentTurn)) return UpgradeResult::NotPlayersTurn;
auto tier = em.getComponent(buildingEntity);
diff --git a/src/game/hexWorld/ecs/systems/UpgradeSystem.h b/src/game/hexWorld/ecs/systems/UpgradeSystem.h
index 790b77e..f1aadf9 100644
--- a/src/game/hexWorld/ecs/systems/UpgradeSystem.h
+++ b/src/game/hexWorld/ecs/systems/UpgradeSystem.h
@@ -20,13 +20,13 @@ class EntityManager;
class UpgradeSystem {
public:
- static void tryUpdate(EntityManager &em, GameMode &gm, PlayerID player, const TurnState &turnState);
- static void enableUpgradeMode(EntityManager &em, PlayerID player, GameMode& gameMode, const TurnState &turnState);
- static void disableUpgradeMode(EntityManager &em, PlayerID player, GameMode& gameMode);
+ static void tryUpdate(EntityManager &em, GameMode &gm, Engine::PlayerID player, const TurnState &turnState);
+ static void enableUpgradeMode(EntityManager &em, Engine::PlayerID player, GameMode& gameMode, const TurnState &turnState);
+ static void disableUpgradeMode(EntityManager &em, Engine::PlayerID player, GameMode& gameMode);
private:
static void createWorldSprite(EntityManager &em, EntityID e);
- static UpgradeResult canUpgrade(EntityManager &em, PlayerID player, GameMode &gameMode, EntityID buildingEntity, const TurnState &turnState);
+ static UpgradeResult canUpgrade(EntityManager &em, Engine::PlayerID player, GameMode &gameMode, EntityID buildingEntity, const TurnState &turnState);
};
diff --git a/src/game/player/Player.h b/src/game/player/Player.h
index 12ba414..a6094fc 100644
--- a/src/game/player/Player.h
+++ b/src/game/player/Player.h
@@ -11,12 +11,13 @@
#include "PlayerInventory.h"
#include "glm/vec3.hpp"
+#include "../../engine/core/Types.h"
+
-using PlayerID = std::uint32_t;
class Player {
private:
- PlayerID playerID;
+ Engine::PlayerID playerID;
std::string name;
std::unique_ptr inventory = std::make_unique();
bool isAI = false;
@@ -24,7 +25,7 @@ private:
public:
Player() = default;
- Player(const PlayerID playerID, std::string name) : playerID(playerID), name(std::move(name)) {
+ Player(const Engine::PlayerID playerID, std::string name) : playerID(playerID), name(std::move(name)) {
inventory->add(RessourceType::WOOD, 100);
inventory->add(RessourceType::STONE, 178);
};