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

mlange-42 / arche / 4873167893

03 May 2023 02:36PM CUT coverage: 100.0%. Remained the same
4873167893

push

github

GitHub
Batch-exchange and add with target (#264)

163 of 163 new or added lines in 7 files covered. (100.0%)

3657 of 3657 relevant lines covered (100.0%)

100168.69 hits per line

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

100.0
/ecs/batch.go
1
package ecs
2

3
// Batch is a helper to perform batched operations on the world.
4
//
5
// Create using [World.Batch].
6
type Batch struct {
7
        world *World
8
}
9

10
// Add adds components to many entities, matching a filter.
11
//
12
// If the callback argument is given, it is called with a [Query] over the affected entities,
13
// one Query for each affected archetype.
14
//
15
// Panics:
16
//   - when called with components that can't be added because they are already present.
17
//   - when called on a locked world. Do not use during [Query] iteration!
18
//
19
// See also [World.Exchange].
20
func (b *Batch) Add(filter Filter, callback func(Query), comps ...ID) {
1✔
21
        b.world.exchangeBatch(filter, comps, nil, callback)
1✔
22
}
1✔
23

24
// Remove removes components from many entities, matching a filter.
25
//
26
// If the callback argument is given, it is called with a [Query] over the affected entities,
27
// one Query for each affected archetype.
28
//
29
// Panics:
30
//   - when called with components that can't be removed because they are not present.
31
//   - when called on a locked world. Do not use during [Query] iteration!
32
//
33
// See also [World.Exchange].
34
func (b *Batch) Remove(filter Filter, callback func(Query), comps ...ID) {
1✔
35
        b.world.exchangeBatch(filter, nil, comps, callback)
1✔
36
}
1✔
37

38
// Exchange exchanges components for many entities, matching a filter.
39
//
40
// If the callback argument is given, it is called with a [Query] over the affected entities,
41
// one Query for each affected archetype.
42
//
43
// Panics:
44
//   - when called with components that can't be added or removed because they are already present/not present, respectively.
45
//   - when called on a locked world. Do not use during [Query] iteration!
46
//
47
// See also [World.Exchange].
48
func (b *Batch) Exchange(filter Filter, add []ID, rem []ID, callback func(Query)) {
5✔
49
        b.world.exchangeBatch(filter, add, rem, callback)
5✔
50
}
5✔
51

52
// RemoveEntities removes and recycles all entities matching a filter.
53
//
54
// Returns the number of removed entities.
55
//
56
// Panics when called on a locked world.
57
// Do not use during [Query] iteration!
58
func (b *Batch) RemoveEntities(filter Filter) int {
25,010✔
59
        return b.world.removeEntities(filter)
25,010✔
60
}
25,010✔
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