forked from yanchunlei/SC-Chinese
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlocks.cs
294 lines (268 loc) · 7.98 KB
/
Blocks.cs
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
using Engine;
using Game;
using System.Collections.Generic;
using System.Linq;
namespace ZHCN
{
public class PumpkinBlock : Game.PumpkinBlock
{
public new const int Index = 131;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
int size = GetSize(Terrain.ExtractData(value));
if (size >= 7)
{
return "南瓜";
}
return "青南瓜";
}
}
public class RottenPumpkinBlock : BasePumpkinBlock
{
public const int Index = 244;
public RottenPumpkinBlock() : base(true)
{
}
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
int size = GetSize(Terrain.ExtractData(value));
if (size >= 7)
{
return "烂南瓜";
}
return "烂青南瓜";
}
}
public class ClothingBlock : Game.ClothingBlock
{
public new const int Index = 203;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
int data = Terrain.ExtractData(value);
ClothingData clothingData = GetClothingData(data);
int clothingColor = GetClothingColor(data);
if (clothingColor != 0)
{
return SubsystemPalette.GetName(subsystemTerrain, clothingColor, "染色 " + clothingData.DisplayName);
}
return clothingData.DisplayName;
}
public override CraftingRecipe GetAdHocCraftingRecipe(SubsystemTerrain terrain, string[] ingredients, float heatLevel)
{
if (heatLevel < 1f)
{
return null;
}
var list = (from i in ingredients
where !string.IsNullOrEmpty(i)
select i).ToList();
if (list.Count == 2)
{
int num = 0;
int num2 = 0;
int num3 = 0;
foreach (string item in list)
{
CraftingRecipesManager.DecodeIngredient(item, out string craftingId, out int? data);
if (craftingId == BlocksManager.Blocks[203].CraftingId)
{
num3 = Terrain.MakeBlockValue(203, 0, data ?? 0);
}
else if (craftingId == BlocksManager.Blocks[129].CraftingId)
{
num = Terrain.MakeBlockValue(129, 0, data ?? 0);
}
else if (craftingId == BlocksManager.Blocks[128].CraftingId)
{
num2 = Terrain.MakeBlockValue(128, 0, data ?? 0);
}
}
if (num != 0 && num3 != 0)
{
int data2 = Terrain.ExtractData(num3);
int clothingColor = GetClothingColor(data2);
int clothingIndex = GetClothingIndex(data2);
bool canBeDyed = GetClothingData(data2).CanBeDyed;
int damage = BlocksManager.Blocks[203].GetDamage(num3);
int color = Game.PaintBucketBlock.GetColor(Terrain.ExtractData(num));
int damage2 = BlocksManager.Blocks[129].GetDamage(num);
Block block = BlocksManager.Blocks[129];
Block block2 = BlocksManager.Blocks[203];
if (!canBeDyed)
{
return null;
}
int num4 = Game.PaintBucketBlock.CombineColors(clothingColor, color);
if (num4 != clothingColor)
{
return new CraftingRecipe
{
ResultCount = 1,
ResultValue = block2.SetDamage(Terrain.MakeBlockValue(203, 0, SetClothingIndex(SetClothingColor(0, num4), clothingIndex)), damage),
RemainsCount = 1,
RemainsValue = BlocksManager.DamageItem(Terrain.MakeBlockValue(129, 0, color), damage2 + MathUtils.Max(block.Durability / 4, 1)),
RequiredHeatLevel = 1f,
Description = $"染色服装 {SubsystemPalette.GetName(terrain, color, null)}",
Ingredients = (string[])ingredients.Clone()
};
}
}
if (num2 != 0 && num3 != 0)
{
int data3 = Terrain.ExtractData(num3);
int clothingColor2 = GetClothingColor(data3);
int clothingIndex2 = GetClothingIndex(data3);
bool canBeDyed2 = GetClothingData(data3).CanBeDyed;
int damage3 = BlocksManager.Blocks[203].GetDamage(num3);
int damage4 = BlocksManager.Blocks[128].GetDamage(num2);
Block block3 = BlocksManager.Blocks[128];
Block block4 = BlocksManager.Blocks[203];
if (!canBeDyed2)
{
return null;
}
if (clothingColor2 != 0)
{
return new CraftingRecipe
{
ResultCount = 1,
ResultValue = block4.SetDamage(Terrain.MakeBlockValue(203, 0, SetClothingIndex(SetClothingColor(0, 0), clothingIndex2)), damage3),
RemainsCount = 1,
RemainsValue = BlocksManager.DamageItem(Terrain.MakeBlockValue(128, 0, 0), damage4 + MathUtils.Max(block3.Durability / 4, 1)),
RequiredHeatLevel = 1f,
Description = "未染色服装",
Ingredients = (string[])ingredients.Clone()
};
}
}
}
return null;
}
}
public class CottonBlock : Game.CottonBlock
{
public new const int Index = 204;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
if (!GetIsWild(Terrain.ExtractData(value)))
{
return "棉花";
}
return "野棉花";
}
}
public class EggBlock : Game.EggBlock
{
public new const int Index = 118;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
EggType eggType = GetEggType(Terrain.ExtractData(value));
int data = Terrain.ExtractData(value);
bool isCooked = GetIsCooked(data);
bool isLaid = GetIsLaid(data);
if (isCooked)
{
return "熟的 " + eggType.DisplayName;
}
if (!isLaid)
{
return eggType.DisplayName;
}
return "生的 " + eggType.DisplayName;
}
}
public class FireworksBlock : Game.FireworksBlock
{
public new const int Index = 215;
public new static readonly string[] ShapeDisplayNames = new string[8]
{
"小型爆炸",
"大型爆炸",
"圆环",
"圆盘",
"球形",
"短轨迹",
"长轨迹",
"平轨迹"
};
public new static readonly string[] FireworksColorDisplayNames = new string[8]
{
"白色",
"青色",
"红色",
"蓝色",
"黄色",
"绿色",
"橙色",
"紫色"
};
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
int data = Terrain.ExtractData(value);
int color = GetColor(data);
Shape shape = GetShape(data);
int altitude = GetAltitude(data);
bool flickering = GetFlickering(data);
return string.Format("烟花 {0} {1}{2} ({3})", FireworksColorDisplayNames[color], flickering ? "闪烁 " : null, ShapeDisplayNames[(int)shape], (altitude == 0) ? "低" : "高");
}
}
public class LightbulbBlock : Game.LightbulbBlock
{
public new const int Index = 139;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
return SubsystemPalette.GetName(subsystemTerrain, GetColor(Terrain.ExtractData(value)), "电灯");
}
}
public class PaintBucketBlock : Game.PaintBucketBlock
{
public new const int Index = 129;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
return SubsystemPalette.GetName(subsystemTerrain, GetColor(Terrain.ExtractData(value)), "油漆桶");
}
}
public class SaplingBlock : Game.SaplingBlock
{
public new const int Index = 119;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
switch (Terrain.ExtractData(value))
{
case 0: return "橡树树苗";
case 1: return "白桦树苗";
case 2: return "云杉树苗";
case 3: return "高大云杉树苗";
default: return "树苗";
}
}
}
public class SeedsBlock : Game.SeedsBlock
{
public new const int Index = 173;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
switch (Terrain.ExtractData(value))
{
case 0: return "高草种子";
case 1: return "红花种子";
case 2: return "紫花种子";
case 3: return "白花种子";
case 4: return "野黑麦种子";
case 5: return "黑麦种子";
case 6: return "棉花种子";
case 7: return "南瓜种子";
default: return string.Empty;
}
}
}
public class SevenSegmentDisplayBlock : Game.SevenSegmentDisplayBlock
{
public new const int Index = 185;
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
{
int color = GetColor(Terrain.ExtractData(value));
return LedBlock.LedColorDisplayNames[color] + " 七段显示器";
}
}
}