mirror of
https://github.com/BlackMATov/ecs.hpp.git
synced 2025-12-13 02:26:27 +07:00
fix assign filled feature bug, add registry_filler
This commit is contained in:
@@ -68,6 +68,7 @@ namespace ecs_hpp
|
||||
class aspect;
|
||||
|
||||
class entity_filler;
|
||||
class registry_filler;
|
||||
}
|
||||
|
||||
namespace ecs_hpp
|
||||
@@ -1813,6 +1814,20 @@ namespace ecs_hpp
|
||||
private:
|
||||
entity& entity_;
|
||||
};
|
||||
|
||||
class registry_filler final {
|
||||
public:
|
||||
registry_filler(registry& registry) noexcept
|
||||
: registry_(registry) {}
|
||||
|
||||
template < typename Tag, typename... Args >
|
||||
registry_filler& feature(Args&&... args) {
|
||||
registry_.assign_feature<Tag>(std::forward<Args>(args)...);
|
||||
return *this;
|
||||
}
|
||||
private:
|
||||
registry& registry_;
|
||||
};
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -2836,7 +2851,7 @@ namespace ecs_hpp
|
||||
return *f = feature{std::forward<Args>(args)...};
|
||||
}
|
||||
assert(!features_locker_.is_locked());
|
||||
return *features_.insert(feature_id, feature()).first;
|
||||
return *features_.insert(feature_id, feature{std::forward<Args>(args)...}).first;
|
||||
}
|
||||
|
||||
template < typename Tag, typename... Args >
|
||||
|
||||
12
scripts/gen_msvc2017_project.bat
Normal file
12
scripts/gen_msvc2017_project.bat
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\msvc2017 || goto :error
|
||||
cd %BUILD_DIR%\msvc2017 || goto :error
|
||||
cmake -G "Visual Studio 15 2017" ..\.. || goto :error
|
||||
start ecs.hpp.sln || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
12
scripts/gen_msvc2019_project.bat
Normal file
12
scripts/gen_msvc2019_project.bat
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\msvc2019 || goto :error
|
||||
cd %BUILD_DIR%\msvc2019 || goto :error
|
||||
cmake -G "Visual Studio 16 2019" ..\.. || goto :error
|
||||
start ecs.hpp.sln || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
7
scripts/gen_xcode_project.sh
Executable file
7
scripts/gen_xcode_project.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/xcode
|
||||
cd $BUILD_DIR/xcode
|
||||
cmake -G Xcode ../..
|
||||
open ecs.hpp.xcodeproj
|
||||
@@ -1583,10 +1583,11 @@ TEST_CASE("registry") {
|
||||
|
||||
ecs::registry w;
|
||||
|
||||
w.assign_feature<struct physics>()
|
||||
.add_system<gravity_system>(9)
|
||||
.add_system<movement_system>()
|
||||
.add_system<physics_system>();
|
||||
ecs::registry_filler(w)
|
||||
.feature<struct physics>(ecs::feature()
|
||||
.add_system<gravity_system>(9)
|
||||
.add_system<movement_system>()
|
||||
.add_system<physics_system>());
|
||||
|
||||
ecs::entity e = w.create_entity();
|
||||
e.assign_component<position_c>(1,2);
|
||||
|
||||
Reference in New Issue
Block a user