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