Commit graph

182 commits

Author SHA1 Message Date
8c462b83a1 Add static_assert, components must be def-const
EC::Manager will fail to compile if any given Component is not default
constructible, so a static_assert and ctest was added.
2018-09-11 12:16:04 +09:00
6bf239a43b API change: context/userdata provided to functions
All functions called by EC/Manager now accept an additional parameter
as a void* to support user-provided data (or context) for functions
(useful when the function is not a lambda function and doesn't have any
other data stored with it).
2018-08-08 16:52:12 +09:00
2411125003 Fix C++14 requirement in CMakeLists.txt 2018-05-21 19:24:49 +09:00
08433bcb4e Update README.md 2018-05-21 16:49:37 +09:00
8f35cf4fa4 Update LICENSE year 2018-05-21 16:46:31 +09:00
b9589b909d Minor fixes/improvements 2018-05-19 16:09:31 +09:00
9d914ce10d Update documentation 2018-05-18 20:47:34 +09:00
d12af4d527 Add ability to handle unknown types
EC/Manager and EC/Bitset can now handle types that are not known
(Components or Tags not in the given Components or Tags when created).

Manager::getEntityData now returns a pointer instead of a reference.
Functions passed to Manager::forMatchingFunction (and other similar fns)
should now accept Component fields as pointer types, not reference
types.
2018-05-17 17:05:49 +09:00
1e1344cdae Fix warning about unused capture for lambda fn 2018-05-16 16:18:11 +09:00
3b742735f0 Add type reference to Components/Tags in Manager 2018-05-16 14:48:33 +09:00
6f0b7cb65b Fix bug with multiple sig/func call
Fixed bug where if an entity is deleted during a multiple
signature/function call but matched a later signature/function, it would
still be called in that later function.

Minor fixes as well.
2017-12-01 19:20:59 +09:00
f8d27d65d3 Remove .gitlab-ci.yml 2017-12-01 14:03:47 +09:00
6124a45453 Replace garbage-collection-like cleanup
Entity IDs are now guaranteed to not change for a living entity.
Cleanup is replaced by using a std::unordered_set to store deleted
Entity IDs to be reclaimed on later calls to addEntity().
2017-12-01 14:00:49 +09:00
477580ad34 Minor fixes to documentation 2017-11-24 15:06:57 +09:00
60bf841c11 Change CleanupReturnType to std::vector 2017-11-24 14:58:00 +09:00
506b027655 Fix bug with duplicate signatures
Fixed bug where if forMatchingSignatures and forMatchingSignaturesPtr
was called with some signatures in the TypeList being duplicates, then
only the first duplicate and function pair would be called, and all
other functions paired with other duplicate signatures would not be
called.
2017-11-15 15:36:04 +09:00
6b0e950c84 Improve efficiency of stored function calling
Previously, every called function iterated through all entities for
calling the function on matching entities.

Now, callForMatchingFunctions iterates through all entities once,
stores matching entities for each function, then calls the functions on
the matching entities.
2017-11-14 13:51:24 +09:00
248cf2676a Add ptr versions of forMatchingSignature fns 2017-11-14 13:11:32 +09:00
648e47aae9 Fix crash bug, improve Unit Test
Crash bug from improperly implemented std::lock_guard for multi-threaded
usage of forMatchingSignatures fixed.
2017-11-10 13:19:50 +09:00
0dba6874ad Implement forMatchingSignatures for efficiency
EC::Manager::forMatchingSignatures is different from
EC::Manager::forMatchingSignature in that it takes multiple signatures
and functions and iterates through all entities once. The trade-off is
that a vector of vectors is created to store matching entities.
This function can be called to use multiple threads as well, similar
to the "non-plural" version of this function.

