/
TintStruct.go
51 lines (39 loc) · 972 Bytes
/
TintStruct.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
package eqStruct
import (
"github.com/nomoresecretz/ghoeq-common/proto/eqstruct"
"google.golang.org/protobuf/proto"
)
type TintStruct struct {
Blue, Green, Red uint8
Use uint8
bPointer int
}
func (p *TintStruct) EQType() EQType { return EQT_TintStruct }
func (p *TintStruct) bp() *int { return &p.bPointer }
func (p *TintStruct) Unmarshal(b []byte) (int, error) {
p.bPointer = 0
if err := EQRead(b, p, &p.Blue, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Green, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Red, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Use, 0); err != nil {
return 0, err
}
return p.bPointer, nil
}
func (p *TintStruct) Proto() *eqstruct.TintStruct {
return &eqstruct.TintStruct{
Red: uint32(p.Red),
Blue: uint32(p.Blue),
Green: uint32(p.Green),
Use: uint32(p.Use),
}
}
func (p *TintStruct) ProtoMess() proto.Message {
return p.Proto()
}