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

mlange-42 / ark / 13665290355

04 Mar 2025 11:54PM CUT coverage: 99.316% (+0.02%) from 99.297%
13665290355

Pull #132

github

web-flow
Merge 22ed5e257 into 5e35511a8
Pull Request #132: Check relation targets in filters and component getters

30 of 30 new or added lines in 5 files covered. (100.0%)

5804 of 5844 relevant lines covered (99.32%)

33896.1 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 "encoding/json"
4

5
type entityID uint32
6

7
var entityType = typeOf[Entity]()
8
var entitySize = sizeOf(entityType)
9

10
//var wildcard = Entity{1, 0}
11

12
// Entity identifier.
13
type Entity struct {
14
        id  entityID // Entity ID
15
        gen uint32   // Entity generation
16
}
17

18
func newEntity(id entityID) Entity {
8✔
19
        return Entity{id, 0}
8✔
20
}
8✔
21

22
// IsZero returns whether this entity is the reserved zero entity.
23
func (e Entity) IsZero() bool {
946✔
24
        return e.id == 0
946✔
25
}
946✔
26

27
// isWildcard returns whether this entity is the reserved wildcard entity.
28
func (e Entity) isWildcard() bool {
1✔
29
        return e.id == 1
1✔
30
}
1✔
31

32
// MarshalJSON returns a JSON representation of the entity, for serialization purposes.
33
//
34
// The JSON representation of an entity is a two-element array of entity ID and generation.
35
func (e Entity) MarshalJSON() ([]byte, error) {
1✔
36
        arr := [2]uint32{uint32(e.id), e.gen}
1✔
37
        jsonValue, _ := json.Marshal(arr) // Ignore the error, as we can be sure this works.
1✔
38
        return jsonValue, nil
1✔
39
}
1✔
40

41
// UnmarshalJSON into an entity.
42
//
43
// For serialization purposes only. Do not use this to create entities!
44
func (e *Entity) UnmarshalJSON(data []byte) error {
2✔
45
        arr := [2]uint32{}
2✔
46
        if err := json.Unmarshal(data, &arr); err != nil {
3✔
47
                return err
1✔
48
        }
1✔
49
        e.id = entityID(arr[0])
1✔
50
        e.gen = arr[1]
1✔
51

1✔
52
        return nil
1✔
53
}
54

55
// entityIndex denotes an entity's location by table and row index.
56
type entityIndex struct {
57
        table tableID
58
        row   uint32
59
}
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