-
Notifications
You must be signed in to change notification settings - Fork 0
/
sector.go
103 lines (87 loc) · 1.72 KB
/
sector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package model
import "github.com/markel1974/godoom/engine/textures"
type Segment struct {
Start XY
End XY
Ref string
Kind int
Sector *Sector
Tag string
}
func NewSegment(ref string, sector * Sector, kind int, start XY, end XY, tag string) *Segment{
out := &Segment{
Start: start,
End: end,
Ref: ref,
Kind: kind,
Sector: sector,
Tag: tag,
}
return out
}
func (k * Segment) Copy() * Segment {
out := &Segment{
Start: k.Start,
End: k.End,
Ref: k.Ref,
Kind: k.Kind,
Sector: k.Sector,
Tag: k.Tag,
}
return out
}
func (k * Segment) SetSector(ref string, sector * Sector) {
k.Ref = ref
k.Sector = sector
}
type Sector struct {
Id string
Floor float64
Ceil float64
Segments []*Segment
Textures bool
Tag string
FloorTexture *textures.Texture
CeilTexture *textures.Texture
UpperTexture *textures.Texture
LowerTexture *textures.Texture
WallTexture *textures.Texture
usage int
compileId uint64
references map[string]bool
}
func NewSector(id string, segments []*Segment) *Sector {
s := &Sector{
Id: id,
Ceil: 0,
Floor: 0,
Segments: segments,
Textures: false,
usage: 0,
compileId: 0,
references: make(map[string]bool),
}
return s
}
func (s *Sector) Reference(compileId uint64) {
if compileId != s.compileId {
s.compileId = compileId
s.usage = 0
s.references = make(map[string]bool)
} else {
s.usage++
}
}
func (s * Sector) GetCompileId() uint64{
return s.compileId
}
func (s *Sector) GetUsage() int {
return s.usage
}
func (s *Sector) Add(id string) {
s.references[id] = true
}
func (s *Sector) Has(id string) bool {
_, ok := s.references[id]
return ok
}