Skip to content

Commit

Permalink
add params, add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaqyoo committed Mar 21, 2022
1 parent 023dc8d commit c263403
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 73 deletions.
55 changes: 24 additions & 31 deletions BP/building/belt.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
import { BluePrint } from "../blueprint";
import { Building, BuilidingParam } from "./building";
import { Building } from "./building";
import { IBuildingParam } from "./building_param";

class BeltParamLabel {
label: number
count: number
export class BeltBlueprintParam implements IBuildingParam {
hasParam = false
label:number
count:number = 0

constructor(label: number, count: number) {
this.label = label
this.count = count
}
}

export class BeltBlueprintParam extends BuilidingParam {
private Belt:null | BeltParamLabel

constructor() {
super()
this.reset()
}

reset() : number {
this.Belt = null
return 0
constructor(label?:number) {
if (label === undefined) {
this.hasParam = false
}
else {
this.label = label
this.hasParam = true
}
}

setLabel(label:number) : number{
this.Belt = new BeltParamLabel(label, 0)
return 2
getCount(): number {
if(this.hasParam) return 2
else return 0
}

getCount(): number {
if (this.Belt == null) {
return 0
toJSON():Object {
if(this.hasParam) {
return {"Belt": {label: this.label, count:this.count}}
}
else {
return 2
return {"Belt": null}
}
}
}
Expand All @@ -44,6 +36,7 @@ export class Belt extends Building {
area_index:number,
local:[number, number, number] | null,
level=3,
label?:number
) {
let item_id = 2003
let model_index = 37
Expand All @@ -56,10 +49,10 @@ export class Belt extends Building {
if (local === null) local = [0, 0, 0]

super(area_index,local, undefined, item_id, model_index, false)
this.param = new BeltBlueprintParam()
this.header.parameter_count = 0
this.header.output_to_slot = 1
this.header.input_to_slot = 1
this.setParam(new BeltBlueprintParam(label))
}

connect(next_belt: Belt) {
Expand Down Expand Up @@ -90,7 +83,7 @@ export class Belt extends Building {
}

setLabel(label:number) {
this.header.parameter_count = this.param.setLabel(label)
this.setParam(new BeltBlueprintParam(label))
}
}

Expand Down
30 changes: 9 additions & 21 deletions BP/building/building.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { local_diff } from "../../util"
import { BuildingParamDefault, IBuildingParam } from "./building_param"
import { InserterLocalParam } from "./inserter"

export class BuildingHeader {
Expand Down Expand Up @@ -27,25 +27,10 @@ export class BuildingHeader {
parameter_count:number
}

export class BuilidingParam {
getCount(){}
}

class BuilidingParamUnknown extends BuilidingParam {
Unknown:[number]
constructor() {
super()
this.Unknown = [0]
}

getCount(): number {
return this.Unknown.length
}
}

export class Building {
header: BuildingHeader
param: any
param: IBuildingParam

constructor(
area_index:number,
Expand Down Expand Up @@ -94,10 +79,8 @@ export class Building {
header.filter_id = 0
header.parameter_count = 0

if (isDefault) {
this.param = new BuilidingParamUnknown()
this.header.parameter_count = this.param.getCount()
}
this.param = new BuildingParamDefault()
this.header.parameter_count = this.param.getCount()
}

setIndex(index:number) {this.header.index = index}
Expand Down Expand Up @@ -152,4 +135,9 @@ export class Building {
}

getInserterLocal(slot: number, is_ingress: boolean): InserterLocalParam {return null}

setParam(param: IBuildingParam) {
this.param = param
this.header.parameter_count = this.param.getCount()
}
}
25 changes: 25 additions & 0 deletions BP/building/building_param.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export enum AccelerateMode {
Accerlerate = 1,
Increase = 0,
}

export interface IBuildingParam {
getCount():number
toJSON():Object
}

export class BuildingParamDefault implements IBuildingParam{
accelerate_mode: AccelerateMode

constructor(accelerate_mode = AccelerateMode.Accerlerate) {
this.accelerate_mode = accelerate_mode
}

getCount(): number {
return 1
}

toJSON():Object {
return {"Unknown": [this.accelerate_mode]}
}
}
44 changes: 25 additions & 19 deletions BP/building/lab.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
import { local_diff } from "../../util";
import { Building, BuilidingParam } from "./building";
import { Building } from "./building";
import { AccelerateMode as AccelerateMode, BuildingParamDefault, IBuildingParam } from "./building_param";
import { InserterLocalParam } from "./inserter";

class LabParams extends BuilidingParam {
Unknown:[number, number]
constructor(isResearch:boolean) {
super()
if (isResearch) {
this.Unknown = [2, 0]
}
else {
this.Unknown = [1, 0]
}
}
export enum LabsParamResearch {
Reasearch = 2,
Produce = 1,
}

class LabParams implements IBuildingParam {
isReseach = LabsParamResearch.Produce
accelateMode = AccelerateMode.Increase

constructor(isResearch:LabsParamResearch, mode = AccelerateMode.Accerlerate) {
this.isReseach = isResearch
this.accelateMode = mode
}
getCount(): number {
return this.Unknown.length
return 2
}
toJSON(): Object {
return {"Unknown": [this.isReseach, this.accelateMode == AccelerateMode.Accerlerate ? 0 : 1]}
}
}

export class Lab extends Building {
constructor(
area_index:number,
local:[number, number, number] = null,
isResearch: boolean,
param_research: LabsParamResearch,
recipe_id?: number,
mode?:AccelerateMode
) {
super(area_index, local, local, 2901, 70, false)
this.header.output_to_slot = 14
this.header.input_from_slot = 15
this.header.output_from_slot = 15
this.header.input_to_slot = 14
this.param = new LabParams(isResearch)
this.header.parameter_count = this.param.getCount()
if (!isResearch) {
this.setParam(new LabParams(param_research, mode))
if (param_research == LabsParamResearch.Produce) {
this.header.recipe_id = recipe_id
}
}
Expand Down Expand Up @@ -91,15 +96,16 @@ export class LabStack {
constructor(
area_index:number,
local:[number, number] = null,
isResearch: boolean,
param_research: LabsParamResearch,
stack = 15,
recipe_id?: number,
accelerate_mode = AccelerateMode.Accerlerate
)
{
if (local === null) local = [0, 0]
this.labs = new Array()
for (let index = 0; index < stack; index++) {
let lab = new Lab(area_index, [local[0], local[1], index*3], isResearch, recipe_id)
let lab = new Lab(area_index, [local[0], local[1], index*3], param_research, recipe_id)
this.labs.push(lab)
}
}
Expand Down
34 changes: 34 additions & 0 deletions building_group/36000_white_matrix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 白糖 7200 增产 36000
* 蓝糖 1152 增产 28800
* 磁铁 64 加速 23040
* 磁线圈 144 加速 23040
* 铜块 895 加速 214733
* 电路板 351 加速 126259
* 铁板 603 加速 144691
* 红糖 1440 加速 28800
* 石墨 634 加速 76032
* 黄糖 3072 增产 28800
* 金刚石 188 加速 59904
* 钛晶石 512 加速 23040
* 钛块 884 加速 105984
* 紫糖 3840 增产 28800
* CPU 1721 增产 64512
* 集成芯片 1147 加速 103219
* 硅块 1721 加速 206438
* 粒子带宽 1639 增产 23040
* 碳纳米管 615 加速 36864
* 晶格硅 154 加速 36864
* 塑料 461 加速 18432
* 绿糖 4608 增产 28800
* 量子芯片 615 增产 11520
* 位面过滤 1229 加速 18432
* 卡晶 410 加速 18432
* 石墨烯 308 加速 36864
* 钛化玻璃 512 加速 36864
* 玻璃 308 加速 36864
* 引力透镜 615 增产 11520
* 奇异物质 615 加速 9216
* 粒子容器 410 加速 18432
* 反物质 240 加速 28800
*/
5 changes: 3 additions & 2 deletions building_group/7200_blue_array.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { BluePrint } from "../BP/blueprint";
import { Assembler } from "../BP/building/assembler";
import { Belt, connectBelts } from "../BP/building/belt";
import { AccelerateMode } from "../BP/building/building_param";
import { Inserter } from "../BP/building/inserter";
import { LabStack } from "../BP/building/lab";
import { LabsParamResearch, LabStack } from "../BP/building/lab";
import { Smelter } from "../BP/building/smelter";
import { SprayCoater } from "../BP/building/spray_coater";
import { TeslaCoil } from "../BP/building/tesla_coil";
Expand Down Expand Up @@ -80,7 +81,7 @@ export class BlueArray7200 {

this.labs = new Array<LabStack>()
for(let i = 0; i < building_num.blue_matrix; i++) {
let lab_stack:LabStack = new LabStack(area_index, null, false, undefined, 9)
let lab_stack:LabStack = new LabStack(area_index, null, LabsParamResearch.Produce, undefined, 9, AccelerateMode.Increase)
lab_stack.getLabs().forEach(lab => bp.addBuilding(lab))
lab_stack.initLabStacks()
this.labs.push(lab_stack)
Expand Down
33 changes: 33 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 戴森球计划蓝图生成脚本

该脚本用来生成戴森球蓝图,将会先生成描述建筑布局的JSON文件

然后使用来自 https://github.com/Wesmania/dspbp 的编译器将JSON文件转换成游戏中的蓝图文件

## 试用

> npm i
> npm start --output=output.json
> ./third/dspbp.exe -i output.json -o output.txt undump
## 当前状态

7200 蓝糖(未完成,缺物流塔和垂直传送带)

----

# Dyson Sphere Project Blueprint Generator

Try to generate the blueprint by code. It will generate the JSON file which describes the DSP blueprint.

The compiler to convert blueprint.json to blueprint.txt is copy from https://github.com/Wesmania/dspbp

## Test

> npm i
> npm start --output=output.json
> ./third/dspbp.exe -i output.json -o output.txt undump
# Current Status

7200 Electric Matrix (not complete for the station and the belts)

0 comments on commit c263403

Please sign in to comment.