-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite the ECS in C++ #142
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added a bunch of components ready for the ECS conversion.
All the logic for the components, the entity component system, and the systems are done, just need to finish the tests and all the remaining errors/warnings.
Rearranged systems into systems/. Moved SteeringMovement.walls into the registry. Refactored all tests and improved some. Fixed various typing and linting problems including changing Vec2d to a normal class.
…riable names. Added __eq__ and __hash__ to Vec2d since removing the NamedTuple inheritance causes all the tests to fail as they couldn't compare two vectors or store the vectors in sets. Added registry.update() to game.py so the systems can be updated.
Registry.create_game_object() now deep copies components to prevent modifications on one instance of a game object from affecting others. Rewrote constructors.py, so it conforms to the new ECS design and allows for deep copies. Added boolean parameter to HadesSprite to simplify the design for calculating the entity's force. Fixed last remaining type errors.
…ON is now not needed and all files are listed in the root CMakeLists.txt. Added SYSTEMS set to game_objects/__init__.py as well as fixing various runtime bugs related to game_objects. Added submodules to binding.cpp.
…hat has the primitives for generation/ and game_objects/ at a later date. Added addition to angle_between() since the Python modulo operator can handle negatives, but the C++ std::fmod cannot so the value needs to be positive. Implemented steering.cpp and its tests.
Implemented components.hpp and its source file as well as its test file. Added registry.hpp and implemented some of the methods. Added base.hpp which needs to be implemented. Private variables have an underscore postfix to differentiate them. Improved CMakeLists.txt path variables. Renamed Fixtures to the specific subdirectory name.
Moved hash_combine to base.hpp. Improved documentation. Still have a few things left to do and one more method to move out of Vec2d (which is causing some problems).
…l as made all members in GameObjectAttributeBase private. Fixed all bugs and redesigned registry.hpp as well as implementing all tests for it. Inline some stuff in primitives.hpp and steering.hpp. Renamed all templates from class to typename.
… rest of the files for systems/. Added type aliases for registry.hpp as well, as removing default constructors and renaming some method names. Added .capacity() to Inventory component. Improved Vec2d operators. Removed test_int for TestGameObjectComponentTwo.
…hpp. Renamed INCLUDE_PATH to INCLUDE_DIR. Registry.cpp and registry.hpp now throws exceptions. Changed Footprints to use a deque. Added macros.hpp to abstract testing for an exception and message as well as moving all fixtures for game_objects/ to their individuals files. Added documentation for each test. Changed a few types.
…cpp as well as fixed a bug with test_inventory.cpp where the fixtures were called the same as in test_attacks.cpp creating a SEH exception. Reformatted some stuff and refactored some other bits to improve definitions and code quality. Changed get_kinematic_object to return a pointer. Removed GameObjectAttributeException and GameObjectAttributeBase's boolean has() methods are now public instead of private since it created an issue.
Moved all systems to being stateful instead of some static methods. Optimised some definitions and methods and moved some things around. Improve the raycast lambda function. Renamed all Fixtures to Fixture. Added more type aliases to registry.hpp.
…the Stat class and split up into multiple separate components and systems. This includes the ArmourRegenSystem, the DamageSystem and the UpgradeSystem. We still have to implement the EffectSystem though. Added extra implementation of Registry::get_component allowing the user to pass in a std::type_index. Updated dependencies. Renamed base.hpp to hash_combine.hpp.
…e leftover time if delta time covers multiple intervals and will apply the status effect on subsequent updates. Moved Stat and all of its subclasses to a separate stats.hpp header. Changed some comments, includes and documentation. Optimised a few things.
…arate. Changed Registry::create_game_object, so it now just creates the game object. This lead to the creation of add_component which adds a component to a given game object. Also changed the add_system method to work similarly to add_component. Added all bindings for game_objects/ and started working on stub files. Just have a bug with create_game_object. Modified a few definitions, includes, docs and comments to be more up to date and improved. Renamed Inventory::capacity() to Inventory::get_capacity().
Rearranged CMakeLists.txt and made all compiler warnings appear as errors.
…timised and is inline with game_objects/. Changed the structure of CMakeLists.txt by moving some statements around, making it much easier to understand and more flexible. Got clang-tidy and cppcheck to run during CMake build. However, I'm not too sure about their configurations, so they're disabled for now and can be enabled at a later date. Changed the ordering of include statements to conform to the Google style.
JackAshwell11
force-pushed
the
ecs-cpp-rewrite
branch
from
October 29, 2023 21:00
16ac7cb
to
6ec01e7
Compare
for more information, see https://pre-commit.ci
Made SystemBase a class and added get_registry() to access the registry attribute. Also changed the constructor to use a pointer instead of a reference as well as making all update() methods const. Modified all components to just hold data and not have any methods. If a struct has any methods, it becomes a class. Simplified the AttackSystem design to not use AttackResult. Updated a few tests that only worked in Debug mode, but failed in Release mode. Solved a few clang-tidy and cppcheck linting errors, but there's still more to go. Modified a few comments to be easier to read and understand. Added const to a few other variables and optimised various bits.
Changed and removed some comments, definitions, and constructors, so they're more efficient and easier to use. Fixed coverage configuration. It should now generate the coverage files for gcov (which still needs to be setup). Used list initialisation wherever possible. Reformatted .clang-tidy.
Started transitioning the Python project to use the new C++ ECS. Nearly completed the stub files for the C++ project. The bindings do need a bit of rearranging to make them easier to use and to remove unnecessary stuff. There's just a few registry methods left to bind, but that may require a redesign.
…rk better with the python bindings. Added type traits for components and systems to deduce their name for the collections on compile time. This avoids the use of typeid() and ensures that the program won't compile if a component or system hasn't implemented the trait. Started fixing the remaining python binding code.
for more information, see https://pre-commit.ci
…rrectly works. This did require removing some attributes for some components in Python, but they probably won't be used. Updated all the stub files and rearranged the binding modules, so they're easier to understand. Updated the Python project to use the new C++ ECS. Renamed the C++ project's test directory to tests to be more in-line with the Python project. Added CMakePresets.json and improved .gitignore. Rewrote RegistryError to provide more helpful error messages. Added some more tests to the C++ project and made sure all the existing ones pass on MSVC and GCC.
Improved .gitignore even more. Fixed the Python CI test errors. The remaining C++ CI build errors will be fixed at a later date.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
This PR rewrites the Python ECS in C++ optimising the ECS design as well as offering a multitude of other improvements to the project structure and the generation module.
Type of Changes
Tasks
Add Clang-tidy and Clang-format to the C++ projectClang-tidy and Clang-format have been added, but Clang-tidy is currently not enabled in the CMake build and will be fixed at a later date.Fix the CI build issues and add coverageCoverage is added, but the CI build issues will be fixed at a later date.Add Python unit tests for the Python bindingsThis will be looked into at a later date.Potentially switch to a package manager like Conan or vcpkgThis will be looked into at a later date.