返回提交历史
Added
art-tools/generate-magnetic-conveyor-border.ps1
+57
-0
Modified
scripts/blocks/磁铜传送带.js
+78
-45
Modified
sprites/books/磁铜传送带/磁铜传送带-0.png
+0
-0
Modified
sprites/books/磁铜传送带/磁铜传送带-1.png
+0
-0
Modified
sprites/books/磁铜传送带/磁铜传送带-2.png
+0
-0
Added
sprites/books/磁铜传送带/磁铜传送带-border.png
+0
-0
XFEstudio/MCIndustry
修复部分边框显示问题
63d38bd
代码差异
6 个文件
+135
-45
@@ -0,0 +1,57 @@
1
param(
2
[Parameter(Mandatory = $true)]
3
[string]$OutputPath
4
)
5
6
$ErrorActionPreference = 'Stop'
7
8
Add-Type -AssemblyName System.Drawing
9
10
$outputDirectory = Split-Path -Parent $OutputPath
11
12
$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')
19
}
20
21
$bitmap = [System.Drawing.Bitmap]::new(
22
6,
23
32,
24
[System.Drawing.Imaging.PixelFormat]::Format32bppArgb
25
)
26
27
try {
28
for ($y = 0; $y -lt $bitmap.Height; $y++) {
29
$phase = $y % 8
30
31
$bitmap.SetPixel(0, $y, $palette.InnerDark)
32
$bitmap.SetPixel(
33
1,
34
$y,
35
$(if ($phase -in 2, 3) { $palette.InnerGlow } else { $palette.Purple })
36
)
37
$bitmap.SetPixel(2, $y, $palette.Purple)
38
$bitmap.SetPixel(3, $y, $palette.CopperDark)
39
$bitmap.SetPixel(
40
4,
41
$y,
42
$(if ($phase -in 5, 6) { $palette.CopperGlow } else { $palette.Copper })
43
)
44
$bitmap.SetPixel(5, $y, $palette.Copper)
45
}
46
47
$resolvedDirectory = [System.IO.Path]::GetFullPath($outputDirectory)
48
[System.IO.Directory]::CreateDirectory($resolvedDirectory) | Out-Null
49
$bitmap.Save(
50
[System.IO.Path]::GetFullPath($OutputPath),
51
[System.Drawing.Imaging.ImageFormat]::Png
52
)
53
} finally {
54
$bitmap.Dispose()
55
}
56
57
Write-Output ([System.IO.Path]::GetFullPath($OutputPath))
@@ -51,20 +51,33 @@ function fillLoadingDock(magneticConveyor, build){
51
51
}
52
52
}
53
53
54
function direction4(value){
55
const result = value % 4;
56
return result < 0 ? result + 4 : result;
57
}
58
54
59
function sideNeighbors(build){
55
60
return [
56
build.nearby(Mathf.mod(build.rotation + 1, 4)),
57
build.nearby(Mathf.mod(build.rotation + 3, 4))
61
build.nearby(direction4(build.rotation + 1)),
62
build.nearby(direction4(build.rotation + 3))
58
63
];
59
64
}
60
65
66
function nearbyInDirection(build, dir){
67
const offset = Geometry.d4[dir];
68
return Vars.world.build(
69
build.tile.x + offset.x,
70
build.tile.y + offset.y
71
);
72
}
73
61
74
function isRenderConnection(magneticConveyor, build, near){
62
75
if(near == null || near.team != build.team){
63
76
return false;
64
77
}
65
78
66
// 磁铜传送带只有在其中一端确实朝向另一端时才算接通。
67
// 这样相邻但平行放置的两条线路仍会各自保留边框。
79
// 只有其中一端确实朝向另一端时才绘制接口。这样 T 形分支会打开,
80
// 但只是平行贴放、并未形成物品通路的两条传送带仍会各自保留封边。
68
81
if(near.block == magneticConveyor){
69
82
return near.front() == build || near.back() == build ||
70
83
build.front() == near || build.back() == near;
@@ -197,16 +210,12 @@ Events.on(ContentInitEvent, cons(() => {
197
210
const magneticSideRegion = Core.atlas.find(
198
211
magneticConveyor.name + "-side"
199
212
);
200
const magneticFrontRegions = [];
201
const magneticBackRegions = [];
202
for(let i = 0; i < 3; i++){
203
magneticFrontRegions.push(Core.atlas.find(
204
magneticConveyor.name + "-front-" + i
205
));
206
magneticBackRegions.push(Core.atlas.find(
207
magneticConveyor.name + "-back-" + i
208
));
209
}
213
const magneticBorderRegion = Core.atlas.find(
214
magneticConveyor.name + "-border"
215
);
216
// border 贴图宽 6 像素,即 1.5 世界单位;将中心平移 3.25 单位后,
217
// 它的外沿恰好落在 8×8 方块的边界上。
218
const magneticBorderOffset = Vars.tilesize / 2 - 0.75;
210
219
211
220
magneticConveyor.buildType = prov(() => extend(
212
221
StackConveyor.StackConveyorBuild,
@@ -256,8 +265,9 @@ Events.on(ContentInitEvent, cons(() => {
256
265
},
257
266
258
267
drawCached(){
259
// 不使用父类的 blendprox 缓存;它只认识原版 StackConveyor 的
260
// 单向连接规则,且在旋转/拆除支路后可能留下不符合本方块规则的边框。
268
// 必须和原版 StackConveyor 一样在缓存层中先画底图、再画 edgeRegion。
269
// edgeRegion 的紫色内沿位于底图范围内;若放到 draw() 的动态层绘制,
270
// 会被已缓存的底图遮住,只剩铜色角块,看起来就像没有封边。
261
271
Draw.rect(
262
272
magneticConveyor.regions[this.state],
263
273
this.x,
@@ -265,37 +275,60 @@ Events.on(ContentInitEvent, cons(() => {
265
275
this.rotdeg()
266
276
);
267
277
268
// 底图的四个方向默认全部封边,只在存在实际连接时打开对应方向。
269
// 前后端恢复当前状态底图的同向半幅,避免旋转侧向接口后破坏箭头;
270
// 左右两侧则绘制转向接口。支线的尾部属于 i=2,必须单独处理。
271
for(let i = 0; i < 4; i++){
272
const dir = Mathf.mod(this.rotation - i, 4);
273
const near = this.nearby(dir);
274
if(isRenderConnection(magneticConveyor, this, near)){
275
if(i == 0){
276
Draw.rect(
277
magneticFrontRegions[this.state],
278
this.x,
279
this.y,
280
this.rotdeg()
281
);
282
}else if(i == 2){
283
Draw.rect(
284
magneticBackRegions[this.state],
285
this.x,
286
this.y,
287
this.rotdeg()
288
);
289
}else{
290
Draw.rect(
291
magneticSideRegion,
292
this.x,
293
this.y,
294
dir * 90
295
);
296
}
278
// v159 的 Rhino 会错误复用 for 块内用 const 声明的值,导致四次循环
279
// 都检查同一个方向。这里使用 var 显式重赋值,确保依次检查四条边。
280
for(var i = 0; i < 4; i++){
281
var dir = direction4(this.rotation - i);
282
var near = nearbyInDirection(this, dir);
283
var connected = isRenderConnection(
284
magneticConveyor,
285
this,
286
near
287
);
288
289
if(!connected){
290
var offset = Geometry.d4[dir];
291
Draw.rect(
292
magneticBorderRegion,
293
this.x + offset.x * magneticBorderOffset,
294
this.y + offset.y * magneticBorderOffset,
295
dir * 90
296
);
297
}else if(i == 1 || i == 3){
298
// 侧向连接使用专用接口贴图填平接缝;
299
// 前后连接由相邻底图自然衔接。
300
Draw.rect(
301
magneticSideRegion,
302
this.x,
303
this.y,
304
dir * 90
305
);
297
306
}
298
307
}
308
},
309
310
onProximityUpdate(){
311
this.super$onProximityUpdate();
312
if(Vars.headless){
313
return;
314
}
315
316
// 原版 blends() 不认识本模组允许的双向侧接规则,因此在父类完成
317
// 状态计算后重建 blendprox,并再次缓存最终连接贴图。
318
var mask = 0;
319
for(var i = 0; i < 4; i++){
320
var dir = direction4(this.rotation - i);
321
if(isRenderConnection(
322
magneticConveyor,
323
this,
324
nearbyInDirection(this, dir)
325
)){
326
mask |= 1 << i;
327
}
328
}
329
330
this.blendprox = mask;
331
this.recache();
299
332
}
300
333
}
301
334
));
二进制文件已变更,无法进行逐行预览。
二进制文件已变更,无法进行逐行预览。
二进制文件已变更,无法进行逐行预览。
二进制文件已变更,无法进行逐行预览。