Project structure refactor
This commit is contained in:
parent
c8b6287b76
commit
80e025afed
@ -14,3 +14,4 @@ add_subdirectory ("Economy")
|
||||
add_subdirectory ("Economy/test")
|
||||
|
||||
add_subdirectory ("ECS")
|
||||
add_subdirectory ("ECS/test")
|
||||
@ -2,10 +2,10 @@ project(ECS)
|
||||
|
||||
# List sources
|
||||
|
||||
set(HEADERS "ECS.h" "world.h")
|
||||
set(SOURCES "ECS.cpp" "world.cpp")
|
||||
set(HEADERS "ecs.hpp" "api.hpp" "world.hpp")
|
||||
set(SOURCES "api.cpp" "world.cpp")
|
||||
|
||||
list(TRANSFORM HEADERS PREPEND "include/")
|
||||
list(TRANSFORM HEADERS PREPEND "include/ee_ecs/")
|
||||
list(TRANSFORM SOURCES PREPEND "src/")
|
||||
|
||||
# Find dependencies
|
||||
@ -14,8 +14,9 @@ find_package(EnTT CONFIG REQUIRED)
|
||||
# Link library
|
||||
|
||||
add_library(ECS SHARED ${HEADERS} ${SOURCES})
|
||||
add_library(ECS::ECS ALIAS ECS)
|
||||
|
||||
target_link_libraries(ECS PRIVATE Economy::Economy)
|
||||
target_link_libraries(ECS PUBLIC Economy::Economy)
|
||||
target_link_libraries(ECS PRIVATE EnTT::EnTT)
|
||||
|
||||
target_include_directories(ECS PUBLIC include/)
|
||||
|
||||
4
ECSAPI/ECS/include/ee_ecs/ecs.hpp
Normal file
4
ECSAPI/ECS/include/ee_ecs/ecs.hpp
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include "api.hpp"
|
||||
#include "world.hpp"
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#include <entt/entt.hpp>
|
||||
#include "defines.h"
|
||||
#include "enterprise_defaults.h"
|
||||
#include <ee_economy/economy.hpp>
|
||||
|
||||
namespace ee_ecs
|
||||
{
|
||||
@ -24,5 +23,8 @@ namespace ee_ecs
|
||||
/// <param name="state">is ID of state entity where enterprise will be placed</param>
|
||||
/// <param name="defaults">is initial properties of enterprise</param>
|
||||
void spawn_enterprise(const bool is_building, const ACTION_TYPE action, const entt::entity state, const enterprise_defaults defaults);
|
||||
|
||||
|
||||
entt::registry& get_registry();
|
||||
};
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
#include "ECS.h"
|
||||
#include "world.h"
|
||||
#include <ee_ecs/ecs.hpp>
|
||||
|
||||
|
||||
static ee_ecs::world world;
|
||||
@ -1,7 +1,4 @@
|
||||
#include "world.h"
|
||||
#include "systems.h"
|
||||
#include "components/enterprise.h"
|
||||
#include "components/miner.h"
|
||||
#include <ee_ecs/ecs.hpp>
|
||||
|
||||
void ee_ecs::world::update()
|
||||
{
|
||||
@ -34,3 +31,5 @@ void ee_ecs::world::spawn_enterprise(const bool is_building, const ACTION_TYPE a
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
entt::registry& ee_ecs::world::get_registry() {return this->registry;}
|
||||
27
ECSAPI/ECS/test/CMakeLists.txt
Normal file
27
ECSAPI/ECS/test/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
# List sources
|
||||
|
||||
set(SOURCES "test_conf.hpp" "main.cpp" "world.cpp")
|
||||
|
||||
# Find dependencies
|
||||
|
||||
find_package(GTest CONFIG REQUIRED)
|
||||
|
||||
# Link
|
||||
|
||||
include(GoogleTest)
|
||||
|
||||
add_executable(ecs_tests ${SOURCES})
|
||||
target_link_libraries(ecs_tests PRIVATE GTest::gtest_main)
|
||||
target_link_libraries(ecs_tests PRIVATE ECS::ECS)
|
||||
|
||||
# Test
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(
|
||||
TARGET ecs_tests POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:ecs_tests> $<TARGET_FILE_DIR:ecs_tests>
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
endif ()
|
||||
|
||||
gtest_discover_tests(ecs_tests)
|
||||
8
ECSAPI/ECS/test/main.cpp
Normal file
8
ECSAPI/ECS/test/main.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
19
ECSAPI/ECS/test/test_conf.hpp
Normal file
19
ECSAPI/ECS/test/test_conf.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <ee_ecs/ecs.hpp>
|
||||
|
||||
struct WorldTest : testing::Test
|
||||
{
|
||||
ee_ecs::world world;
|
||||
|
||||
void SetUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TearDown()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
8
ECSAPI/ECS/test/world.cpp
Normal file
8
ECSAPI/ECS/test/world.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "test_conf.hpp"
|
||||
#include <ee_ecs/ecs.hpp>
|
||||
|
||||
TEST_F(WorldTest, SpawnEnterprise)
|
||||
{
|
||||
ASSERT_TRUE(true);
|
||||
}
|
||||
@ -2,14 +2,14 @@
|
||||
|
||||
# List sources
|
||||
|
||||
set(HEADERS "defines.h" "enterprise_defaults.h" "systems.h")
|
||||
set(HEADERS_COMPONENTS "container.h" "enterprise.h" "miner.h" "producer.h" "tags.h")
|
||||
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(SOURCES "Economy.cpp")
|
||||
set(SOURCES_SYSTEMS "mining.cpp")
|
||||
|
||||
list(TRANSFORM HEADERS PREPEND "include/")
|
||||
list(TRANSFORM HEADERS_COMPONENTS PREPEND "include/components/")
|
||||
list(TRANSFORM HEADERS PREPEND "include/ee_economy/")
|
||||
list(TRANSFORM HEADERS_COMPONENTS PREPEND "include/ee_economy/components/")
|
||||
|
||||
list(TRANSFORM SOURCES PREPEND "src/")
|
||||
list(TRANSFORM SOURCES_SYSTEMS PREPEND "src/systems/")
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "../defines.h"
|
||||
#include "../defines.hpp"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace ee_ecs
|
||||
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "../defines.h"
|
||||
#include "../defines.hpp"
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
namespace ee_ecs
|
||||
11
ECSAPI/Economy/include/ee_economy/economy.hpp
Normal file
11
ECSAPI/Economy/include/ee_economy/economy.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "defines.hpp"
|
||||
#include "enterprise_defaults.hpp"
|
||||
#include "systems.hpp"
|
||||
|
||||
#include "components/tags.hpp"
|
||||
#include "components/container.hpp"
|
||||
#include "components/enterprise.hpp"
|
||||
#include "components/miner.hpp"
|
||||
#include "components/producer.hpp"
|
||||
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "components/container.h"
|
||||
#include "defines.hpp"
|
||||
#include "components/container.hpp"
|
||||
|
||||
namespace ee_ecs
|
||||
{
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <unordered_map>
|
||||
#include "defines.h"
|
||||
#include "defines.hpp"
|
||||
|
||||
namespace ee_ecs
|
||||
{
|
||||
13
ECSAPI/Economy/include/ee_economy/systems.hpp
Normal file
13
ECSAPI/Economy/include/ee_economy/systems.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
namespace ee_ecs
|
||||
{
|
||||
void mining(entt::registry& registry);
|
||||
// void producing(entt::registry& registry);
|
||||
// void delivering(entt::registry& registry);
|
||||
// void containing(entt::registry& registry);
|
||||
// void destructing(entt::registry& registry);
|
||||
// void building(entt::registry& registry);
|
||||
// void trading(entt::registry& registry);
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
namespace ee_ecs
|
||||
{
|
||||
void mining(entt::registry& registry);
|
||||
}
|
||||
@ -1,7 +1,4 @@
|
||||
#include "systems.h"
|
||||
#include "components/miner.h"
|
||||
#include "components/container.h"
|
||||
#include "components/enterprise.h"
|
||||
#include <ee_economy/economy.hpp>
|
||||
|
||||
void ee_ecs::mining(entt::registry ®istry)
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# List sources
|
||||
|
||||
set(SOURCES "test_conf.h" "main.cpp" "systems/mining.cpp")
|
||||
set(SOURCES "test_conf.hpp" "main.cpp" "systems/mining.cpp")
|
||||
|
||||
# Find dependencies
|
||||
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "components/container.h"
|
||||
#include "components/miner.h"
|
||||
#include "defines.h"
|
||||
#include "../test_conf.h"
|
||||
#include "systems.h"
|
||||
#include <ee_economy/economy.hpp>
|
||||
#include "../test_conf.hpp"
|
||||
|
||||
TEST_F(SystemsTest, MiningNormal)
|
||||
{
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#include "components/container.h"
|
||||
#include "components/enterprise.h"
|
||||
#include "components/miner.h"
|
||||
#include "components/tags.h"
|
||||
#pragma once
|
||||
|
||||
#include <ee_economy/economy.hpp>
|
||||
#include <entt/entt.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user