summaryrefslogtreecommitdiff
path: root/nodedef.go
blob: 95bab83b259641ed79e9f8405ab0fee3c449aafe (plain) (blame)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package mt

import "image/color"

type Param1Type uint8

const (
	P1Nothing Param1Type = iota
	P1Light
)

//go:generate stringer -trimprefix P1 -type Param1Type

type Param2Type uint8

const (
	P2Nibble Param2Type = iota
	P2Byte
	P2Flowing
	P2FaceDir
	P2Mounted
	P2Leveled
	P2Rotation
	P2Mesh
	P2Color
	P2ColorFaceDir
	P2ColorMounted
	P2GlassLikeLevel
	P2ColorRotation
)

//go:generate stringer -trimprefix P2 -type Param2Type

// A DrawType specifies how a node is drawn.
type DrawType uint8

const (
	DrawCube DrawType = iota
	DrawNothing
	DrawLiquid
	DrawFlowing
	DrawLikeGlass
	DrawAllFaces
	DrawAllFacesOpt
	DrawTorch
	DrawSign
	DrawPlant
	DrawFence
	DrawRail
	DrawNodeBox
	DrawGlassFrame
	DrawFire
	DrawGlassFrameOpt
	DrawMesh
	DrawRootedPlant
)

//go:generate stringer -trimprefix Draw -type DrawType

type WaveType uint8

const (
	NotWaving    WaveType = iota
	PlantWaving           // Only top waves from side to side.
	LeafWaving            // Wave side to side.
	LiquidWaving          // Wave up and down.
)

//go:generate stringer -type WaveType

type LiquidType uint8

const (
	NotALiquid LiquidType = iota
	FlowingLiquid
	LiquidSrc
)

//go:generate stringer -type LiquidType

// AlphaUse specifies how the alpha channel of a texture is used.
type AlphaUse uint8

const (
	Blend AlphaUse = iota
	Mask           // "Rounded" to either fully opaque or transparent.
	Opaque
	Legacy
)

//go:generate stringer -type AlphaUse

type NodeDef struct {
	Param0 Content

	//mt:lenhdr 16

	//mt:const uint8(13)

	Name   string
	Groups []Group

	P1Type   Param1Type
	P2Type   Param2Type
	DrawType DrawType

	Mesh  string
	Scale float32
	//mt:const uint8(6)
	Tiles        [6]TileDef
	OverlayTiles [6]TileDef
	//mt:const uint8(6)
	SpecialTiles [6]TileDef

	Color   color.NRGBA
	Palette Texture

	Waving       WaveType
	ConnectSides uint8
	ConnectTo    []Content
	InsideTint   color.NRGBA
	Level        uint8 // Must be < 128.

	Translucent bool // Sunlight is scattered and becomes normal light.
	Transparent bool // Sunlight isn't scattered.
	LightSrc    uint8

	GndContent   bool
	Collides     bool
	PointType    PointabilityType
	Diggable     bool
	Climbable    bool
	Replaceable  bool
	OnRightClick bool

	DmgPerSec int32

	LiquidType   LiquidType
	FlowingAlt   string
	SrcAlt       string
	Viscosity    uint8 // 0-7
	LiqRenewable bool
	FlowRange    uint8
	DrownDmg     uint8
	Floodable    bool

	DrawBox, ColBox, SelBox NodeBox

	FootstepSnd, DiggingSnd, DugSnd SoundDef

	LegacyFaceDir bool
	LegacyMounted bool

	DigPredict string

	MaxLvl uint8

	AlphaUse

	MoveResistance    uint8
	LiquidMovePhysics bool
	InsideTintShaded  bool

	//mt:end
}

func BuiltinNodeDefs(n int) map[Content]NodeDef {
	defs := make(map[Content]NodeDef, 3+n)
	defs[Unknown] = NodeDef{
		Name: "unknown",
	}
	defs[Air] = NodeDef{
		Name:        "air",
		DrawType:    DrawNothing,
		P1Type:      P1Light,
		Translucent: true,
		Transparent: true,
		Replaceable: true,
		Floodable:   true,
		GndContent:  true,
	}
	defs[Ignore] = NodeDef{
		Name:        "ignore",
		DrawType:    DrawNothing,
		Replaceable: true,
		GndContent:  true,
	}
	return defs
}