See the doxygen-style documentation in src/EC/Manager.hpp for
forMatchingSignatures (or the generated doxygen html) for how to use.
Usage example is in the last unit test function in src/test/ECTest.hpp .
2017-11-09 21:17:40 +09:00
d809d34716 Add getCurrentSize and getCurrentCapacity 2017-11-03 17:11:20 +09:00
16fd8e9ec3 Fix minor typo 2017-10-31 14:10:21 +09:00
1d2fbf7b52 Fix cleanup function's return value
Unordered map does not preserve order in which items were inserted.
This is a problem because an entity id relocated to a previously deleted
one could be read as deleted when iterating through the unordered map.
Thus, it has been replaced with a queue.
2017-10-31 13:25:27 +09:00
2523831097 Fix unit test 2017-10-06 14:35:37 +09:00
ab580a5565 Replace variable length arrays with std::vector 2017-10-06 12:58:49 +09:00
a08b1575d6 Implement multithreading for function calls
Each of the EC::Manager's function calls over entities can now be
multi-threaded.
2017-10-06 12:47:05 +09:00
aad97d6d42 Add feature to cleanup function in manager
ECManager's cleanup function now returns a map detailing info on all
entities changed by cleanup.
2017-09-28 16:05:05 +09:00
396ede1c76 Add const fns to Manager, obey 80 char line limit 2017-09-20 17:18:29 +09:00
bc70089822 Add a test to unit tests 2017-08-29 15:27:58 +09:00
d700b023b3 Fixed keepSomeMatchingFunctions
Previous implementation would fail if functionIndex had wrapped around
2017-07-13 17:28:45 +09:00
1f052154ad Changed clearSomeMatchingFunctions, line lengths
clearSomeMatchingFunctions removed for
keepSomeMatchingFunctions and removeSomeMatchingFunctions to
avoid confusion.

Lines now respect 80 column limit.
2017-07-13 16:13:37 +09:00
49ae172c3a Added two new functions
Added "removeForMatchingFunction" and "callForMatchingFunction".
The former deletes a specific function and the latter calls a specific
function.
2017-07-12 22:02:02 +09:00
7d605bebe7 Updated README.md 2017-06-10 22:17:37 +09:00
9b5281520d Updated README.md 2017-06-10 22:16:55 +09:00
be8ac2f837 Added readme 2017-06-10 22:15:59 +09:00
09a7546509 Changed implementation of stored functions to map
An unordered_map stores functions, allowing for functions to be
removed by index, and bulk removals with filtering by index.

Also added reset(), which changes the state of the Manager to be
almost identical to a newly constructed one.
2016-09-21 21:01:48 +09:00
2e115cd7a2 Fixed docs, ids changed to const references 2016-09-20 20:31:56 +09:00
7c49ab4f04 Added capability to store functions
EC::Manager can now store functions similar to functions
given to EC::Manager::forMatchingSignature.
2016-09-20 20:07:28 +09:00
ab2209b698 Fixed bug where deleted entities retain info 2016-08-30 17:34:34 +09:00
74ecae5dff Temporary(?) bugfix 2016-08-28 16:11:23 +09:00
428df3f1ab Fixed not working as cmake subproject 2016-08-27 13:32:32 +09:00
646cb89157 Fixed missing include 2016-04-20 22:18:25 +09:00
816e596878 Added missing includes 2016-04-20 21:59:47 +09:00
b2355248be Fixed include gtest on nonstanndard gtest install 2016-04-11 14:59:56 +09:00
2a11d1e86c Added note about manager's addComponent
AddComponent overwrites an already existing component
if it exists.
2016-04-06 19:35:24 +09:00
577132554e Added support for components of type UniquePtr 2016-04-06 19:32:30 +09:00
6fbdbcebde Updated .gitlab-ci.yml 2016-03-19 01:05:43 +09:00
c4700ee9bd Updated .gitlab-ci.yml 2016-03-19 00:59:30 +09:00
0cdd86bde8 Updated .gitlab-ci.yml 2016-03-19 00:53:40 +09:00
d984d2cde9 Updated .gitlab-ci.yml 2016-03-19 00:47:04 +09:00