• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / arche / 4725747591

17 Apr 2023 08:58PM CUT coverage: 100.0%. Remained the same
4725747591

push

github

GitHub
Add parallel simulations example (#223)

2729 of 2729 relevant lines covered (100.0%)

4272.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/ecs/filter.go
1
package ecs
2

3
// Filter is the interface for logic filters.
4
// Filters are required to query entities using [World.Query].
5
//
6
// See [Mask] and [MaskFilter] for basic filters.
7
// For type-safe generics queries, see package [github.com/mlange-42/arche/generic].
8
// For advanced filtering, see package [github.com/mlange-42/arche/filter].
9
type Filter interface {
10
        // Matches the filter against a bitmask, i.e. a component composition.
11
        Matches(bits Mask) bool
12
}
13

14
// MaskFilter is a [Filter] for including and excluding certain components.
15
// See [All] and [Mask.Without].
16
type MaskFilter struct {
17
        Include Mask // Components to include.
18
        Exclude Mask // Components to exclude.
19
}
20

21
// Matches matches a filter against a mask.
22
func (f *MaskFilter) Matches(bits Mask) bool {
55✔
23
        return bits.Contains(f.Include) && (f.Exclude.IsZero() || !bits.ContainsAny(f.Exclude))
55✔
24
}
55✔
25

26
// CachedFilter is a filter that is cached by the world.
27
//
28
// Create it using [Cache.Register].
29
type CachedFilter struct {
30
        filter Filter
31
        id     ID
32
}
33

34
// Matches matches a filter against a mask.
35
func (f *CachedFilter) Matches(bits Mask) bool {
2✔
36
        return f.filter.Matches(bits)
2✔
37
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc