返回提交历史

XFEstudio/MCIndustry

新增磁铜传送带

ce3b206
X
XFEstudio <mail@xfegzs.com>
提交于

代码差异

17 个文件 +152 -55
Added content/blocks/磁铜传送带.hjson +29 -0
@@ -0,0 +1,29 @@
1 {
2 name: 磁铜传送带
3 description: 将物品压缩为二十五件一组,利用高速磁场进行运输。满载时可运输每秒500件物品。
4 type: StackConveyor
5 category: distribution
6 health: 220
7 itemCapacity: 25
8 // 每3 tick传输25件:25 × 60 ÷ 3 = 500件/秒。
9 // 略高于1/3可避免浮点误差使冷却多等待1 tick。
10 speed: 0.333334
11 recharge: 1
12 outputRouter: true
13 canOverdrive: false
14 hasPower: true
15 consumes: {
16 power: 0.2
17 }
18 glowColor: "7f5cff"
19 glowAlpha: 0.9
20 requirements: [
21 copper/10
22 磁铜/5
23 ]
24 research: 磁铜
25 researchCost: [
26 copper/1000
27 磁铜/500
28 ]
29 }
Modified content/units/攻击型UAV.json +1 -1
@@ -1,7 +1,7 @@
1 1 {
2 2 "name": "攻击型UAV",
3 3 "description": "小型无人机,可以继续快速攻击",
4 "research": "磁铜工业",
4 "research": "磁铜UAV工厂",
5 5 "flying":true,
6 6 "speed": 4,
7 7 "accel":2,
Modified content/units/磁爆.json +1 -1
@@ -2,7 +2,7 @@
2 2 "type": "legs",
3 3 "name": "磁爆",
4 4 "description": "类自爆单位,可在自身周围爆发高伤害的电磁脉冲",
5 "research":"磁铜工业",
5 "research":"磁铜UAV工厂",
6 6 "flying":false,
7 7 "speed":3
8 8 "hitSize":5
Modified content/units/辅助型UAV.json +1 -1
@@ -1,7 +1,7 @@
1 1 {
2 2 "name": "辅助型UAV",
3 3 "description": "小型无人机,可以治疗修复和建造建筑,可以挖矿",
4 "research": "磁铜工业",
4 "research": "磁铜UAV工厂",
5 5 "flying":true,
6 6 "speed": 4,
7 7 "accel":2,
Modified mod.hjson +1 -1
@@ -2,6 +2,6 @@
2 2 name:磁铜工业
3 3 author:XFEstudio
4 4 "description":"[purple]磁铜工业,适合度过前期,以及为后期增加各类工厂工业制造模块,方便传输,增加新炮塔及工厂,全工业基于磁铜,持续测试中"
5 version:"2.41"
5 version:"2.50"
6 6 minGameVersion:136
7 7 }
Added scripts/blocks/磁铜传送带.js +59 -0
@@ -0,0 +1,59 @@
1 // StackConveyor 的标称速度是“整组容量 × 每秒移动组数”。原版装载端仍然
2 // 等待相邻建筑逐件 dump,所以单个物品源会先被 100/s 的输出上限卡住。
3 // 磁铜传送带在装载状态下从相邻 ItemSource 补满一组,使 25 件物品可以真正
4 // 每 3 tick 向前移动一次,即 25 × 60 / 3 = 500 件/秒。
5 function pullFrom(magneticConveyor, build, source, room){
6 if(source == null || source == build.front() || source.team != build.team){
7 return 0;
8 }
9
10 // 只对无限物品源做主动补组。普通工厂、核心和仓库仍沿用原版输入
11 // 规则,避免传送带错误抽走配方原料或绕过卸载器。
12 if(!(source.block instanceof ItemSource)){
13 return 0;
14 }
15
16 // ItemSource 没有持久库存;它的 outputItem 就是无限供应的配置物品。
17 const item = source.outputItem;
18 if(item == null || (build.items.any() && !build.items.has(item)) || !source.canDump(build, item)){
19 return 0;
20 }
21
22 build.handleStack(item, room, source);
23 return room;
24 }
25
26 function fillLoadingDock(magneticConveyor, build){
27 // stateLoad == 1;该常量在 Java 中是 protected,脚本侧不能直接读取。
28 if(build.state !== 1 || build.items.total() >= magneticConveyor.itemCapacity){
29 return;
30 }
31
32 let room = magneticConveyor.itemCapacity - build.items.total();
33 for(let i = 0; i < build.proximity.size && room > 0; i++){
34 room -= pullFrom(magneticConveyor, build, build.proximity.get(i), room);
35 }
36 }
37
38 Events.on(ContentInitEvent, cons(() => {
39 const magneticConveyor = Vars.content.getByName(
40 ContentType.block,
41 modName + "-磁铜传送带"
42 );
43
44 if(magneticConveyor == null){
45 Log.err("找不到磁铜传送带内容:" + modName + "-磁铜传送带");
46 return;
47 }
48
49 magneticConveyor.buildType = prov(() => extend(
50 StackConveyor.StackConveyorBuild,
51 magneticConveyor,
52 {
53 updateTile(){
54 this.super$updateTile();
55 fillLoadingDock(magneticConveyor, this);
56 }
57 }
58 ));
59 }));
Modified scripts/blocks/磁驱传输器.js +47 -46
@@ -1,63 +1,64 @@
1 const magneticBridge = Vars.content.getByName(
2 ContentType.block,
3 modName + "-磁驱传输器"
4 );
5
6 1 const batchSize = 10;
7 2
8 if(magneticBridge == null){
9 throw new Error("找不到磁驱传输器内容:" + modName + "-磁驱传输器");
10 }
11
12 3 // ItemBridge.setStats() 只按 transportTime 计算单件速度;初始化完成后将
13 4 // 数据库面板中的速度替换为实际的“每批数量 × 每秒批数”。
14 5 Events.on(ContentInitEvent, cons(() => {
6 const magneticBridge = Vars.content.getByName(
7 ContentType.block,
8 modName + "-磁驱传输器"
9 );
10
11 if(magneticBridge == null){
12 Log.err("找不到磁驱传输器内容:" + modName + "-磁驱传输器");
13 return;
14 }
15
15 16 magneticBridge.stats.remove(Stat.itemsMoved);
16 17 magneticBridge.stats.add(
17 18 Stat.itemsMoved,
18 19 batchSize * 60 / magneticBridge.transportTime,
19 20 StatUnit.itemsSecond
20 21 );
21 }));
22 22
23 // ItemBridge 原版每次只处理 1 件物品。这里保留它的计时、供电与连接
24 // 规则,但把一次传输事件改成最多搬运 10 件物品。
25 magneticBridge.buildType = prov(() => extend(
26 ItemBridge.ItemBridgeBuild,
27 magneticBridge,
28 {
29 updateTransport(other){
30 this.transportCounter += this.edelta();
31
32 while(this.transportCounter >= magneticBridge.transportTime){
33 const item = this.items.first();
34
35 if(item != null && other.acceptItem(this, item)){
36 // 两端都是同一种 ItemBridge;按对端的总容量截断批量,
37 // 再用一次 handleStack 完成真正的成组传输。
38 const amount = Math.min(
39 batchSize,
40 this.items.get(item),
41 magneticBridge.itemCapacity - other.items.total()
42 );
43
44 if(amount > 0){
45 this.items.remove(item, amount);
46 other.handleStack(item, amount, this);
47 this.moved = true;
23 // ItemBridge 原版每次只处理 1 件物品。这里保留它的计时、供电与连接
24 // 规则,但把一次传输事件改成最多搬运 10 件物品。
25 magneticBridge.buildType = prov(() => extend(
26 ItemBridge.ItemBridgeBuild,
27 magneticBridge,
28 {
29 updateTransport(other){
30 this.transportCounter += this.edelta();
31
32 while(this.transportCounter >= magneticBridge.transportTime){
33 const item = this.items.first();
34
35 if(item != null && other.acceptItem(this, item)){
36 // 两端都是同一种 ItemBridge;按对端的总容量截断批量,
37 // 再用一次 handleStack 完成真正的成组传输。
38 const amount = Math.min(
39 batchSize,
40 this.items.get(item),
41 magneticBridge.itemCapacity - other.items.total()
42 );
43
44 if(amount > 0){
45 this.items.remove(item, amount);
46 other.handleStack(item, amount, this);
47 this.moved = true;
48 }
48 49 }
49 }
50 50
51 this.transportCounter -= magneticBridge.transportTime;
52 }
53 },
51 this.transportCounter -= magneticBridge.transportTime;
52 }
53 },
54 54
55 // 无有效链接时,ItemBridge 会向相邻建筑卸货。原版这里同样只有
56 // 1 件/tick,因此必须一起扩展,否则整条线路仍会卡在约 60 件/秒。
57 doDump(){
58 for(let i = 0; i < batchSize; i++){
59 if(!this.dump()) break;
55 // 无有效链接时,ItemBridge 会向相邻建筑卸货。原版这里同样只有
56 // 1 件/tick,因此必须一起扩展,否则整条线路仍会卡在约 60 件/秒。
57 doDump(){
58 for(let i = 0; i < batchSize; i++){
59 if(!this.dump()) break;
60 }
60 61 }
61 62 }
62 }
63 ));
63 ));
64 }));
Modified scripts/main.js +2 -1
@@ -1,5 +1,6 @@
1 1
2 require("units/辅助型UAV");
3 2 require("blocks/磁驱传输器");
3 require("blocks/磁铜传送带");
4 require("units/辅助型UAV");
4 5
5 6 this.window = this;
Modified scripts/units/辅助型UAV.js +11 -4
@@ -1,5 +1,12 @@
1 1
2 var 辅助型UAV = Vars.content.getByName(ContentType.unit, modName + "-辅助型UAV");
3 辅助型UAV.aiController = prov(() => new BuilderAI());
4 辅助型UAV.drawShields = false;
5 辅助型UAV.abilities.add( new RepairFieldAbility(20, 60, 80));
2 Events.on(ContentInitEvent, cons(() => {
3 const 辅助型UAV = Vars.content.getByName(ContentType.unit, modName + "-辅助型UAV");
4 if(辅助型UAV == null){
5 Log.err("找不到辅助型UAV内容:" + modName + "-辅助型UAV");
6 return;
7 }
8
9 辅助型UAV.aiController = prov(() => new BuilderAI());
10 辅助型UAV.drawShields = false;
11 辅助型UAV.abilities.add(new RepairFieldAbility(20, 60, 80));
12 }));
Added sprites/books/磁铜传送带/磁铜传送带-0.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added sprites/books/磁铜传送带/磁铜传送带-1.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added sprites/books/磁铜传送带/磁铜传送带-2.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added sprites/books/磁铜传送带/磁铜传送带-edge-glow.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added sprites/books/磁铜传送带/磁铜传送带-edge.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added sprites/books/磁铜传送带/磁铜传送带-glow.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added sprites/books/磁铜传送带/磁铜传送带-stack.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added sprites/books/磁铜传送带/磁铜传送带.png +0 -0
二进制文件已变更,无法进行逐行预览。