Skip to content

Commit be588d8

Browse files
committed
[docs] Extend documentation of CanToggle trait
1 parent a0b78c1 commit be588d8

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

docs/ComponentTraits.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,48 @@ assert!(e.enabled::<Position>());
8383
</ul>
8484
</div>
8585

86+
Toggling a component does not add the component to the entity. For a toggled component to be matched by a query it also needs to be added to the entity.
87+
88+
Queries can explicitly match entities that have toggle bits for a component by adding the `TOGGLE` flag:
89+
90+
<div class="flecs-snippet-tabs">
91+
<ul>
92+
<li><b class="tab-title">C</b>
93+
94+
```c
95+
ecs_query_t *q = ecs_query(world, {
96+
.terms = {{ ECS_TOGGLE | ecs_id(Position) }}
97+
});
98+
```
99+
100+
</li>
101+
<li><b class="tab-title">C++</b>
102+
103+
```cpp
104+
auto q = world.query_builder()
105+
.with<Position>().id_flags(flecs::TOGGLE)
106+
.build();
107+
```
108+
109+
</li>
110+
<li><b class="tab-title">C#</b>
111+
112+
```cs
113+
// TODO
114+
```
115+
116+
</li>
117+
<li><b class="tab-title">Rust</b>
118+
119+
```rust
120+
// TODO
121+
```
122+
123+
</li>
124+
</ul>
125+
</div>
126+
127+
86128
## Cleanup traits
87129
When entities that are used as tags, components, relationships or relationship targets are deleted, cleanup traits ensure that the store does not contain any dangling references. Any cleanup policy provides this guarantee, so while they are configurable, applications cannot configure traits that allows for dangling references.
88130

0 commit comments

Comments
 (0)