This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
/
example.go
106 lines (81 loc) · 1.6 KB
/
example.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
104
105
106
package ao
import (
"github.com/anon55555/mt"
"github.com/ev2-1/minetest-go"
)
// ActiveObjectS is a example for a ActiveObject interface
type ActiveObjectS struct {
AOState
ID mt.AOID
AnimSpeed float32
Attach mt.AOAttach
Props mt.AOProps
}
/*
SetID(mt.AOID)
GetID() mt.AOID
GetPos() mt.AOPos
GetBonePos(string) mt.AOBonePos
GetProps() mt.AOProps
GetArmor() []mt.Group
Intet
*/
func (ao *ActiveObjectS) SetID(id mt.AOID) {
ao.ID = id
}
func (ao *ActiveObjectS) GetID() mt.AOID {
return ao.ID
}
func (ao *ActiveObjectS) GetBonePos(str string) (p mt.AOBonePos, ok bool) {
p, ok = ao.Bones[str]
return
}
func (ao *ActiveObjectS) GetProps() mt.AOProps {
return ao.Props
}
func (ao *ActiveObjectS) Delete(DelReason) {
}
func (ao *ActiveObjectS) Interact(AOInteract) {
}
func (ao *ActiveObjectS) InitPkt(id mt.AOID, clt *minetest.Client) mt.AOInitData {
var msgs []mt.AOMsg
appendM := func(msgss ...mt.AOMsg) {
msgs = append(msgs, msgss...)
}
appendM(&mt.AOCmdProps{
Props: ao.GetProps(),
})
anim := ao.GetAnimState()
if anim.Active {
appendM(&mt.AOCmdAnim{
Anim: anim.AOAnim,
})
}
// bones:
bones := ao.GetBones()
if len(bones) != 0 {
for name, pos := range bones {
appendM(&mt.AOCmdBonePos{
Bone: name,
Pos: pos,
})
}
}
// phys
phys := ao.GetPhys()
if phys.NotDefault() {
appendM(phys.Pkt())
}
// finnal finish AO
appendM(&mt.AOCmdAttach{
Attach: mt.AOAttach{ParentID: 0, ForceVisible: true},
})
return mt.AOInitData{
IsPlayer: false,
ID: id,
Pos: ao.GetPos().Pos,
Rot: ao.GetPos().Rot,
HP: ao.GetHP(),
Msgs: msgs,
}
}