返回提交历史
Modified
art-tools/generate-magnetic-conveyor-border.ps1
+92
-27
Modified
scripts/blocks/磁铜传送带.js
+47
-18
Modified
sprites/books/磁铜传送带/磁铜传送带-border.png
+0
-0
Added
sprites/books/磁铜传送带/磁铜传送带-corner.png
+0
-0
XFEstudio/MCIndustry
修复部分传送带问题
6e301ce
代码差异
4 个文件
+139
-45
@@ -1,57 +1,122 @@
1
1
param(
2
2
[Parameter(Mandatory = $true)]
3
[string]$OutputPath
3
[string]$BorderPath,
4
5
[Parameter(Mandatory = $true)]
6
[string]$CornerPath
4
7
)
5
8
6
9
$ErrorActionPreference = 'Stop'
7
10
8
11
Add-Type -AssemblyName System.Drawing
9
12
10
$outputDirectory = Split-Path -Parent $OutputPath
11
12
13
$palette = @{
13
InnerDark = [System.Drawing.ColorTranslator]::FromHtml('#2b174f')
14
InnerGlow = [System.Drawing.ColorTranslator]::FromHtml('#9558ff')
15
Purple = [System.Drawing.ColorTranslator]::FromHtml('#6230bd')
16
CopperDark = [System.Drawing.ColorTranslator]::FromHtml('#85483d')
17
Copper = [System.Drawing.ColorTranslator]::FromHtml('#c77762')
18
CopperGlow = [System.Drawing.ColorTranslator]::FromHtml('#e59a78')
14
Background = [System.Drawing.ColorTranslator]::FromHtml('#2b2244')
15
CornerShadow = [System.Drawing.ColorTranslator]::FromHtml('#302748')
16
CornerOuter = [System.Drawing.ColorTranslator]::FromHtml('#595155')
17
CornerInner = [System.Drawing.ColorTranslator]::FromHtml('#6b5f86')
18
CornerLight = [System.Drawing.ColorTranslator]::FromHtml('#75688e')
19
InnerDark = [System.Drawing.ColorTranslator]::FromHtml('#24183d')
20
InnerGlow = [System.Drawing.ColorTranslator]::FromHtml('#9a63f0')
21
Purple = [System.Drawing.ColorTranslator]::FromHtml('#6339ad')
22
CopperDark = [System.Drawing.ColorTranslator]::FromHtml('#704039')
23
Copper = [System.Drawing.ColorTranslator]::FromHtml('#b96959')
24
CopperGlow = [System.Drawing.ColorTranslator]::FromHtml('#dc8b6d')
25
OuterDark = [System.Drawing.ColorTranslator]::FromHtml('#472b32')
19
26
}
20
27
21
$bitmap = [System.Drawing.Bitmap]::new(
22
6,
28
$border = [System.Drawing.Bitmap]::new(
29
5,
23
30
32,
24
31
[System.Drawing.Imaging.PixelFormat]::Format32bppArgb
25
32
)
26
33
27
34
try {
28
for ($y = 0; $y -lt $bitmap.Height; $y++) {
35
for ($y = 0; $y -lt $border.Height; $y++) {
29
36
$phase = $y % 8
30
37
31
$bitmap.SetPixel(0, $y, $palette.InnerDark)
32
$bitmap.SetPixel(
38
$border.SetPixel(0, $y, $palette.InnerDark)
39
$border.SetPixel(
33
40
1,
34
41
$y,
35
$(if ($phase -in 2, 3) { $palette.InnerGlow } else { $palette.Purple })
42
$(if ($phase -eq 2) { $palette.InnerGlow } else { $palette.Purple })
36
43
)
37
$bitmap.SetPixel(2, $y, $palette.Purple)
38
$bitmap.SetPixel(3, $y, $palette.CopperDark)
39
$bitmap.SetPixel(
40
4,
44
$border.SetPixel(2, $y, $palette.CopperDark)
45
$border.SetPixel(
46
3,
41
47
$y,
42
$(if ($phase -in 5, 6) { $palette.CopperGlow } else { $palette.Copper })
48
$(if ($phase -eq 5) { $palette.CopperGlow } else { $palette.Copper })
43
49
)
44
$bitmap.SetPixel(5, $y, $palette.Copper)
50
$border.SetPixel(4, $y, $palette.OuterDark)
51
}
52
53
$resolvedBorderDirectory = [System.IO.Path]::GetFullPath(
54
(Split-Path -Parent $BorderPath)
55
)
56
[System.IO.Directory]::CreateDirectory($resolvedBorderDirectory) | Out-Null
57
$border.Save(
58
[System.IO.Path]::GetFullPath($BorderPath),
59
[System.Drawing.Imaging.ImageFormat]::Png
60
)
61
} finally {
62
$border.Dispose()
63
}
64
65
$corner = [System.Drawing.Bitmap]::new(
66
32,
67
32,
68
[System.Drawing.Imaging.PixelFormat]::Format32bppArgb
69
)
70
71
try {
72
for ($y = 0; $y -lt $corner.Height; $y++) {
73
for ($x = 0; $x -lt $corner.Width; $x++) {
74
$corner.SetPixel($x, $y, $palette.Background)
75
76
$pixelX = $x + 0.5
77
$pixelY = $y + 0.5
78
79
# Canonical elbow: east + south. The bend follows the outside of
80
# the central item footprint, so a full stack cannot hide its
81
# turning point. Its endpoints retain the same in-tile spacing as
82
# the straight chevrons on the two neighbouring conveyor tiles.
83
$distance = [Math]::Abs(
84
[Math]::Sqrt(
85
($pixelX - 10) * ($pixelX - 10) +
86
($pixelY - 10) * ($pixelY - 10)
87
) - 18
88
)
89
90
if ($pixelX -lt 10 -or $pixelY -lt 10) {
91
$distance = 100
92
}
93
94
if ($distance -le 3.5) {
95
$corner.SetPixel($x, $y, $palette.CornerShadow)
96
}
97
if ($distance -le 2.75) {
98
$corner.SetPixel($x, $y, $palette.CornerOuter)
99
}
100
if ($distance -le 2.0) {
101
$corner.SetPixel($x, $y, $palette.CornerInner)
102
}
103
if ($distance -le 0.65) {
104
$corner.SetPixel($x, $y, $palette.CornerLight)
105
}
106
}
45
107
}
46
108
47
$resolvedDirectory = [System.IO.Path]::GetFullPath($outputDirectory)
48
[System.IO.Directory]::CreateDirectory($resolvedDirectory) | Out-Null
49
$bitmap.Save(
50
[System.IO.Path]::GetFullPath($OutputPath),
109
$resolvedCornerDirectory = [System.IO.Path]::GetFullPath(
110
(Split-Path -Parent $CornerPath)
111
)
112
[System.IO.Directory]::CreateDirectory($resolvedCornerDirectory) | Out-Null
113
$corner.Save(
114
[System.IO.Path]::GetFullPath($CornerPath),
51
115
[System.Drawing.Imaging.ImageFormat]::Png
52
116
)
53
117
} finally {
54
$bitmap.Dispose()
118
$corner.Dispose()
55
119
}
56
120
57
Write-Output ([System.IO.Path]::GetFullPath($OutputPath))
121
Write-Output ([System.IO.Path]::GetFullPath($BorderPath))
122
Write-Output ([System.IO.Path]::GetFullPath($CornerPath))
@@ -213,9 +213,12 @@ Events.on(ContentInitEvent, cons(() => {
213
213
const magneticBorderRegion = Core.atlas.find(
214
214
magneticConveyor.name + "-border"
215
215
);
216
// border 贴图宽 6 像素,即 1.5 世界单位;将中心平移 3.25 单位后,
216
const magneticCornerRegion = Core.atlas.find(
217
magneticConveyor.name + "-corner"
218
);
219
// border 贴图宽 5 像素,即 1.25 世界单位;将中心平移 3.375 单位后,
217
220
// 它的外沿恰好落在 8×8 方块的边界上。
218
const magneticBorderOffset = Vars.tilesize / 2 - 0.75;
221
const magneticBorderOffset = Vars.tilesize / 2 - 0.625;
219
222
220
223
magneticConveyor.buildType = prov(() => extend(
221
224
StackConveyor.StackConveyorBuild,
@@ -265,26 +268,48 @@ Events.on(ContentInitEvent, cons(() => {
265
268
},
266
269
267
270
drawCached(){
268
// 必须和原版 StackConveyor 一样在缓存层中先画底图、再画 edgeRegion。
269
// edgeRegion 的紫色内沿位于底图范围内;若放到 draw() 的动态层绘制,
270
// 会被已缓存的底图遮住,只剩铜色角块,看起来就像没有封边。
271
Draw.rect(
272
magneticConveyor.regions[this.state],
273
this.x,
274
this.y,
275
this.rotdeg()
276
);
277
278
// v159 的 Rhino 会错误复用 for 块内用 const 声明的值,导致四次循环
279
// 都检查同一个方向。这里使用 var 显式重赋值,确保依次检查四条边。
280
for(var i = 0; i < 4; i++){
281
var dir = direction4(this.rotation - i);
271
// 先按世界方向收集四条边的连接状态。使用 var 是为了避开 v159
272
// Rhino 在 Java 扩展方法中复用循环块 const 值的问题。
273
var connections = [false, false, false, false];
274
var connectionCount = 0;
275
for(var dir = 0; dir < 4; dir++){
282
276
var near = nearbyInDirection(this, dir);
283
var connected = isRenderConnection(
277
connections[dir] = isRenderConnection(
284
278
magneticConveyor,
285
279
this,
286
280
near
287
281
);
282
if(connections[dir]){
283
connectionCount++;
284
}
285
}
286
287
// corner 贴图的标准方向连接东(0)+南(3)。恰好两条相邻边连接时
288
// 整格替换为专用弯道中心,避免直线箭头和半格 side 贴图重叠。
289
var cornerRotation = -1;
290
if(connectionCount == 2){
291
if(connections[0] && connections[3]){
292
cornerRotation = 0;
293
}else if(connections[0] && connections[1]){
294
cornerRotation = 90;
295
}else if(connections[2] && connections[1]){
296
cornerRotation = 180;
297
}else if(connections[2] && connections[3]){
298
cornerRotation = 270;
299
}
300
}
301
302
Draw.rect(
303
cornerRotation >= 0
304
? magneticCornerRegion
305
: magneticConveyor.regions[this.state],
306
this.x,
307
this.y,
308
cornerRotation >= 0 ? cornerRotation : this.rotdeg()
309
);
310
311
for(var dir = 0; dir < 4; dir++){
312
var connected = connections[dir];
288
313
289
314
if(!connected){
290
315
var offset = Geometry.d4[dir];
@@ -294,7 +319,11 @@ Events.on(ContentInitEvent, cons(() => {
294
319
this.y + offset.y * magneticBorderOffset,
295
320
dir * 90
296
321
);
297
}else if(i == 1 || i == 3){
322
}else if(
323
cornerRotation < 0 &&
324
dir != this.rotation &&
325
dir != direction4(this.rotation + 2)
326
){
298
327
// 侧向连接使用专用接口贴图填平接缝;
299
328
// 前后连接由相邻底图自然衔接。
300
329
Draw.rect(
二进制文件已变更,无法进行逐行预览。
二进制文件已变更,无法进行逐行预览。