Merge pull request #40 from BlackMATov/hotfix/assign_filled_feature_bug

hotfix/assign_filled_feature_bug
This commit is contained in:
2019-10-19 02:04:50 +07:00
committed by GitHub
5 changed files with 52 additions and 5 deletions

View File

@@ -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 >

View 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%

View 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
View 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

View File

@@ -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);