|
|
@@ -15,7 +15,7 @@ ECS is an architectural pattern used mostly in game development. For further det
|
|
|
|
|
|
## Code Example
|
|
|
|
|
|
-```
|
|
|
+```cpp
|
|
|
#include <iostream>
|
|
|
#include <registry.hpp>
|
|
|
|
|
|
@@ -145,7 +145,9 @@ CMake version 3.4 or later is mandatory to compile the tests, you don't have to
|
|
|
`EnTT` is a header-only library. This means that including the `registry.hpp` header is enough to use it.<br/>
|
|
|
It's a matter of adding the following line at the top of a file:
|
|
|
|
|
|
- #include <registry.hpp>
|
|
|
+```cpp
|
|
|
+#include <registry.hpp>
|
|
|
+```
|
|
|
|
|
|
Then pass the proper `-I` argument to the compiler to add the `src` directory to the include paths.<br/>
|
|
|
|
|
|
@@ -164,7 +166,7 @@ There are three options to instantiate your own registry:
|
|
|
|
|
|
* By using the default one:
|
|
|
|
|
|
- ```
|
|
|
+ ```cpp
|
|
|
auto registry = entt::DefaultRegistry<Components...>{args...};
|
|
|
```
|
|
|
|
|
|
@@ -172,7 +174,7 @@ There are three options to instantiate your own registry:
|
|
|
|
|
|
* By using the standard one:
|
|
|
|
|
|
- ```
|
|
|
+ ```cpp
|
|
|
auto registry = entt::StandardRegistry<std::uint16_t, Components...>{args...};
|
|
|
```
|
|
|
|
|
|
@@ -180,7 +182,7 @@ There are three options to instantiate your own registry:
|
|
|
|
|
|
* By using your own pool:
|
|
|
|
|
|
- ```
|
|
|
+ ```cpp
|
|
|
auto registry = entt::Registry<DesiredEntityType, YourOwnPool<Components...>>{args...};
|
|
|
```
|
|
|
|
|
|
@@ -225,7 +227,7 @@ There are three different kinds of view, each one with a slighlty different inte
|
|
|
|
|
|
All of them are iterable. In other terms they have `begin` and `end` member functions that are suitable for a range-based for loop:
|
|
|
|
|
|
-```
|
|
|
+```cpp
|
|
|
auto view = registry.view<Position, Velocity>();
|
|
|
|
|
|
for(auto entity: view) {
|
|
|
@@ -253,7 +255,7 @@ The multi component view has an additional member function:
|
|
|
A filtered view is nothing more than a multi component view with an additional set of components that act as filters.<br/>
|
|
|
Users can create filtered views either from a single component view or from a multi component view by means of the `exclude` member function:
|
|
|
|
|
|
-```
|
|
|
+```cpp
|
|
|
auto view = registry.view<Position>().exclude<Velocity>();
|
|
|
|
|
|
for(auto entity: view) {
|
|
|
@@ -295,7 +297,7 @@ concurrently on a separate thread if needed.
|
|
|
Custom pools for a given component can be defined as a specialization of the class template `ComponentPool`.<br/>
|
|
|
In particular:
|
|
|
|
|
|
-```
|
|
|
+```cpp
|
|
|
template<>
|
|
|
struct ComponentPool<Entity, MyComponent> final {
|
|
|
// ...
|
|
|
@@ -327,7 +329,7 @@ In cases when the per-component pools are not good enough, the registry can be i
|
|
|
In other terms, `entt::Registry` has a template template parameter that can be used to provide both the pool and the list of
|
|
|
components:
|
|
|
|
|
|
-```
|
|
|
+```cpp
|
|
|
auto registry = entt::Registry<Entity, MyCustomPool<Component1, Component2>>{};
|
|
|
```
|
|
|
|