Repository navigation
0.7 filters #49
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
Merged
Merged
0.7 filters #49
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9b953d3
feat: extract FilteredStream with two-delegate runners
thygrrr 09ad2f0
test: close statement-level coverage gaps in FilteredStream
thygrrr 7738885
feat: stryker mutation test improvements
thygrrr 8633312
feat: stryker mutation test improvements
thygrrr 0fed5f9
chore: review issues addressed
thygrrr a5873f6
chore: warnings as errors!
thygrrr 8f542ca
chore: review issues
thygrrr 0903e40
chore: review issues
thygrrr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| title: Has & Not | ||
| layout: doc | ||
| outline: [2, 3] | ||
| order: 1 | ||
| description: 'Archetype-level Stream filters in fennecs: Has and Not clauses on a FilteredStream prune whole Archetypes by component presence before iteration starts.' | ||
| --- | ||
|
|
||
| # Has & Not Archetype Filters | ||
|
|
||
| The coarse (and fastest) way to narrow a Stream: additional component clauses that prune whole **Archetypes** before iteration even starts. Entire tables of Entities are skipped in one go – no per-Entity work at all. | ||
|
|
||
| ## Creating a FilteredStream | ||
|
|
||
| `Stream<>.Has(...)` and `Stream<>.Not(...)` each return a `FilteredStream<>` applying the clause for all its operations. The original Stream and the underlying Query are untouched. | ||
|
|
||
| ```csharp | ||
| var stream = world.Stream<Position, Velocity>(); | ||
|
|
||
| var filtered = stream | ||
| .Has(Comp<Alive>.Plain) | ||
| .Not(Comp<OneRing>.Matching(TheOneRing)); | ||
| ``` | ||
|
|
||
| ## Has Clause | ||
| This works exactly like an additional `Has<>` clause on a QueryBuilder. | ||
|
|
||
| > `includes only` Entities whose Archetype has **all** of the given components or relations. Multiple expressions – whether passed in one call or chained – combine to a logical `A AND B AND C`. | ||
|
|
||
| ## Not Clause | ||
| This works exactly like an additional `Not<>` clause on a QueryBuilder. | ||
|
|
||
| > `excludes` any Entities whose Archetype has **any** of the given components. Multiple expressions can be compared to a logical `NOT (A OR B OR C)`, aka. `(NOT A) AND (NOT B) AND (NOT C)`. | ||
|
|
||
| ## Chaining Accumulates | ||
|
|
||
| `Has` and `Not` accumulate on a `FilteredStream` – each call unions its expressions into the existing clause: | ||
|
|
||
| ```csharp | ||
| var picky = stream | ||
| .Has(Comp<Alive>.Plain) | ||
| .Has(Comp<Hungry>.Plain) // same as .Has(Comp<Alive>.Plain, Comp<Hungry>.Plain) | ||
| .Not(Comp<Dead>.Plain, Comp<Sleeping>.Plain); | ||
| ``` | ||
|
|
||
| ::: tip :neofox_thumbsup: Need to filter by component *values* instead? | ||
| Has & Not decide by component *presence*. To skip Entities based on what their components *contain*, add a [Where](Where.md) lambda filter on top. | ||
| ::: | ||
|
|
||
| ## Future Features | ||
| The `Comp<T>` expression API used to create the necessary filter expressions is likely to have its API reviewed and tightened, to make the syntax more readable and easier to use. It might get unified into a Mask-like system as used internally to power QueryBuilders. |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.