• 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/event.go
1
package ecs
2

3
// EntityEvent contains information about component changes to an [Entity].
4
//
5
// To receive change events, register a function func(e *EntityEvent) with [World.SetListener].
6
//
7
// Events notified are entity creation, removal and changes to the component composition.
8
// Events are emitted immediately after the change is applied.
9
//
10
// Except for removed entities, events are always fired when the [World] is in an unlocked state.
11
// Events for removed entities are fired right before removal of the entity,
12
// to allow for inspection of it's components.
13
// Therefore, the [World] is in a locked state during entity removal events.
14
//
15
// Events for batch-creation of entities using [World.Batch] are fired after all entities are created.
16
// For batch methods that return a [Query], events are fired after the [Query] is closed (or fully iterated).
17
// This allows the [World] to be in an unlocked state, and notifies after potential entity initialization.
18
//
19
// Note that the event pointer received by the listener function should not be stored,
20
// as the instance behind the pointer might be reused for further notifications.
21
type EntityEvent struct {
22
        Entity                  Entity // The entity that was changed.
23
        OldMask, NewMask        Mask   // The old and new component masks.
24
        Added, Removed, Current []ID   // Components added, removed, and after the change. DO NOT MODIFY!
25
        AddedRemoved            int    // Whether the entity itself was added (> 0), removed (< 0), or only changed (= 0).
26
}
27

28
// EntityAdded reports whether the entity was newly added.
29
func (e *EntityEvent) EntityAdded() bool {
3✔
30
        return e.AddedRemoved > 0
3✔
31
}
3✔
32

33
// EntityRemoved reports whether the entity was removed.
34
func (e *EntityEvent) EntityRemoved() bool {
1,106✔
35
        return e.AddedRemoved < 0
1,106✔
36
}
1,106✔
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