From 74042175f8f0bf87568d0ef750ecc9aa1fd43506 Mon Sep 17 00:00:00 2001 From: legatt Date: Fri, 4 Jul 2025 18:20:45 +0300 Subject: [PATCH] State and enterprises register, move namespaces --- ECSAPI/.gitignore | 1 + ECSAPI/CMakePresets.json | 4 ++ ECSAPI/ECS/include/ee_ecs/api.hpp | 4 +- ECSAPI/ECS/include/ee_ecs/data.hpp | 13 ++++ ECSAPI/ECS/include/ee_ecs/world.hpp | 24 ++++--- ECSAPI/ECS/src/api.cpp | 11 +++- ECSAPI/ECS/src/world.cpp | 57 +++++++++++++---- ECSAPI/ECS/test/CMakeLists.txt | 6 +- ECSAPI/ECS/test/benchmark.cpp | 31 ++++++++++ ECSAPI/ECS/test/test_conf.hpp | 19 +++++- ECSAPI/ECS/test/world.cpp | 33 +++++++++- ECSAPI/Economy/CMakeLists.txt | 2 +- .../ee_economy/components/container.hpp | 2 +- .../ee_economy/components/enterprise.hpp | 2 +- .../include/ee_economy/components/miner.hpp | 2 +- .../ee_economy/components/producer.hpp | 2 +- .../include/ee_economy/components/state.hpp | 8 +++ .../include/ee_economy/components/tags.hpp | 4 +- ECSAPI/Economy/include/ee_economy/defines.hpp | 2 +- ECSAPI/Economy/include/ee_economy/economy.hpp | 1 + .../ee_economy/enterprise_defaults.hpp | 2 +- .../include/ee_economy/resources_exchange.hpp | 2 +- ECSAPI/Economy/include/ee_economy/systems.hpp | 2 +- ECSAPI/Economy/src/systems/mining.cpp | 2 +- ECSAPI/Economy/test/systems/mining.cpp | 62 +++++++++---------- ECSAPI/Economy/test/test_conf.hpp | 10 +-- 26 files changed, 227 insertions(+), 81 deletions(-) create mode 100644 ECSAPI/ECS/include/ee_ecs/data.hpp create mode 100644 ECSAPI/ECS/test/benchmark.cpp create mode 100644 ECSAPI/Economy/include/ee_economy/components/state.hpp diff --git a/ECSAPI/.gitignore b/ECSAPI/.gitignore index d63cff4..ed28a3e 100644 --- a/ECSAPI/.gitignore +++ b/ECSAPI/.gitignore @@ -154,6 +154,7 @@ install_manifest.txt compile_commands.json CTestTestfile.cmake _deps +CMakeUserPresets.json ### CMake Patch ### # External projects diff --git a/ECSAPI/CMakePresets.json b/ECSAPI/CMakePresets.json index fb4ca42..ba02f36 100644 --- a/ECSAPI/CMakePresets.json +++ b/ECSAPI/CMakePresets.json @@ -20,6 +20,7 @@ }, { "name": "x64-debug", + "hidden": true, "displayName": "x64 Debug", "inherits": "windows-base", "architecture": { @@ -32,6 +33,7 @@ }, { "name": "x64-release", + "hidden": true, "displayName": "x64 Release", "inherits": "x64-debug", "cacheVariables": { @@ -40,6 +42,7 @@ }, { "name": "x86-debug", + "hidden": true, "displayName": "x86 Debug", "inherits": "windows-base", "architecture": { @@ -52,6 +55,7 @@ }, { "name": "x86-release", + "hidden": true, "displayName": "x86 Release", "inherits": "x86-debug", "cacheVariables": { diff --git a/ECSAPI/ECS/include/ee_ecs/api.hpp b/ECSAPI/ECS/include/ee_ecs/api.hpp index 77fae46..a200812 100644 --- a/ECSAPI/ECS/include/ee_ecs/api.hpp +++ b/ECSAPI/ECS/include/ee_ecs/api.hpp @@ -1,10 +1,10 @@ -// API to control world multithreaded processing in real time #pragma once +#include "data.hpp" namespace ee_ecs { - void init(); + void init(InitConfiguration config); void start(); void stop(); diff --git a/ECSAPI/ECS/include/ee_ecs/data.hpp b/ECSAPI/ECS/include/ee_ecs/data.hpp new file mode 100644 index 0000000..9ba71ee --- /dev/null +++ b/ECSAPI/ECS/include/ee_ecs/data.hpp @@ -0,0 +1,13 @@ +#pragma once +#include +#include + +namespace ee_ecs +{ + + struct InitConfiguration + { + std::unordered_map states; + }; + +} \ No newline at end of file diff --git a/ECSAPI/ECS/include/ee_ecs/world.hpp b/ECSAPI/ECS/include/ee_ecs/world.hpp index e4d8495..d7a6c30 100644 --- a/ECSAPI/ECS/include/ee_ecs/world.hpp +++ b/ECSAPI/ECS/include/ee_ecs/world.hpp @@ -1,6 +1,9 @@ #pragma once +#include "ee_economy/components/container.hpp" +#include #include #include +#include namespace ee_ecs { @@ -9,21 +12,22 @@ namespace ee_ecs private: entt::registry registry; + std::unordered_map states_table; + + void update_enterprises(); public: - /// - /// Run every registered system - /// + // Run every registered system void update(); - /// - /// Register new enterprise entity in specified state - /// - /// represents type of activity that enterprise do every tick - /// is ID of state entity where enterprise will be placed - /// is initial properties of enterprise - void spawn_enterprise(const bool is_building, const ACTION_TYPE action, const entt::entity state, const enterprise_defaults defaults); + entt::entity register_state(const short id, const ee_economy::container &resources); + entt::entity spawn_enterprise( + const bool is_building, + const ee_economy::ACTION_TYPE action, + const entt::entity state, + const ee_economy::enterprise_defaults &defaults + ); entt::registry& get_registry(); }; diff --git a/ECSAPI/ECS/src/api.cpp b/ECSAPI/ECS/src/api.cpp index 7c31afa..58d9f35 100644 --- a/ECSAPI/ECS/src/api.cpp +++ b/ECSAPI/ECS/src/api.cpp @@ -1,11 +1,15 @@ +#include "ee_ecs/world.hpp" #include -static ee_ecs::world world; +static ee_ecs::world world_instance; -void ee_ecs::init() +void ee_ecs::init(ee_ecs::InitConfiguration config) { - + for (auto& [id, container]: config.states) + { + world_instance.register_state(id, container); + } } void ee_ecs::start() @@ -17,3 +21,4 @@ void ee_ecs::stop() { } + diff --git a/ECSAPI/ECS/src/world.cpp b/ECSAPI/ECS/src/world.cpp index e4db81b..c8b7229 100644 --- a/ECSAPI/ECS/src/world.cpp +++ b/ECSAPI/ECS/src/world.cpp @@ -1,35 +1,68 @@ +#include #include +#include + +void ee_ecs::world::update_enterprises() +{ + ee_economy::mining(this->registry); +} void ee_ecs::world::update() { - mining(this->registry); + this->update_enterprises(); } -void ee_ecs::world::spawn_enterprise(const bool is_building, const ACTION_TYPE action, const entt::entity state, const enterprise_defaults defaults) +entt::entity ee_ecs::world::register_state(const short id, const ee_economy::container &resources) +{ + if (this->states_table.contains(id)) + throw std::invalid_argument("State with this Id is already registered"); + + entt::entity entity = this->registry.create(); + + this->registry.emplace(entity, id); + this->registry.emplace( + entity, + resources.capacity, + resources.total, + resources.content + ); + + this->states_table[id] = entity; + + return entity; +} + +entt::entity ee_ecs::world::spawn_enterprise( + const bool is_building, + const ee_economy::ACTION_TYPE action, + const entt::entity state, + const ee_economy::enterprise_defaults &defaults +) { entt::entity entity = this->registry.create(); - auto &enterprise_c = this->registry.emplace(entity); - enterprise_c.is_building = is_building; - enterprise_c.state = state; + this->registry.emplace(entity, is_building, state); - auto &container_c = this->registry.emplace(entity); - container_c = defaults.container; + this->registry.emplace( + entity, + defaults.container.capacity, + defaults.container.total, + defaults.container.content + ); switch (action) { - case ACTION_TYPE::MINING: + case ee_economy::ACTION_TYPE::MINING: { - auto& miner_c = this->registry.emplace(entity); - miner_c.resource = defaults.resource_target; - miner_c.value = defaults.base_efficiency_flat; - + this->registry.emplace(entity, defaults.resource_target, defaults.base_efficiency_flat); break; } default: break; } + + return entity; } entt::registry& ee_ecs::world::get_registry() {return this->registry;} \ No newline at end of file diff --git a/ECSAPI/ECS/test/CMakeLists.txt b/ECSAPI/ECS/test/CMakeLists.txt index ab7ffe4..be35148 100644 --- a/ECSAPI/ECS/test/CMakeLists.txt +++ b/ECSAPI/ECS/test/CMakeLists.txt @@ -1,6 +1,6 @@ # List sources -set(SOURCES "test_conf.hpp" "main.cpp" "world.cpp") +set(SOURCES "test_conf.hpp" "main.cpp" "world.cpp" "benchmark.cpp") # Find dependencies @@ -16,6 +16,10 @@ target_link_libraries(ecs_tests PRIVATE ECS::ECS) # Test +if (CMAKE_VERSION VERSION_GREATER 3.12) + set_property(TARGET ecs_tests PROPERTY CXX_STANDARD 20) +endif() + if (WIN32) add_custom_command( TARGET ecs_tests POST_BUILD diff --git a/ECSAPI/ECS/test/benchmark.cpp b/ECSAPI/ECS/test/benchmark.cpp new file mode 100644 index 0000000..a0a2e1e --- /dev/null +++ b/ECSAPI/ECS/test/benchmark.cpp @@ -0,0 +1,31 @@ +#include +#include "test_conf.hpp" +#include +#include + +struct timer final { + timer() + : start{std::chrono::system_clock::now()} {} + + void elapsed() { + auto now = std::chrono::system_clock::now(); + std::cout << std::chrono::duration(now - start).count() << " seconds" << std::endl; + } + +private: + std::chrono::time_point start; +}; + +template +void generic_with(Func func) { + timer timer; + func(); + timer.elapsed(); +} + +TEST_F(WorldBenchmark, UpdateSystems) +{ + generic_with([&]() { + world.update(); + }); +} \ No newline at end of file diff --git a/ECSAPI/ECS/test/test_conf.hpp b/ECSAPI/ECS/test/test_conf.hpp index b9539bf..f35e9a0 100644 --- a/ECSAPI/ECS/test/test_conf.hpp +++ b/ECSAPI/ECS/test/test_conf.hpp @@ -3,13 +3,30 @@ #include #include -struct WorldTest : testing::Test +struct WorldBenchmark : testing::Test { ee_ecs::world world; void SetUp() { + for (short i = 0; i < 1000; i++) + { + ee_economy::container resources = {.capacity = 100.0}; + resources.add(ee_economy::RESOURCE_TYPE::COAL, 100.0); + entt::entity state = world.register_state(i, resources); + ee_economy::enterprise_defaults miner = { + .container = {.capacity = 100.0}, + .resource_target = ee_economy::RESOURCE_TYPE::GOLD, + .base_efficiency_flat = 1.0 + }; + + world.spawn_enterprise(false, ee_economy::ACTION_TYPE::MINING, state, miner); + world.spawn_enterprise(false, ee_economy::ACTION_TYPE::MINING, state, miner); + world.spawn_enterprise(false, ee_economy::ACTION_TYPE::MINING, state, miner); + world.spawn_enterprise(false, ee_economy::ACTION_TYPE::MINING, state, miner); + world.spawn_enterprise(false, ee_economy::ACTION_TYPE::MINING, state, miner); + } } void TearDown() diff --git a/ECSAPI/ECS/test/world.cpp b/ECSAPI/ECS/test/world.cpp index 8ac8fea..0db137c 100644 --- a/ECSAPI/ECS/test/world.cpp +++ b/ECSAPI/ECS/test/world.cpp @@ -1,8 +1,35 @@ #include -#include "test_conf.hpp" #include +#include +#include -TEST_F(WorldTest, SpawnEnterprise) +TEST(WorldTest, RegisterState) { - ASSERT_TRUE(true); + ee_ecs::world world; + + ee_economy::container res = {.capacity = 100.0}; + res.add(ee_economy::RESOURCE_TYPE::COAL, 98.0); + entt::entity state = world.register_state(10, res); + + ee_economy::state registered_state = world.get_registry().get(state); + ee_economy::container registered_container = world.get_registry().get(state); + + ASSERT_EQ(registered_state.external_id, 10); + ASSERT_EQ(registered_container.content[ee_economy::RESOURCE_TYPE::COAL], 98.0); +} + +TEST(WorldTest, RegisterStateDuplicate) +{ + ee_ecs::world world; + + world.register_state(10, {}); + + ASSERT_THROW({ + world.register_state(10, {}); + }, std::invalid_argument); +} + +TEST(WorldTest, SpawnEnterprise) +{ + ASSERT_TRUE(false); } \ No newline at end of file diff --git a/ECSAPI/Economy/CMakeLists.txt b/ECSAPI/Economy/CMakeLists.txt index dced1d0..0bc19bf 100644 --- a/ECSAPI/Economy/CMakeLists.txt +++ b/ECSAPI/Economy/CMakeLists.txt @@ -3,7 +3,7 @@ # List sources set(HEADERS "economy.hpp" "defines.hpp" "enterprise_defaults.hpp" "systems.hpp") -set(HEADERS_COMPONENTS "container.hpp" "enterprise.hpp" "miner.hpp" "producer.hpp" "tags.hpp") +set(HEADERS_COMPONENTS "container.hpp" "enterprise.hpp" "miner.hpp" "producer.hpp" "state.hpp" "tags.hpp") set(SOURCES "Economy.cpp") set(SOURCES_SYSTEMS "mining.cpp") diff --git a/ECSAPI/Economy/include/ee_economy/components/container.hpp b/ECSAPI/Economy/include/ee_economy/components/container.hpp index 9998fea..61df5f2 100644 --- a/ECSAPI/Economy/include/ee_economy/components/container.hpp +++ b/ECSAPI/Economy/include/ee_economy/components/container.hpp @@ -2,7 +2,7 @@ #include "../defines.hpp" #include -namespace ee_ecs +namespace ee_economy { struct container { diff --git a/ECSAPI/Economy/include/ee_economy/components/enterprise.hpp b/ECSAPI/Economy/include/ee_economy/components/enterprise.hpp index 7392c89..c06848d 100644 --- a/ECSAPI/Economy/include/ee_economy/components/enterprise.hpp +++ b/ECSAPI/Economy/include/ee_economy/components/enterprise.hpp @@ -1,7 +1,7 @@ #pragma once #include -namespace ee_ecs +namespace ee_economy { struct enterprise { diff --git a/ECSAPI/Economy/include/ee_economy/components/miner.hpp b/ECSAPI/Economy/include/ee_economy/components/miner.hpp index 1f3773d..e7ffb58 100644 --- a/ECSAPI/Economy/include/ee_economy/components/miner.hpp +++ b/ECSAPI/Economy/include/ee_economy/components/miner.hpp @@ -2,7 +2,7 @@ #include "../defines.hpp" #include -namespace ee_ecs +namespace ee_economy { struct miner { diff --git a/ECSAPI/Economy/include/ee_economy/components/producer.hpp b/ECSAPI/Economy/include/ee_economy/components/producer.hpp index 83dcd82..fc6d12a 100644 --- a/ECSAPI/Economy/include/ee_economy/components/producer.hpp +++ b/ECSAPI/Economy/include/ee_economy/components/producer.hpp @@ -1,6 +1,6 @@ #pragma once -namespace ee_ecs +namespace ee_economy { struct producer { diff --git a/ECSAPI/Economy/include/ee_economy/components/state.hpp b/ECSAPI/Economy/include/ee_economy/components/state.hpp new file mode 100644 index 0000000..31c031f --- /dev/null +++ b/ECSAPI/Economy/include/ee_economy/components/state.hpp @@ -0,0 +1,8 @@ +#pragma once + +namespace ee_economy +{ + struct state { + short external_id = -1; + }; +} \ No newline at end of file diff --git a/ECSAPI/Economy/include/ee_economy/components/tags.hpp b/ECSAPI/Economy/include/ee_economy/components/tags.hpp index 0e8e63b..ea625ce 100644 --- a/ECSAPI/Economy/include/ee_economy/components/tags.hpp +++ b/ECSAPI/Economy/include/ee_economy/components/tags.hpp @@ -1,8 +1,6 @@ #pragma once -namespace ee_ecs +namespace ee_economy { - struct state {}; - } \ No newline at end of file diff --git a/ECSAPI/Economy/include/ee_economy/defines.hpp b/ECSAPI/Economy/include/ee_economy/defines.hpp index a23a67d..a5a879c 100644 --- a/ECSAPI/Economy/include/ee_economy/defines.hpp +++ b/ECSAPI/Economy/include/ee_economy/defines.hpp @@ -1,6 +1,6 @@ #pragma once -namespace ee_ecs +namespace ee_economy { const double TOLERANCE = 0.001; diff --git a/ECSAPI/Economy/include/ee_economy/economy.hpp b/ECSAPI/Economy/include/ee_economy/economy.hpp index 6fa69fa..891f7bb 100644 --- a/ECSAPI/Economy/include/ee_economy/economy.hpp +++ b/ECSAPI/Economy/include/ee_economy/economy.hpp @@ -5,6 +5,7 @@ #include "systems.hpp" #include "components/tags.hpp" +#include "components/state.hpp" #include "components/container.hpp" #include "components/enterprise.hpp" #include "components/miner.hpp" diff --git a/ECSAPI/Economy/include/ee_economy/enterprise_defaults.hpp b/ECSAPI/Economy/include/ee_economy/enterprise_defaults.hpp index 59be088..7d8abbe 100644 --- a/ECSAPI/Economy/include/ee_economy/enterprise_defaults.hpp +++ b/ECSAPI/Economy/include/ee_economy/enterprise_defaults.hpp @@ -2,7 +2,7 @@ #include "defines.hpp" #include "components/container.hpp" -namespace ee_ecs +namespace ee_economy { struct enterprise_defaults { diff --git a/ECSAPI/Economy/include/ee_economy/resources_exchange.hpp b/ECSAPI/Economy/include/ee_economy/resources_exchange.hpp index dd6b743..cad73c5 100644 --- a/ECSAPI/Economy/include/ee_economy/resources_exchange.hpp +++ b/ECSAPI/Economy/include/ee_economy/resources_exchange.hpp @@ -4,7 +4,7 @@ #include #include "defines.hpp" -namespace ee_ecs +namespace ee_economy { struct exchange_rule { diff --git a/ECSAPI/Economy/include/ee_economy/systems.hpp b/ECSAPI/Economy/include/ee_economy/systems.hpp index 2e56a48..6d36b01 100644 --- a/ECSAPI/Economy/include/ee_economy/systems.hpp +++ b/ECSAPI/Economy/include/ee_economy/systems.hpp @@ -1,7 +1,7 @@ #pragma once #include -namespace ee_ecs +namespace ee_economy { void mining(entt::registry& registry); // void producing(entt::registry& registry); diff --git a/ECSAPI/Economy/src/systems/mining.cpp b/ECSAPI/Economy/src/systems/mining.cpp index 020d668..d6c0dff 100644 --- a/ECSAPI/Economy/src/systems/mining.cpp +++ b/ECSAPI/Economy/src/systems/mining.cpp @@ -1,6 +1,6 @@ #include -void ee_ecs::mining(entt::registry ®istry) +void ee_economy::mining(entt::registry ®istry) { auto miners = registry.view(); diff --git a/ECSAPI/Economy/test/systems/mining.cpp b/ECSAPI/Economy/test/systems/mining.cpp index 90fcc2e..4666331 100644 --- a/ECSAPI/Economy/test/systems/mining.cpp +++ b/ECSAPI/Economy/test/systems/mining.cpp @@ -4,83 +4,83 @@ TEST_F(SystemsTest, MiningNormal) { - ee_ecs::container &state_container = registry.get(state); - ee_ecs::container &miner_container = registry.get(miner); - ee_ecs::miner &miner_miner = registry.get(miner); + ee_economy::container &state_container = registry.get(state); + ee_economy::container &miner_container = registry.get(miner); + ee_economy::miner &miner_miner = registry.get(miner); state_container.capacity = 15.0; - state_container.add(ee_ecs::RESOURCE_TYPE::COAL, 10.0); + state_container.add(ee_economy::RESOURCE_TYPE::COAL, 10.0); miner_container.capacity = 5.0; - miner_miner.resource = ee_ecs::RESOURCE_TYPE::COAL; + miner_miner.resource = ee_economy::RESOURCE_TYPE::COAL; miner_miner.value = 0.1; - ee_ecs::mining(registry); + ee_economy::mining(registry); ASSERT_DOUBLE_EQ(state_container.total, 9.9); - ASSERT_DOUBLE_EQ(state_container.content[ee_ecs::RESOURCE_TYPE::COAL], 9.9); + ASSERT_DOUBLE_EQ(state_container.content[ee_economy::RESOURCE_TYPE::COAL], 9.9); ASSERT_DOUBLE_EQ(miner_container.total, 0.1); - ASSERT_DOUBLE_EQ(miner_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.1); + ASSERT_DOUBLE_EQ(miner_container.content[ee_economy::RESOURCE_TYPE::COAL], 0.1); } TEST_F(SystemsTest, MiningEmptyState) { - ee_ecs::container &state_container = registry.get(state); - ee_ecs::container &miner_container = registry.get(miner); - ee_ecs::miner &miner_miner = registry.get(miner); + ee_economy::container &state_container = registry.get(state); + ee_economy::container &miner_container = registry.get(miner); + ee_economy::miner &miner_miner = registry.get(miner); state_container.capacity = 15.0; miner_container.capacity = 5.0; - miner_miner.resource = ee_ecs::RESOURCE_TYPE::COAL; + miner_miner.resource = ee_economy::RESOURCE_TYPE::COAL; miner_miner.value = 0.1; - ee_ecs::mining(registry); + ee_economy::mining(registry); ASSERT_DOUBLE_EQ(state_container.total, 0.0); - ASSERT_DOUBLE_EQ(state_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.0); + ASSERT_DOUBLE_EQ(state_container.content[ee_economy::RESOURCE_TYPE::COAL], 0.0); ASSERT_DOUBLE_EQ(miner_container.total, 0.0); - ASSERT_DOUBLE_EQ(miner_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.0); + ASSERT_DOUBLE_EQ(miner_container.content[ee_economy::RESOURCE_TYPE::COAL], 0.0); } TEST_F(SystemsTest, MiningPoorState) { - ee_ecs::container &state_container = registry.get(state); - ee_ecs::container &miner_container = registry.get(miner); - ee_ecs::miner &miner_miner = registry.get(miner); + ee_economy::container &state_container = registry.get(state); + ee_economy::container &miner_container = registry.get(miner); + ee_economy::miner &miner_miner = registry.get(miner); state_container.capacity = 15.0; - state_container.add(ee_ecs::RESOURCE_TYPE::COAL, 0.05); + state_container.add(ee_economy::RESOURCE_TYPE::COAL, 0.05); miner_container.capacity = 5.0; - miner_miner.resource = ee_ecs::RESOURCE_TYPE::COAL; + miner_miner.resource = ee_economy::RESOURCE_TYPE::COAL; miner_miner.value = 0.1; - ee_ecs::mining(registry); + ee_economy::mining(registry); ASSERT_DOUBLE_EQ(state_container.total, 0.0); - ASSERT_DOUBLE_EQ(state_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.0); + ASSERT_DOUBLE_EQ(state_container.content[ee_economy::RESOURCE_TYPE::COAL], 0.0); ASSERT_DOUBLE_EQ(miner_container.total, 0.05); - ASSERT_DOUBLE_EQ(miner_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.05); + ASSERT_DOUBLE_EQ(miner_container.content[ee_economy::RESOURCE_TYPE::COAL], 0.05); } TEST_F(SystemsTest, MiningReachCap) { - ee_ecs::container &state_container = registry.get(state); - ee_ecs::container &miner_container = registry.get(miner); - ee_ecs::miner &miner_miner = registry.get(miner); + ee_economy::container &state_container = registry.get(state); + ee_economy::container &miner_container = registry.get(miner); + ee_economy::miner &miner_miner = registry.get(miner); state_container.capacity = 15.0; - state_container.add(ee_ecs::RESOURCE_TYPE::COAL, 10.0); + state_container.add(ee_economy::RESOURCE_TYPE::COAL, 10.0); miner_container.capacity = 0.05; - miner_miner.resource = ee_ecs::RESOURCE_TYPE::COAL; + miner_miner.resource = ee_economy::RESOURCE_TYPE::COAL; miner_miner.value = 0.1; - ee_ecs::mining(registry); + ee_economy::mining(registry); ASSERT_DOUBLE_EQ(state_container.total, 9.95); - ASSERT_DOUBLE_EQ(state_container.content[ee_ecs::RESOURCE_TYPE::COAL], 9.95); + ASSERT_DOUBLE_EQ(state_container.content[ee_economy::RESOURCE_TYPE::COAL], 9.95); ASSERT_DOUBLE_EQ(miner_container.total, 0.05); - ASSERT_DOUBLE_EQ(miner_container.content[ee_ecs::RESOURCE_TYPE::COAL], 0.05); + ASSERT_DOUBLE_EQ(miner_container.content[ee_economy::RESOURCE_TYPE::COAL], 0.05); } \ No newline at end of file diff --git a/ECSAPI/Economy/test/test_conf.hpp b/ECSAPI/Economy/test/test_conf.hpp index 4ed9c09..9b3a453 100644 --- a/ECSAPI/Economy/test/test_conf.hpp +++ b/ECSAPI/Economy/test/test_conf.hpp @@ -16,14 +16,14 @@ struct SystemsTest : testing::Test { // Create state state = registry.create(); - registry.emplace(state); - registry.emplace(state); + registry.emplace(state); + registry.emplace(state); // Create miner enterprise miner = registry.create(); - registry.emplace(miner, false, state); - registry.emplace(miner); - registry.emplace(miner); + registry.emplace(miner, false, state); + registry.emplace(miner); + registry.emplace(miner); } void TearDown()