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

mlange-42 / arche / 4874413404

03 May 2023 04:46PM CUT coverage: 100.0%. Remained the same
4874413404

push

github

GitHub
Batch-set entity relation, RelationFilter to function (#265)

137 of 137 new or added lines in 6 files covered. (100.0%)

3764 of 3764 relevant lines covered (100.0%)

97404.29 hits per line

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

100.0
/ecs/entity.go
1
package ecs
2

3
import "reflect"
4

5
// Reflection type of an [Entity].
6
var entityType = reflect.TypeOf(Entity{})
7

8
// Size of an [Entity] in memory, in bytes.
9
var entitySize = entityType.Size()
10

11
// Size of an [entityIndex] in memory.
12
var entityIndexSize = reflect.TypeOf(entityIndex{}).Size()
13

14
// Entity identifier.
15
// Holds an entity ID and it's generation for recycling.
16
//
17
// Entities are only created via the [World], using [World.NewEntity] or [World.NewEntityWith].
18
// Batch creation of entities is possible via [Builder].
19
//
20
// Entities are intended to be stored and passed around via copy, not via pointers.
21
type Entity struct {
22
        id  eid    // Entity ID
23
        gen uint16 // Entity generation
24
}
25

26
// newEntity creates a new Entity.
27
func newEntity(id eid) Entity {
259,385✔
28
        return Entity{id, 0}
259,385✔
29
}
259,385✔
30

31
// newEntityGen creates a new Entity with a given generation.
32
func newEntityGen(id eid, gen uint16) Entity {
16✔
33
        return Entity{id, gen}
16✔
34
}
16✔
35

36
// IsZero returns whether this entity is the reserved zero entity.
37
func (e Entity) IsZero() bool {
87,905✔
38
        return e.id == 0
87,905✔
39
}
87,905✔
40

41
// entityIndex indicates where an entity is currently stored.
42
type entityIndex struct {
43
        arch     *archetype // Entity's current archetype
44
        index    uintptr    // Entity's current index in the archetype
45
        isTarget bool
46
}
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