]> git.lizzy.rs Git - mt.git/blob - nodedef.go
Add WaitGroup to SerializePkt
[mt.git] / nodedef.go
1 package mt
2
3 import "image/color"
4
5 type Param1Type uint8
6
7 const (
8         P1Nothing Param1Type = iota
9         P1Light
10 )
11
12 //go:generate stringer -trimprefix P1 -type Param1Type
13
14 type Param2Type uint8
15
16 const (
17         P2Nibble Param2Type = iota
18         P2Byte
19         P2Flowing
20         P2FaceDir
21         P2Mounted
22         P2Leveled
23         P2Rotation
24         P2Mesh
25         P2Color
26         P2ColorFaceDir
27         P2ColorMounted
28         P2GlassLikeLevel
29         P2ColorRotation
30 )
31
32 //go:generate stringer -trimprefix P2 -type Param2Type
33
34 // A DrawType specifies how a node is drawn.
35 type DrawType uint8
36
37 const (
38         DrawCube DrawType = iota
39         DrawNothing
40         DrawLiquid
41         DrawFlowing
42         DrawLikeGlass
43         DrawAllFaces
44         DrawAllFacesOpt
45         DrawTorch
46         DrawSign
47         DrawPlant
48         DrawFence
49         DrawRail
50         DrawNodeBox
51         DrawGlassFrame
52         DrawFire
53         DrawGlassFrameOpt
54         DrawMesh
55         DrawRootedPlant
56 )
57
58 //go:generate stringer -trimprefix Draw -type DrawType
59
60 type WaveType uint8
61
62 const (
63         NotWaving    WaveType = iota
64         PlantWaving           // Only top waves from side to side.
65         LeafWaving            // Wave side to side.
66         LiquidWaving          // Wave up and down.
67 )
68
69 //go:generate stringer -type WaveType
70
71 type LiquidType uint8
72
73 const (
74         NotALiquid LiquidType = iota
75         FlowingLiquid
76         LiquidSrc
77 )
78
79 //go:generate stringer -type LiquidType
80
81 // AlphaUse specifies how the alpha channel of a texture is used.
82 type AlphaUse uint8
83
84 const (
85         Blend AlphaUse = iota
86         Mask           // "Rounded" to either fully opaque or transparent.
87         Opaque
88         Legacy
89 )
90
91 //go:generate stringer -type AlphaUse
92
93 type NodeDef struct {
94         Param0 Content
95
96         //mt:lenhdr 16
97
98         //mt:const uint8(13)
99
100         Name   string
101         Groups []Group
102
103         P1Type   Param1Type
104         P2Type   Param2Type
105         DrawType DrawType
106
107         Mesh  string
108         Scale float32
109         //mt:const uint8(6)
110         Tiles        [6]TileDef
111         OverlayTiles [6]TileDef
112         //mt:const uint8(6)
113         SpecialTiles [6]TileDef
114
115         Color   color.NRGBA
116         Palette Texture
117
118         Waving       WaveType
119         ConnectSides uint8
120         ConnectTo    []Content
121         InsideTint   color.NRGBA
122         Level        uint8 // Must be < 128.
123
124         Translucent bool // Sunlight is scattered and becomes normal light.
125         Transparent bool // Sunlight isn't scattered.
126         LightSrc    uint8
127
128         GndContent   bool
129         Collides     bool
130         Pointable    bool
131         Diggable     bool
132         Climbable    bool
133         Replaceable  bool
134         OnRightClick bool
135
136         DmgPerSec int32
137
138         LiquidType   LiquidType
139         FlowingAlt   string
140         SrcAlt       string
141         Viscosity    uint8 // 0-7
142         LiqRenewable bool
143         FlowRange    uint8
144         DrownDmg     uint8
145         Floodable    bool
146
147         DrawBox, ColBox, SelBox NodeBox
148
149         FootstepSnd, DiggingSnd, DugSnd SoundDef
150
151         LegacyFaceDir bool
152         LegacyMounted bool
153
154         DigPredict string
155
156         MaxLvl uint8
157
158         AlphaUse
159
160         MoveResistance uint8
161
162         LiquidMovePhysics bool
163
164         //mt:end
165 }
166
167 func BuiltinNodeDefs(n int) map[Content]NodeDef {
168         defs := make(map[Content]NodeDef, 3+n)
169         defs[Unknown] = NodeDef{
170                 Name: "unknown",
171         }
172         defs[Air] = NodeDef{
173                 Name:        "air",
174                 DrawType:    DrawNothing,
175                 P1Type:      P1Light,
176                 Translucent: true,
177                 Transparent: true,
178                 Replaceable: true,
179                 Floodable:   true,
180                 GndContent:  true,
181         }
182         defs[Ignore] = NodeDef{
183                 Name:        "ignore",
184                 DrawType:    DrawNothing,
185                 Replaceable: true,
186                 GndContent:  true,
187         }
188         return defs
189 }