Starting point
This commit is contained in:
29
.gitignore
vendored
Normal file
29
.gitignore
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Build directories
|
||||||
|
build/
|
||||||
|
cmake-build-*/
|
||||||
|
out/
|
||||||
|
|
||||||
|
# IDE files
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Compiled files
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# CMake generated files
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
cmake_install.cmake
|
||||||
|
compile_commands.json
|
||||||
|
CTestTestfile.cmake
|
||||||
|
Testing/
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
33
CMakeLists.txt
Normal file
33
CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
project(factory_hole_core
|
||||||
|
VERSION 0.1.0
|
||||||
|
DESCRIPTION "High-performance ECS-based factory game engine core"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
# C++17 standard
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Options
|
||||||
|
option(FACTORY_CORE_BUILD_TESTS "Build tests" ON)
|
||||||
|
option(FACTORY_CORE_BUILD_EXAMPLES "Build examples" ON)
|
||||||
|
|
||||||
|
# Export compile commands for IDE support
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
# Include dependency management
|
||||||
|
include(cmake/FetchDependencies.cmake)
|
||||||
|
|
||||||
|
# Add subdirectories
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
if(FACTORY_CORE_BUILD_TESTS)
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FACTORY_CORE_BUILD_EXAMPLES)
|
||||||
|
add_subdirectory(examples)
|
||||||
|
endif()
|
||||||
20
cmake/FetchDependencies.cmake
Normal file
20
cmake/FetchDependencies.cmake
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
# Fetch flecs - high-performance ECS library
|
||||||
|
FetchContent_Declare(
|
||||||
|
flecs
|
||||||
|
GIT_REPOSITORY https://github.com/SanderMertens/flecs.git
|
||||||
|
GIT_TAG v4.0.4
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fetch doctest - testing framework (same as Godot uses)
|
||||||
|
FetchContent_Declare(
|
||||||
|
doctest
|
||||||
|
GIT_REPOSITORY https://github.com/doctest/doctest.git
|
||||||
|
GIT_TAG v2.4.11
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Make dependencies available
|
||||||
|
FetchContent_MakeAvailable(flecs doctest)
|
||||||
1
src/CMakeLists.txt
Normal file
1
src/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(core)
|
||||||
21
src/core/CMakeLists.txt
Normal file
21
src/core/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Factory Core library
|
||||||
|
add_library(factory_core STATIC
|
||||||
|
factory_core.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add alias for consistent usage
|
||||||
|
add_library(factory::core ALIAS factory_core)
|
||||||
|
|
||||||
|
target_include_directories(factory_core
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(factory_core
|
||||||
|
PUBLIC
|
||||||
|
flecs::flecs_static
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set compile features
|
||||||
|
target_compile_features(factory_core PUBLIC cxx_std_17)
|
||||||
5
src/core/factory_core.cpp
Normal file
5
src/core/factory_core.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#include "factory_core.hpp"
|
||||||
|
|
||||||
|
// Implementation file for factory_core
|
||||||
|
// Currently empty as Core is header-only, but needed for static library target
|
||||||
|
// Future implementations will go here
|
||||||
25
src/core/factory_core.hpp
Normal file
25
src/core/factory_core.hpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <flecs.h>
|
||||||
|
|
||||||
|
namespace factory {
|
||||||
|
|
||||||
|
// Core engine class wrapping flecs world
|
||||||
|
class Core {
|
||||||
|
public:
|
||||||
|
Core() : world_() {}
|
||||||
|
|
||||||
|
// Access the underlying flecs world
|
||||||
|
flecs::world& world() { return world_; }
|
||||||
|
const flecs::world& world() const { return world_; }
|
||||||
|
|
||||||
|
// Progress the simulation by one tick
|
||||||
|
bool progress(float delta_time = 0.0f) {
|
||||||
|
return world_.progress(delta_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
flecs::world world_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace factory
|
||||||
15
tests/CMakeLists.txt
Normal file
15
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Test executable
|
||||||
|
add_executable(factory_core_tests
|
||||||
|
test_main.cpp
|
||||||
|
test_example.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(factory_core_tests
|
||||||
|
PRIVATE
|
||||||
|
factory_core
|
||||||
|
doctest::doctest
|
||||||
|
)
|
||||||
|
|
||||||
|
# Register with CTest
|
||||||
|
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
|
||||||
|
doctest_discover_tests(factory_core_tests)
|
||||||
30
tests/test_example.cpp
Normal file
30
tests/test_example.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include <doctest/doctest.h>
|
||||||
|
#include "factory_core.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("Core initialization") {
|
||||||
|
factory::Core core;
|
||||||
|
|
||||||
|
SUBCASE("World is valid after construction") {
|
||||||
|
CHECK(core.world().id() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("Progress returns true") {
|
||||||
|
CHECK(core.progress() == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Basic ECS operations") {
|
||||||
|
factory::Core core;
|
||||||
|
auto& world = core.world();
|
||||||
|
|
||||||
|
SUBCASE("Can create entity") {
|
||||||
|
auto entity = world.entity();
|
||||||
|
CHECK(entity.is_valid());
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("Can create entity with name") {
|
||||||
|
auto entity = world.entity("test_entity");
|
||||||
|
CHECK(entity.is_valid());
|
||||||
|
CHECK(entity.name() == std::string("test_entity"));
|
||||||
|
}
|
||||||
|
}
|
||||||
2
tests/test_main.cpp
Normal file
2
tests/test_main.cpp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||||
|
#include <doctest/doctest.h>
|
||||||
Reference in New Issue
Block a user