-
Notifications
You must be signed in to change notification settings - Fork 0
/
opRotate.go
51 lines (43 loc) · 1003 Bytes
/
opRotate.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 main
import (
"strconv"
"time"
"github.com/vikebot/vbgs/vbge"
)
type rotateObj struct {
Angle *string `json:"angle"`
}
type rotatePacket struct {
Type string `json:"type"`
Obj rotateObj `json:"obj"`
}
func opRotate(c *ntcpclient, packet rotatePacket) {
// c.Player.Rl.Rotate.Take()
time.Sleep(500 * time.Millisecond)
if packet.Obj.Angle == nil {
c.Respond("Invalid packet. '.obj.angle' missing")
return
}
angle := *packet.Obj.Angle
if !vbge.IsAngle(angle) {
c.RespondFmt("Invalid packet. '%s' is not a valid value for '.obj.angle'", angle)
return
}
ngl := c.Player.Rotate(angle)
c.RespondNil()
for _, entity := range ngl {
dist.GetClient(strconv.Itoa(entity.Player.UserID)).Push("game",
struct {
GRID string `json:"grid"`
Type string `json:"type"`
Angle string `json:"angle"`
Loc *vbge.ARLocation `json:"loc"`
}{
c.Player.GRenderID,
"rotate",
angle,
entity.ARLoc,
},
c.Log)
}
}