diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..ad30e10 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,48 @@ +{ + "esversion":6, + "shadow":true, + "sub":true, + "loopfunc":true, + "unused":true, + "undef":true, + "globals":{ + "print":true, + "extendContent":true, + "extend":true, + "run":true, + "boolf":true, + "boolp":true, + "floatf":true, + "floatp":true, + "cons":true, + "prov":true, + "func":true, + "newEffect":true, + "Call":true, + "GenericCrafter":true, + "ObjectSet":true, + "BlockInventoryFragment":true, + "Mathf":true, + "Time":true, + "Effects":true, + "ReqImage":true, + "ItemImage":true, + "Cicon":true, + "Icon":true, + "BlockStat":true, + "StatUnit":true, + "Core":true, + "Bar":true, + "Pal":true, + "Vars":true, + "ContentType":true, + "ItemStack":true, + "LiquidStack":true, + "ButtonGroup":true, + "Tex":true, + "Styles":true, + "TextureRegionDrawable":true, + "ConsumePower":true, + "require":true + } +} diff --git a/bundles/bundle.properties b/bundles/bundle.properties index 0550559..478adc6 100644 --- a/bundles/bundle.properties +++ b/bundles/bundle.properties @@ -1,4 +1,5 @@ steam-power-heat-per-sec=heat/sec +steam-power-heat-cond=above {0} heat steam-power-matter-disintegrator-dialog-0=Current State steam-power-matter-disintegrator-dialog-1=Values steam-power-matter-disintegrator-title-0=Container Requirement @@ -42,7 +43,7 @@ block.steam-power-electric-burner.description=Heats up using power.\n\n[red]Heat block.steam-power-heat-regulator.name=Heat Regulator block.steam-power-heat-regulator.description=Uses power to control the surrounding heat givers. You can configure the upper limit. The higher the current heat, the more power it consumes. Handles up to 30 heat per second.\n\n[red]Heat Block. Explodes when heat goes over 500.\nHeat decreases by 5% per sec of current heat.\nThe lower limit is 25. block.steam-power-metal-smelter.name=Metal Smelter -block.steam-power-metal-smelter.description=Smelts advanced alloys. +block.steam-power-metal-smelter.description=Smelts advanced alloys.\n\n[red]Heat Block. Explodes when heat goes over 1500.\nHeat decreases by 5% per sec of current heat.\nThe lower limit is 25. block.steam-power-missile-factory.name=Missile Factory block.steam-power-missile-factory.description=A missile factory. block.steam-power-semiconductor-plant.name=Semiconductor Plant @@ -82,9 +83,11 @@ block.steam-power-dense-alloy-wall.description=Dense Alloy Wall. Strong against block.steam-power-heat-bridge.name=Heat Bridge block.steam-power-heat-bridge.description=Use to transport heat over long distances.\n\n[red]Heat Block. Explodes when heat goes over 500.\nHeat decreases by 1% per sec of current heat.\nThe lower limit is 25. block.steam-power-heat-phase-bridge.name=Heat Phase Bridge -block.steam-power-heat-phase-bridge.description=Use to transport heat over very long distances.\n\n[red]Heat Block. Explodes when heat goes over 1000.\nHeat decreases by 0.5% per sec of current heat.\nThe lower limit is 25. +block.steam-power-heat-phase-bridge.description=Use to transport heat over very long distances.\n\n[red]Heat Block. Explodes when heat goes over 1000.\nHeat decreases by 5% per sec of current heat.\nThe lower limit is 25. block.steam-power-teleporter.name=Teleporter block.steam-power-teleporter.description=Advanced item transport block. Teleporters input items to other teleporters of the same color. Does nothing if no teleporters of the same color exist. If multiple teleporters exist of the same color, a random one is selected. Uses power. Tap to change color. +block.steam-power-matter-disintegrator.name=Matter Disintegrator +block.steam-power-matter-disintegrator.description=Disintegrates matter to quantum unit. If heat is over 500 boost goes up to +200%.\n\n[red]Heat Block. Explodes when heat goes over 3000.\nHeat decreases by 5% per sec of current heat.\nThe lower limit is 25. item.steam-power-armor-piercing-shell.name=AP item.steam-power-armor-piercing-shell.description=Armor Piercing Shell. @@ -130,6 +133,8 @@ item.steam-power-uranium.name=Uranium item.steam-power-uranium.description=Enriched Uranium. item.steam-power-quantum-mass.name=Quantum Mass item.steam-power-quantum-mass.description=Quantum Mass. Set of quantums that state is quark and lepton. Holded in solid container that maintains the state. +item.steam-power-dimension-armour.name=Dimension Armour +item.steam-power-dimension-armour.description=Dimension Armour. Armour made by organizing from quantum level. It is light and strong since inner structure is special. unit.steam-power-draug-a.name = Draug-A Miner Drone unit.steam-power-draug-a.description = Smarter then the vanilla miner drone. Delivers mined resources to the cloeset furnace. diff --git a/bundles/bundle_ko.properties b/bundles/bundle_ko.properties index 4189a87..5922a53 100644 --- a/bundles/bundle_ko.properties +++ b/bundles/bundle_ko.properties @@ -1,4 +1,5 @@ steam-power-heat-per-sec=열/초 +steam-power-heat-cond={0}열 이상 steam-power-matter-disintegrator-dialog-0=현황 steam-power-matter-disintegrator-dialog-1=값들 steam-power-matter-disintegrator-title-0=용기 요구량 @@ -40,7 +41,7 @@ block.steam-power-electric-burner.description=전기를 이용해 가열합니 block.steam-power-heat-regulator.name=열 조절기 block.steam-power-heat-regulator.description=전기를 소모해 주변의 열 방출기를 조절합니다. 버튼을 이용해 상한선을 설정할 수 있습니다. 현재 열이 높을 수록 더 많은 전력을 소모하며, 최대 초당 30열 까지 조절가능합니다. \n\n[red]열 블럭입니다. 열이 500 이상이 되면 폭발합니다.\n열은 전기가 초당 현재 열의 5%만큼 감소합니다.\n하한선은 25입니다. block.steam-power-metal-smelter.name=금속 제련소 -block.steam-power-metal-smelter.description=고급 합금들을 제련합니다. +block.steam-power-metal-smelter.description=고급 합금들을 제련합니다.\n\n[red]열 블럭입니다. 열이 1500 이상이 되면 폭발합니다.\n열은 초당 현재 열의 5%만큼 감소합니다.\n하한선은 25입니다. block.steam-power-missile-factory.name=미사일 공장 block.steam-power-missile-factory.description=미사일 공장. block.steam-power-semiconductor-plant.name=반도체 공장 @@ -90,11 +91,13 @@ block.steam-power-solar-conveyor.description=태양 전지판이 있어 전력 block.steam-power-heat-bridge.name=열 다리 block.steam-power-heat-bridge.description=열을 전달합니다.\n\n[red]열 블럭입니다. 열이 500 이상이 되면 폭발합니다.\n열은 초당 현재 열의 1%만큼 감소합니다.\n하한선은 25입니다. block.steam-power-heat-phase-bridge.name=메타 열 다리 -block.steam-power-heat-phase-bridge.description=열을 굉장히 긴 범위로 전달할 수 있습니다.\n\n[red]열 블럭입니다. 열이 1000 이상이 되면 폭발합니다.\n열은 초당 현재 열의 0.5%만큼 감소합니다.\n하한선은 25입니다. +block.steam-power-heat-phase-bridge.description=열을 굉장히 긴 범위로 전달할 수 있습니다.\n\n[red]열 블럭입니다. 열이 1000 이상이 되면 폭발합니다.\n열은 초당 현재 열의 5%만큼 감소합니다.\n하한선은 25입니다. block.steam-power-teleporter.name=텔레포터 block.steam-power-teleporter.description=고급 아이템 운송 블럭입니다. 텔레포터들은 같은 색의 텔레포터들로부터 아이템을 받습니다. 같은 색의 텔레포터들이 존재하지 않으면 아무것도 하지 않습니다. 만약 같은 색의 여러 텔레포터들이 존재한다면, 무작위로 전송합니다. 전력을 사용합니다. 눌러서 색을 바꿀 수 있습니다. block.steam-power-starport.name=우주공항 block.steam-power-starport.description=영감 순양함을 생산합니다. +block.steam-power-matter-disintegrator.name=물질 해체기 +block.steam-power-matter-disintegrator.description=물질을 양자 단위로 해체합니다. 열이 500이상 일 때 최대 +200% 가속됩니다. \n\n[red]열 블럭입니다. 열이 3000 이상이 되면 폭발합니다.\n열은 초당 현재 열의 5%만큼 감소합니다.\n하한선은 25입니다. item.steam-power-armor-piercing-shell.name=철갑탄 item.steam-power-armor-piercing-shell.description=철갑탄. @@ -140,6 +143,8 @@ item.steam-power-uranium.name=우라늄 item.steam-power-uranium.description=농축된 우라늄. item.steam-power-quantum-mass.name=양자 덩어리 item.steam-power-quantum-mass.description=양자 덩어리. 쿼크와 랩톤 상태의 양자 집합체입니다. 해당 상태를 유지시켜주는 단단한 용기속에 보관되어 있습니다. +item.steam-power-dimension-armour.name=차원 장갑 +item.steam-power-dimension-armour.description=차원 장갑. 양자 수준부터 조직하여 만들어진 장갑입니다. 내부구조가 특수해 가벼우면서 견고합니다. liquid.steam-power-high-pressure-steam.name=고압 증기 liquid.steam-power-high-pressure-steam.description=고압 증기. liquid.steam-power-hot-cryofluid.name=뜨거운 냉각수 diff --git a/content/blocks/production/matter-disintegrator.json b/content/blocks/production/matter-disintegrator.json new file mode 100644 index 0000000..f2a0c06 --- /dev/null +++ b/content/blocks/production/matter-disintegrator.json @@ -0,0 +1,18 @@ +category: crafting +requirements:[ + computer/20 + dense-alloy/100 + plastanium/40 + surge-alloy/60 + uranium/40 + silicon/40 + graphite/40 +] +itemCapacity: 20 +craftTime: 360 +outputItem: quantum-mass/1 +size: 3 +health: 400 +craftEffect: none +updateEffect: none +research: metal-smelter diff --git a/content/blocks/turrets/tesla.json b/content/blocks/turrets/tesla.json index 633508f..9b087bc 100644 --- a/content/blocks/turrets/tesla.json +++ b/content/blocks/turrets/tesla.json @@ -8,7 +8,7 @@ requirements:[ ] powerUse:2 health:1000 -reload:16 +reload:24 range:128 shootEffect:lightningShoot recoil:0 diff --git a/mod.json b/mod.json index 2e07e27..c25277f 100644 --- a/mod.json +++ b/mod.json @@ -1,7 +1,7 @@ name:steam-power displayName:Steam Power -description:"[orange]Realistic power generation. \n\n[cyan]Developer : [green]younggam\n[yellow]Thanks to : sirius, 우파루파, Lily, sk7725\n\n[red]Need younggam/multi-lib" +description:"[orange]Realistic power generation. \n\n[cyan]Developer : [green]younggam\n[yellow]Thanks to : sirius, 우파루파, Lily, sk7725\n\n[red]Need younggam/multi-lib2" author: younggam -version: 1.7.1 +version: 1.8.0 minGameVersion: 104 -dependencies:["multi-lib"] +dependencies:["multi-lib2"] diff --git a/scripts/blocks/liquid/liquid-heat-exchanger.js b/scripts/blocks/liquid/liquid-heat-exchanger.js index 2337f5c..28a91cc 100644 --- a/scripts/blocks/liquid/liquid-heat-exchanger.js +++ b/scripts/blocks/liquid/liquid-heat-exchanger.js @@ -8,7 +8,7 @@ const liquidHeatExchanger=heatL.heatGiver(GenericCrafter,GenericCrafter.GenericC this.stats.add(BlockStat.output,this.outputLiquid.liquid,this.outputLiquid.amount*60,true); this.stats.remove(BlockStat.input); this.stats.add(BlockStat.input,this.consumes.get(ConsumeType.liquid).liquid,this.consumes.get(ConsumeType.liquid).amount*60,true); - this.stats.add(BlockStat.basePowerGeneration,String(this.heatProduction*60.0)+" heat/sec",""); + this.stats.add(BlockStat.basePowerGeneration,this.heatProduction*60.0+Core.bundle.get("steam-power-heat-per-sec"),""); this.stats.remove(BlockStat.productionTime); }, setBars(){ diff --git a/scripts/blocks/power/geothermal-system.js b/scripts/blocks/power/geothermal-system.js index a468d87..e4369a2 100644 --- a/scripts/blocks/power/geothermal-system.js +++ b/scripts/blocks/power/geothermal-system.js @@ -5,7 +5,7 @@ const geothermalSystem=heatL.heatGiver(Block,TileEntity,"geothermal-system",{ heatCapacity:500, setStats(){ this.super$setStats(); - this.stats.add(BlockStat.basePowerGeneration,String(this.heatProduction*60.0)+" heat/sec",""); + this.stats.add(BlockStat.basePowerGeneration,this.heatProduction*60.0+Core.bundle.get("steam-power-heat-per-sec"),""); this.stats.add(BlockStat.tiles,this.attribute); }, setBars(){ diff --git a/scripts/blocks/power/nuclear-fusion-reactor.js b/scripts/blocks/power/nuclear-fusion-reactor.js index 636509a..e3433c4 100644 --- a/scripts/blocks/power/nuclear-fusion-reactor.js +++ b/scripts/blocks/power/nuclear-fusion-reactor.js @@ -16,7 +16,7 @@ const nuclearFusionReactor=heatL.heatRecator(LiquidConverter,GenericCrafter.Gene this.stats.add(BlockStat.output,this.outputLiquid.liquid,this.outputLiquid.amount*60,true); this.stats.remove(BlockStat.input); this.stats.add(BlockStat.input,this.consumes.get(ConsumeType.liquid).liquid,this.consumes.get(ConsumeType.liquid).amount*60,true); - this.stats.add(BlockStat.basePowerGeneration,String(this.heatProduction*60.0)+" heat/sec",""); + this.stats.add(BlockStat.basePowerGeneration,this.heatProduction*60.0+Core.bundle.get("steam-power-heat-per-sec"),""); this.stats.remove(BlockStat.powerUse); this.stats.add(BlockStat.powerUse,this.powerCons*60,StatUnit.powerSecond); }, diff --git a/scripts/blocks/power/nuclear-reactor.js b/scripts/blocks/power/nuclear-reactor.js index 4ea94ab..550c9c0 100644 --- a/scripts/blocks/power/nuclear-reactor.js +++ b/scripts/blocks/power/nuclear-reactor.js @@ -20,7 +20,7 @@ const nuclearReactor=heatL.heatRecator(LiquidConverter,GenericCrafter.GenericCra this.stats.add(BlockStat.output,this.outputLiquid.liquid,this.outputLiquid.amount*60,true); this.stats.remove(BlockStat.input); this.stats.add(BlockStat.input,this.consumes.get(ConsumeType.liquid).liquid,this.consumes.get(ConsumeType.liquid).amount*60,true); - this.stats.add(BlockStat.basePowerGeneration,String(this.heatProduction*60.0)+" heat/sec",""); + this.stats.add(BlockStat.basePowerGeneration,this.heatProduction*60.0+Core.bundle.get("steam-power-heat-per-sec"),""); }, setBars(){ this.super$setBars(); diff --git a/scripts/blocks/production/advanced-furnace.js b/scripts/blocks/production/advanced-furnace.js index f839bbc..0a24df4 100644 --- a/scripts/blocks/production/advanced-furnace.js +++ b/scripts/blocks/production/advanced-furnace.js @@ -1,57 +1,87 @@ -const multiLib=require("multi-lib/wrapper"); +const multiLib=require("multi-lib2/wrapper"); const furnaces=this.global.furnaces; -const advancedFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCrafterEntity,"advanced-furnace",{ +const advancedFurnace=multiLib.extend(GenericCrafter,"advanced-furnace", +[ + { + input:{ + items:["steam-power-copper-ore/1"], + power:0.6 + }, + output:{ + items:["copper/1"], + liquids:["slag/1"] + }, + craftTime:50 + }, + { + input:{ + items:["steam-power-lead-ore/1"], + power:0.6 + }, + output:{ + items:["lead/1"], + liquids:["slag/1"] + }, + craftTime:50 + }, + { + input:{ + items:["steam-power-iron-ore/1"], + }, + output:{ + items:["steam-power-iron/1"], + liquids:["slag/1"] + }, + craftTime:100 + }, + { + input:{ + items:["steam-power-titanium-ore/1"], + power:0.6 + }, + output:{ + items:["titanium/1"], + liquids:["slag/1"] + }, + craftTime:50 + }, + { + input:{ + items:["sand/1"], + power:0.6 + }, + output:{ + items:["steam-power-glass/1"], + liquids:[] + }, + craftTime:50 + }, + { + input:{ + items:["scrap/1"], + power:0.6 + }, + output:{ + liquids:["slag/2"] + }, + craftTime:25 + }, +], +{ setBars(){ this.super$setBars(); //initialize this.bars.remove("liquid"); - //this.bars.remove("items"); - var powerBarI=false; - var powerBarO=false; - //decdes whether show poweroutput bar - for(var i=0;i - new Bar(prov(()=>Core.bundle.format("bar.poweroutput",entity.block.getPowerProduction(entity.tile)*60*entity.timeScale)),prov(()=>Pal.powerBar),floatp(()=>entity!=null?entity.getPowerStat():0)) - )); - }else if(!powerBarI){ - this.outputsPower=true; - }else{ - this.outputsPower=false; - } - //show current Items amount - if(this.itemList[0]!=null){ - (function(itemCapacity,itemList,bars){ - bars.add("items",func(entity=> - new Bar(prov(()=>Core.bundle.format("bar.items",entity.getItemStat().join('/'))) - ,prov(()=>Pal.items) - ,floatp(()=>entity.items.total()/(itemCapacity*itemList.length))) - )); - })(this.itemCapacity,this.itemList,this.bars) - } + this.bars.remove("items"); //display every Liquids that can contain - if(this.liquidList[0]!=null){ - for(var i=0;i - new Bar(prov(()=>liquidList[i].localizedName),prov(()=>liquidList[i].barColor()),floatp(()=>entity.liquids.get(liquidList[i])/liquidCapacity)) - )); - })(i,this.liquidList,this.liquidCapacity,this.bars) - } + var i=0; + if(!this.liquidSet.isEmpty()){ + this.liquidSet.each(cons(k=>{ + this.bars.add("liquid"+i,func(entity=> + new Bar(prov(()=>k.localizedName),prov(()=>k.barColor()),floatp(()=>entity.liquids.get(k)/this.liquidCapacity)) + )); + i++; + })); } this.bars.add("multiplier",func(entity=> new Bar(prov(()=>Core.bundle.formatFloat("bar.efficiency",entity.warmup*100*(entity.items.get(Items.coal)>0?2.5:1),1)),prov(()=>Pal.ammo),floatp(()=>entity.warmup*(entity.items.get(Items.coal)>0?2.5:1))) @@ -65,93 +95,43 @@ const advancedFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCraft this.stats.remove(BlockStat.productionTime); this.stats.add(BlockStat.booster,new ItemListValue(ItemStack(Items.coal,1))) this.stats.add(BlockStat.boostEffect,2.5,StatUnit.timesSpeed); + var recLen=this.recs.length; //crafTimes - for(var i=0;i0) this.stats.add(BlockStat.powerUse,this.recs[i].input.power*60,StatUnit.powerSecond); + else this.stats.add(BlockStat.powerUse,0,StatUnit.powerSecond); } } }, //custom function for consumeing items and liquids customCons(tile,i){ const entity=tile.ent(); - entity.saveCond(this.checkCond(tile,i)); - if(this.checkCond(tile,i)){ + var excute=this.checkCond(tile,i); + entity.saveCond(excute); + if(excute){ //do produce if(entity.getProgress(i)!=0&&entity.getProgress(i)!=null){ entity.progress=entity.getProgress(i); entity.saveProgress(i,0); } - entity.progress+=(entity.items.get(Items.coal)>0?2.5:1)*entity.warmup*this.getProgressIncrease(entity,this.craftTimes[i]); + entity.progress+=(entity.items.get(Items.coal)>0?2.5:1)*entity.warmup*this.getProgressIncreaseA(entity,i,this.recs[i].craftTime); if(entity.items.get(Items.coal)>0){ var oldProgress=entity.totalProgress; var prog=Time.delta() @@ -169,22 +149,14 @@ const advancedFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCraft if(Mathf.chance(Time.delta()*this.updateEffectChance)){ Effects.effect(this.updateEffect,entity.x+Mathf.range(this.size*4),entity.y+Mathf.range(this.size*4)); } - }else{ - entity.warmup=Mathf.lerp(entity.warmup,0,0.02); - } + }else entity.warmup=Mathf.lerp(entity.warmup,0,0.02); }, //decides which item to accept acceptItem(item,tile,source){ const entity=tile.ent(); - if(entity==null||entity.items==null) return; + if(typeof entity["items"]!=="object") return false; if(entity.items.get(item)>=this.itemCapacity) return false; - if(item==Items.coal) return true; - for(var i in this.inputItemList){ - if(item==this.inputItemList[i]){ - return true; - } - } - return false; + return item==Items.coal||this.inputItemSet.contains(item); }, placed(tile){ this.super$placed(tile); @@ -200,19 +172,16 @@ const advancedFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCraft customUpdate(tile){ const entity=tile.ent(); if(entity==null) return; - if(entity.getToggle()==-1||entity.getToggle()==this.input.length)entity.warmup=Mathf.lerp(entity.warmup,0,0.02); - if(Time.time()%60this.itemCapacity) return true; - } + var items=this.recs[i].output.items; + for(var j=0,len=items.length;jthis.itemCapacity) return true; } return false; }, @@ -221,13 +190,10 @@ const advancedFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCraft const old=entity.getToggle(); if((old==1||old==0)&&value!=1&&value!=0) furnaces.sizes[tile.getTeam()]--; if((value==1||value==0)&&old!=1&&old!=0) furnaces.sizes[tile.getTeam()]++; - print(furnaces.sizes[tile.getTeam()]); - if(old>=0&&old=0) entity.saveProgress(old,entity.progress); + if(value==-1) entity.saveCond(false); entity.progress=0; - entity.modifyToggle(value); + entity.setToggle(value); }, random:new Rand(0), draw(tile){ @@ -258,31 +224,5 @@ const advancedFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCraft this.super$load(); this.topRegion=Core.atlas.find(this.name+"-top") } -}, -{ - _output:[ - [[["copper",1] ] ,[["slag",1]] ,null], - [[["lead",1]] ,[["slag",1] ] ,null], - [[["titanium",1]] ,[["slag",1]] ,null], - [[["steam-power-iron",1]] ,[["slag",1]] ,null], - [[["steam-power-glass",1]],null,null], - [null,[["slag",2]],null] - ], - _input:[ - [[["steam-power-copper-ore",1] ] ,null ,0.6], - [[["steam-power-lead-ore",1] ] ,null ,0.6], - [[["steam-power-titanium-ore",1] ] ,null ,0.6], - [[["steam-power-iron-ore",1] ] ,null ,0.6], - [[["sand",1]],null,0.6], - [[["scrap",1]],null,0.6] - ], - craftTimes:[50,50,50,50,50,25], - output:[], - input:[], - itemList:[], - liquidList:[], - isSameOutput:[], -}); -advancedFurnace.enableInv=true; +},{}); advancedFurnace.dumpToggle=false; -//advancedFurnace.entityType=prov(()=>extend(); diff --git a/scripts/blocks/production/advanced-steam-generator.js b/scripts/blocks/production/advanced-steam-generator.js index bfb430e..7265d7a 100644 --- a/scripts/blocks/production/advanced-steam-generator.js +++ b/scripts/blocks/production/advanced-steam-generator.js @@ -4,13 +4,14 @@ const advancedSteamGenerator=heatL.heatUser(LiquidConverter,GenericCrafter.Gener heatCons:7/60, setStats(){ this.super$setStats(); + var heatPSec=Core.bundle.get("steam-power-heat-per-sec"); this.stats.remove(BlockStat.output); this.stats.add(BlockStat.output,this.outputLiquid.liquid,this.outputLiquid.amount*60,true); this.stats.add(BlockStat.output,Vars.content.getByName(ContentType.liquid,"steam-power-high-pressure-steam"),this.outputLiquid.amount*60,true); this.stats.remove(BlockStat.input); - this.stats.add(BlockStat.input,String(this.heatCons*60.0)+" heat/sec",""); + this.stats.add(BlockStat.input,this.heatCons*60.0+heatPSec,""); this.stats.add(BlockStat.input,this.consumes.get(ConsumeType.liquid).liquid,this.consumes.get(ConsumeType.liquid).amount*60,true); - this.stats.add(BlockStat.input,String(this.heatCons*60.0)+" heat/sec",""); + this.stats.add(BlockStat.input,this.heatCons*60.0+heatPSec,""); this.stats.add(BlockStat.input,this.consumes.get(ConsumeType.liquid).liquid,this.consumes.get(ConsumeType.liquid).amount*60,true); this.stats.remove(BlockStat.productionTime); }, diff --git a/scripts/blocks/production/blast-furnace.js b/scripts/blocks/production/blast-furnace.js index 3bf6815..87c652e 100644 --- a/scripts/blocks/production/blast-furnace.js +++ b/scripts/blocks/production/blast-furnace.js @@ -1,183 +1,81 @@ -const multiLib=require("multi-lib/wrapper"); +const multiLib=require("multi-lib2/wrapper"); const furnaces=this.global.furnaces; -const blastFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCrafterEntity,"blast-furnace",{ - _configure(entity,value){ - for(var i=0;i=1){ - this.customProd(tile,z); - } - break; - } - } - if(z==this.input.length) entity.warmup=Mathf.lerpDelta(entity.warmup,0,0.002); - //dump - //dump - var exitI=false; - var exitL=false; - //when normal button checked - if(entity.getToggle()!=this.input.length){ - if(entity.timer.get(this.timerDump,this.dumpTime)){ - //dump items in order - for(var ii=0;ii0&&((!this.dumpToggle)||entity.getToggle()==ii)){ - this.tryDump(tile,this.output[ii][0][ij].item); - exitI=true; - break; - } - } - if(exitI){ - exitI=false; - break; - } - } - } - } - //dump liquids in order - for(var jj=0;jj0.001&&((!this.dumpToggle)||entity.getToggle()==jj)){ - this.tryDumpLiquid(tile,this.output[jj][1][i].liquid); - exitL=true; - break; - } - } - if(exitL){ - exitL=false; - break; - } - } - } - } - //when trash button is checked. dump everything if possible/ - else if(entity.getToggle()==this.input.length){ - //dump items and liquids even input - if(entity.timer.get(this.timerDump,this.dumpTime)&&entity.items.total()>0){ - this.tryDump(tile); - } - if(entity.liquids.total()>0.01){ - for(var i=0;i0.01){ - this.tryDumpLiquid(tile,this.liquidList[i]); - break; - } - } - } - } + { + input:{ + items:["sand/1"], + }, + output:{ + items:["steam-power-glass/1"], + liquids:[] + }, + craftTime:100 }, - customCons(tile,i){ - const entity=tile.ent(); - entity.saveCond(this.checkCond(tile,i)); - if(this.checkCond(tile,i)){ - //do produce - if(entity.getProgress(i)!=0&&entity.getProgress(i)!=null){ - entity.progress=entity.getProgress(i); - entity.saveProgress(i,0); - } - entity.progress+=(entity.items.get(Items.coal)>0?2.5:1)*entity.warmup*this.getProgressIncrease(entity,this.craftTimes[i]); - if(entity.items.get(Items.coal)>0){ - var oldProgress=entity.totalProgress; - var prog=entity.warmup*Time.delta() - entity.totalProgress+=prog; - if(entity.totalProgress>=120) { - entity.items.remove(Items.coal,1); - entity.totalProgress=0; - } - } - entity.warmup=Mathf.lerpDelta(entity.warmup,1,0.002); - if(Mathf.equal(entity.warmup,1,0.002)){ - entity.warmup=1; - } - if(Mathf.chance(Time.delta()*this.updateEffectChance)){ - Effects.effect(this.updateEffect,entity.x+Mathf.range(this.size*4),entity.y+Mathf.range(this.size*4)); - } - } + { + input:{ + items:["scrap/1"], + }, + output:{ + liquids:["slag/2"] + }, + craftTime:50 }, +], +{ setBars(){ this.super$setBars(); //initialize this.bars.remove("liquid"); - //this.bars.remove("items"); - var powerBarI=false; - var powerBarO=false; - //decdes whether show poweroutput bar - for(var i=0;i - new Bar(prov(()=>Core.bundle.format("bar.poweroutput",entity.block.getPowerProduction(entity.tile)*60*entity.timeScale)),prov(()=>Pal.powerBar),floatp(()=>entity!=null?entity.getPowerStat():0)) - )); - }else if(!powerBarI){ - this.outputsPower=true; - }else{ - this.outputsPower=false; - } - //show current Items amount - if(this.itemList[0]!=null){ - (function(itemCapacity,itemList,bars){ - bars.add("items",func(entity=> - new Bar(prov(()=>Core.bundle.format("bar.items",entity.getItemStat().join('/'))) - ,prov(()=>Pal.items) - ,floatp(()=>(entity.items.total()-entity.items.get(Items.coal))/(itemCapacity*itemList.length))) - )); - })(this.itemCapacity,this.itemList,this.bars) - } + this.bars.remove("power") //display every Liquids that can contain - if(this.liquidList[0]!=null){ - for(var i=0;i - new Bar(prov(()=>liquidList[i].localizedName),prov(()=>liquidList[i].barColor()),floatp(()=>entity.liquids.get(liquidList[i])/liquidCapacity)) - )); - })(i,this.liquidList,this.liquidCapacity,this.bars) - } + var i=0; + if(!this.liquidSet.isEmpty()){ + this.liquidSet.each(cons(k=>{ + this.bars.add("liquid"+i,func(entity=> + new Bar(prov(()=>k.localizedName),prov(()=>k.barColor()),floatp(()=>entity.liquids.get(k)/this.liquidCapacity)) + )); + i++; + })); } this.bars.add("multiplier",func(entity=> new Bar(prov(()=>Core.bundle.formatFloat("bar.efficiency",entity.warmup*100*(entity.items.get(Items.coal)>0?2.5:1),1)),prov(()=>Pal.ammo),floatp(()=>entity.warmup*(entity.items.get(Items.coal)>0?2.5:1))) @@ -185,110 +83,132 @@ const blastFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCrafterE }, //for dislpying info setStats(){ + this.itemList[this.itemList.length]=Items.coal; this.super$setStats(); this.stats.remove(BlockStat.powerUse); this.stats.remove(BlockStat.productionTime); this.stats.add(BlockStat.booster,new ItemListValue(ItemStack(Items.coal,1))) this.stats.add(BlockStat.boostEffect,2.5,StatUnit.timesSpeed); + var recLen=this.recs.length; //crafTimes - for(var i=0;i0?2.5:1)*entity.warmup*this.getProgressIncreaseA(entity,i,this.recs[i].craftTime); + if(entity.items.get(Items.coal)>0){ + var oldProgress=entity.totalProgress; + var prog=Time.delta() + entity.totalProgress+=prog; + if(entity.totalProgress>=120) { + entity.items.remove(Items.coal,1); + entity.totalProgress=0; + } + if(entity.totalProgress%120<=prog&&entity.totalProgress!=0&&!(oldProgress<=prog)) entity.items.remove(Items.coal,1); + } + entity.warmup=Mathf.lerpDelta(entity.warmup,1,0.002); + if(Mathf.equal(entity.warmup,1,0.002)){ + entity.warmup=1; + } + if(Mathf.chance(Time.delta()*this.updateEffectChance)){ + Effects.effect(this.updateEffect,entity.x+Mathf.range(this.size*4),entity.y+Mathf.range(this.size*4)); } }, //decides which item to accept acceptItem(item,tile,source){ const entity=tile.ent(); - if(entity==null||entity.items==null) return; + if(typeof entity["items"]!=="object") return false; if(entity.items.get(item)>=this.itemCapacity) return false; - if(item==Items.coal) return true; - for(var i in this.inputItemList){ - if(item==this.inputItemList[i]){ - return true; - } - } - return false; + return item==Items.coal||this.inputItemSet.contains(item); }, - //custom function that checks space for item and liquid - checkoutput(tile,i){ + placed(tile){ + this.super$placed(tile); + this.register(tile.entity,1); + }, + register(entity,value){ + if(entity!=null)furnaces.update(entity,value); + }, + removed(tile){ + this.register(tile.entity,1); + this.register(tile.entity,0); + }, + customUpdate(tile){ + const entity=tile.ent(); + if(entity==null) return; + if(entity.getToggle()==-1)entity.warmup=Mathf.lerp(entity.warmup,0,0.02); + if(Time.time()%60this.itemCapacity) return true; + var recLen=this.recs.length; + var eItems=entity.items; + var eLiquids=entity.liquids; + //to not rewrite whole update + if(typeof this["customUpdate"]==="function") this.customUpdate(tile); + for(var i=0;i=1) this.customProd(tile,i); + break; + } + } + if(i==recLen) { + entity.warmup=Mathf.lerp(entity.warmup,0,0.02); + entity.saveCond(false) + } + //TODO 반복문 줄이기 + if(entity.timer.get(this.timerDump,this.dumpTime)&&eItems.total()>0){ + var itemIter=this.outputItemSet.iterator(); + while(itemIter.hasNext()){ + var item=itemIter.next(); + if(eItems.has(item)){ + this.tryDump(tile,item); + break; + } + } + } + if(eLiquids.total()>0.001){ + var liquidIter=this.outputLiquidSet.iterator(); + while(liquidIter.hasNext()){ + var liquid=liquidIter.next(); + if(eLiquids.get(liquid)>0.001){ + this.tryDumpLiquid(tile,liquid); + break; + } } } - return false; + }, + _configure(entity,value){ + const i=entity.getToggle(); + if(i>=0) entity.saveProgress(i,entity.progress); + entity.progress=0; + entity.setToggle(value); }, random:new Rand(0), draw(tile){ @@ -319,31 +239,6 @@ const blastFurnace=multiLib.extend(GenericCrafter,GenericCrafter.GenericCrafterE this.super$load(); this.topRegion=Core.atlas.find(this.name+"-top") } -}, -{ - _output:[ - [[["copper",1] ] ,[["slag",1]] ,null], - [[["lead",1]] ,[["slag",1]] ,null], - [[["steam-power-iron",1]] ,[["slag",1] ] ,null], - [[["titanium",1]] ,[["slag",1]] ,null], - [[["steam-power-glass",1]],null,null], - [null,[["slag",2]],null] - ], - _input:[ - [[["steam-power-copper-ore",1]] ,null ,null], - [[["steam-power-lead-ore",1]] ,null ,null], - [[["steam-power-iron-ore",1]] ,null ,null], - [[["steam-power-titanium-ore",1]] ,null ,null], - [[["sand",1]],null,null], - [[["scrap",1]],null,null] - ], - craftTimes:[100,100,100,100,100,50], - output:[], - input:[], - itemList:[], - liquidList:[], - isSameOutput:[], -}); -blastFurnace.enableInv=false; +},{}); blastFurnace.dumpToggle=false; blastFurnace.configurable=false; diff --git a/scripts/blocks/production/bullet-mill.js b/scripts/blocks/production/bullet-mill.js index 9bb6f07..4071a4d 100644 --- a/scripts/blocks/production/bullet-mill.js +++ b/scripts/blocks/production/bullet-mill.js @@ -1,26 +1,44 @@ -const multiLib=require("multi-lib/wrapper"); -const bulletMill=multiLib.extend(GenericCrafter,GenericCrafter.GenericCrafterEntity,"bullet-mill",{ - -}, -{ - _output:[ - [[["steam-power-bullet",2]] ,null ,null], - [[["steam-power-armor-piercing-shell",2]] ,null ,null], - [[["steam-power-cluster-bullet",2]] ,null ,null], - [[["steam-power-high-explosive",1] ] ,null ,null], - ], - _input:[ - [[["lead",2] ,["coal",1]] ,null ,0.5], - [[["steam-power-steel",1] ,["pyratite",1],["titanium",1]] ,null ,1], - [[["lead",2],["steam-power-iron",1] ,["pyratite",2] ] ,null ,1], - [[["lead",1],["steam-power-iron",1] ,["blast-compound",1] ] ,null ,1], - ], - craftTimes:[80,90,90,90], - output:[], - input:[], - itemList:[], - liquidList:[], - isSameOutput:[], -}); -bulletMill.enableInv=true; +const multiLib=require("multi-lib2/wrapper"); +const bulletMill=multiLib.extend(GenericCrafter,"bullet-mill", +[ + { + input:{ + items:["lead/2","coal/1"], + power:0.5 + }, + output:{ + items:["steam-power-bullet/2"] + }, + }, + { + input:{ + items:["steam-power-steel/1","pyratite/1","titanium/1"], + power:1 + }, + output:{ + items:["steam-power-armor-piercing-shell/2"] + }, + craftTime:90 + }, + { + input:{ + items:["lead/2","steam-power-iron/1","pyratite/2"], + power:1 + }, + output:{ + items:["steam-power-cluster-bullet/2"] + }, + craftTime:90 + }, + { + input:{ + items:["lead/1","steam-power-iron/1","blast-compound/1"], + power:1 + }, + output:{ + items:["steam-power-high-explosive/2"] + }, + craftTime:90 + }, +],{},{}); bulletMill.dumpToggle=false; diff --git a/scripts/blocks/production/burner.js b/scripts/blocks/production/burner.js index 6fee83c..48ad787 100644 --- a/scripts/blocks/production/burner.js +++ b/scripts/blocks/production/burner.js @@ -6,7 +6,7 @@ const burner=heatL.heatGiver(Block,TileEntity,"burner",{ heatProduction:5/12, setStats(){ this.super$setStats(); - this.stats.add(BlockStat.basePowerGeneration,String(this.heatProduction*60.0)+" heat/sec",""); + this.stats.add(BlockStat.basePowerGeneration,this.heatProduction*60.0+Core.bundle.get("steam-power-heat-per-sec"),""); this.stats.add(BlockStat.productionTime,2,StatUnit.seconds); }, setBars(){ diff --git a/scripts/blocks/production/matter-disintegrator.js b/scripts/blocks/production/matter-disintegrator.js index df50f04..f2dbf87 100644 --- a/scripts/blocks/production/matter-disintegrator.js +++ b/scripts/blocks/production/matter-disintegrator.js @@ -1,7 +1,12 @@ function getItem(name){ return Vars.content.getByName(ContentType.item,name); -}; -const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ +} +Blocks.overdriveProjector.consumes.add(new ConsumeItemFilter(boolf(item=>item==Items.phasefabric||item==getItem("steam-power-quantum-mass")))).boost(); +Blocks.mendProjector.consumes.add(new ConsumeItemFilter(boolf(item=>item==Items.phasefabric||item==getItem("steam-power-quantum-mass")))).boost(); +Blocks.forceProjector.consumes.add(new ConsumeItemFilter(boolf(item=>item==Items.phasefabric||item==getItem("steam-power-quantum-mass")))).boost(); +const heatL=require("heatWrapper"); +const matterDisintegrator=heatL.heatUser(GenericCrafter,GenericCrafter.GenericCrafterEntity,"matter-disintegrator",{ + heatCapacity:3000, itemValues:[], tmpImage:null, pauseImg:null, @@ -9,7 +14,7 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ cancelImg:null, invFrag:extend(BlockInventoryFragment,{ visible:false, - isShown(){ return this.visible}, + isShown(){ return this.visible;}, showFor(t){ this.visible=true; this.super$showFor(t); @@ -21,7 +26,7 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ }), _containerItems:[], _containerItemMap:new IntMap(4,1), - getContainerItems(){return this._containerItems}, + getContainerItems(){return this._containerItems;}, init(){ this.super$init(); this._containerItems=[new ItemStack(getItem("steam-power-semiconductor"),1),new ItemStack(getItem("metaglass"),2),new ItemStack(getItem("steam-power-dense-alloy"),2)]; @@ -34,10 +39,24 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ value+=Math.pow(Math.max(item.cost,0),0.5); value+=regExpA.test(item.name)?0.8:0; value+=regExpB.test(item.name)?1.6:0; - value-=(item.explosiveness+item.flammability+item.radioactivity)*0.25 - this.itemValues[item.id]=Math.max(value,0.1) + value-=(item.explosiveness+item.flammability+item.radioactivity)*0.25; + this.itemValues[item.id]=Math.max(value*10,1); })); }, + setStats(){ + this.super$setStats(); + this.stats.remove(BlockStat.itemCapacity); + this.stats.add(BlockStat.itemCapacity,"20/10/5 {0}",StatUnit.items.localized()); + this.stats.add(BlockStat.booster,Core.bundle.get("steam-power-heat-cond"),"500"); + this.stats.add(BlockStat.boostEffect,"0~200{0}",StatUnit.timesSpeed.localized()); + }, + setBars(){ + this.super$setBars(); + this.bars.add("heat",func(entity=> + new Bar(prov(()=>Core.bundle.format("bar.heat")+": "+(typeof(entity["getHeat"])!=="function"?0.0:entity.getHeat()).toFixed(1)),prov(()=>Pal.lightFlame),floatp(()=>typeof(entity["getHeat"])!=="function"?0:entity.getHeat()/this.heatCapacity)) + )); + this.bars.remove("items"); + }, acceptItem(item,tile,source){ if(item==this.outputItem.item) return false; const items=tile.ent().items; @@ -96,23 +115,32 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ update(tile){ const entity=tile.ent(); if(entity.isFragShown()&&!this.invFrag.isShown()&&entity.items.total()>0){ this.invFrag.showFor(tile);} + if(entity.timer.get(this.timerDump,this.dumpTime)) this.tryDump(tile,this.outputItem.item); + entity.coolDownHeat(); if(entity.isPaused()||entity.power.status<=0) return; - if(entity.progress==0){ - const que=entity.getItemQueue(); - if(!que.isEmpty()){ - var tmp=que.removeFirst(); - entity.items.remove(tmp,1); - entity.setCurrentItem(tmp); - entity.progress+=this.getProgressIncrease(entity,this.craftTime); + if(entity.progress<1){ + var prog=this.getProgressIncrease(entity,this.craftTime); + if(entity.getCurrentItem()==null){ + const que=entity.getItemQueue(); + if(!que.isEmpty()){ + var tmp=que.removeFirst(); + entity.items.remove(tmp,1); + entity.setCurrentItem(tmp); + entity.setValue(this.itemValues[tmp.id]); + entity.progressValue(prog); + entity.progress+=prog; + } + }else { + entity.progressValue(prog); + entity.progress+=prog; } - }else if(entity.progress>=1){ + }else if(entity.progress>=1&&entity.items.has(this._containerItems)&&entity.items.get(this.outputItem.item)<10){ this.offloadNear(tile,this.outputItem.item); entity.progress=0; - entity.setCurrentItem(null); - }else entity.progress+=this.getProgressIncrease(entity,this.craftTime); + } }, buildCommon(entity){ - var cb=Core.bundle + var cb=Core.bundle; var display2=cb.get(this.name+"-display-2"); var display3=cb.get(this.name+"-display-3"); if(this.dialog0==null){ @@ -133,13 +161,13 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ valueTable.table(cons(t=>{ var a=0; for(var i=0;i{ @@ -147,13 +175,13 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ this.dialog0.hide(); this.dialog1.hide(); } - })) + })); var cont=this.dialog0.cont; cont.clear(); cont.table(cons(t=>{ t.add(cb.get(this.name+"-title-0")); t.addImage(Icon.warning).color(Pal.remove).visible(boolp(()=>entity.isContainerValid())).padLeft(8); - })).row() + })).row(); cont.addImage().height(4).pad(6).color(Pal.gray).growX().width(300).row(); cont.table(cons(t=>{ var items=entity.items; @@ -162,20 +190,20 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ t.addImage(itemStack.item.icon(Cicon.medium)).size(48).padBottom(8).padTop(8); (function(i,item,amount){ t.add(items.get(item)+"/").padLeft(8).update(cons(e=>e.setText(items.get(item)+"/"))); - t.add(String(amount)).padLeft(4).padRight(16).update(cons(e=>{if(items.get(item){if(items.get(item){ - t.add(cb.get(this.name+"-title-1")).padTop(16);; + t.add(cb.get(this.name+"-title-1")).padTop(16); t.addButton(cons(b=>{ this.tmpImage=b.add(this.pauseImg); }),run(()=>{ - entity.pause() + entity.pause(); this.tmpImage.setElement(entity.isPaused()?this.playImg:this.pauseImg); })).size(48).padLeft(8); t.addImageButton(Icon.info,run(()=>{ - Vars.ui.showOkText(cb.get(this.name+"-display-0"),cb.get(this.name+"-display-1"),run(()=>{})) + Vars.ui.showOkText(cb.get(this.name+"-display-0"),cb.get(this.name+"-display-1"),run(()=>{})); })).size(48).padLeft(8); t.addImageButton(Icon.book,run(()=>{ this.dialog1.show(); @@ -186,19 +214,19 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ cont.add(cb.get(this.name+"-title-2")).padTop(16).row(); cont.addImage().height(4).pad(6).color(Pal.gray).growX().width(300).row(); cont.table(cons(tt=>{ - tt.add(new Label("")).update(cons(e=>e.setText(display2+" x"+(entity.power.status*entity.timeScale).toFixed(2)))).padRight(8); + tt.add(new Label("")).update(cons(e=>e.setText(display2+" x"+(entity.power.status*entity.timeScale+Math.max(0,entity.getHeat()/1250-0.4)).toFixed(2)))).padRight(8); tt.table(Tex.inventory).update(cons(t=>{ t.clear(); var cur=entity.getCurrentItem(),status=entity.power.status; - t.addImage(Icon.power).color(status<=0?Pal.remove:status>0.99?Pal.accent:Pal.lightOrange).padRight(4) + t.addImage(Icon.power).color(status<=0?Pal.remove:status>0.99?Pal.accent:Pal.lightOrange).padRight(4); if(cur!=null) { t.addImage(cur.icon(Cicon.medium)); var dots="",time=Time.time()%60/15; for(var i=1;i{ t.clear(); var que=entity.getItemQueue().iterator(),i=0,tmp,tmpAmount=0,last; @@ -217,7 +245,7 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ }else tmpAmount++; } if(i!=0)t.add(String(tmpAmount)); - })) + })); this.dialog0.show(); }, buildConfiguration(tile,table){ @@ -232,7 +260,7 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ this.invFrag.hide(); Vars.control.input.frag.config.hideConfig(); entity.switchFrag(); - })) + })); } entity.switchFrag(); }, @@ -241,29 +269,49 @@ const matterDisintegrator=extendContent(GenericCrafter,"matter-disintegrator",{ tile.entity.switchFrag(); this.invFrag.hide(); } - return true + return true; } -}); -matterDisintegrator.entityType=prov(()=>extend(GenericCrafter.GenericCrafterEntity,{ +}, +{ _pause:false, - isPaused(){ return this._pause}, - pause(){ this._pause=!this._pause}, - isContainerValid(){ return !this.items.has(this.block.getContainerItems())}, + isPaused(){ return this._pause;}, + pause(){ this._pause=!this._pause;}, + isContainerValid(){ return !this.items.has(this.block.getContainerItems());}, _isFragShown:false, - isFragShown(){ return this._isFragShown}, - switchFrag(){ this._isFragShown=!this._isFragShown}, + isFragShown(){ return this._isFragShown;}, + switchFrag(){ this._isFragShown=!this._isFragShown;}, _itemQueue:new Queue(20), - getItemQueue(){ return this._itemQueue}, + getItemQueue(){ return this._itemQueue;}, _currentItem:null, - getCurrentItem(){ return this._currentItem}, - setCurrentItem(a){ this._currentItem=a}, - _heat:25, + getCurrentItem(){ return this._currentItem;}, + setCurrentItem(a){ this._currentItem=a;}, + _value:0, + setValue(a){ this._value=a/100;}, + progressValue(b){ + this._value-=b; + if(this._value<=0) this._currentItem=null; + }, delta(){ - return Time.delta()*(this.timeScale+Math.max(0,this._heat/1000-2)) + return Time.delta()*(this.timeScale+Math.max(0,this._heat/1250-0.4)); }, -})); + write(stream){ + this.super$write(stream); + stream.writeFloat(this._heat); + stream.writeByte(this._itemQueue.size); + var que=this._itemQueue.iterator(); + while(que.hasNext()) stream.writeShort(que.next().id); + }, + read(stream,revision){ + this.super$read(stream,revision); + this._heat=stream.readFloat(); + var count=stream.readByte(); + var que=this._itemQueue; + que.clear(); + for(var i=0;i{ - if(typeof e["getCurrentItem"]==="function") return e.getCurrentItem()!=null&&!e.isPaused() + if(typeof e["getCurrentItem"]==="function") return e.getCurrentItem()!=null&&!e.isPaused()&&e.isContainerValid(); return false; -}));; +})); diff --git a/scripts/blocks/production/metal-smelter.js b/scripts/blocks/production/metal-smelter.js index 2cb7fb6..71e2280 100644 --- a/scripts/blocks/production/metal-smelter.js +++ b/scripts/blocks/production/metal-smelter.js @@ -1,24 +1,153 @@ -const multiLib=require("multi-lib/wrapper"); -const metalSmelter=multiLib.extend(GenericSmelter,GenericCrafter.GenericCrafterEntity,"metal-smelter",{ - -}, -{ - _output:[ - [[["surge-alloy",1]] ,null ,null], - [[["steam-power-steel",1]] ,null ,null], - [[["steam-power-dense-alloy",1]] ,null ,null], - ], - _input:[ - [[["copper",3],["lead",4],["titanium",2],["steam-power-iron",3]] ,null ,5], - [[["steam-power-iron",2] ,["graphite",1] ] ,null ,8], - [[["steam-power-steel",2] ,["steam-power-depleted-uranium",1],["plastanium",1]] ,null ,11], - ], - craftTimes:[75,90,90,90], - output:[], - input:[], - itemList:[], - liquidList:[], - isSameOutput:[], +const multiLib=require("multi-lib2/wrapper"); +const metalSmelter=multiLib.extend(GenericSmelter,"metal-smelter",[ + { + input:{ + items:["copper/3","lead/4","titanium/2","steam-power-iron/3"], + power:5 + }, + output:{ + items:["surge-alloy/1"] + }, + craftTime:75 + }, + { + input:{ + items:["steam-power-iron/2","graphite/1"], + power:8 + }, + output:{ + items:["steam-power-steel/1"] + }, + craftTime:90 + }, + { + input:{ + items:["steam-power-steel/2","steam-power-depleted-uranium/1","plastanium/1"], + power:11 + }, + output:{ + items:["steam-power-dense-alloy/1"] + }, + craftTime:90 + }, + { + input:{ + items:["steam-power-quantum-mass/1","plastanium/2","graphite/1"], + power:20 + }, + output:{ + items:["steam-power-dimension-armour/1"] + }, + craftTime:150 + }, +], +{/* + heatCons:[0,0.15,0.2,0.25], + heatCond:[0,100,360,840], + heatCapacity:1500, + customUpdate(tile){ + const entity=tile.ent(); + entity.coolDownHeat(); + if(entity.getHeat()>=this.heatCapacity){ + entity.kill(); + } + }, + setStats(){ + this.super$setStats(); + var heatPSec=Core.bundle.get("steam-power-heat-per-sec"); + var heatC=Core.bundle.get("steam-power-heat-cond"); + this.stats.remove(BlockStat.powerUse); + this.stats.remove(BlockStat.productionTime); + var recLen=this.recs.length; + for(var i=0;i + new Bar(prov(()=>Core.bundle.format("bar.heat")+": "+(typeof(entity["getHeat"])!=="function"?0.0:entity.getHeat()).toFixed(1)),prov(()=>Pal.lightFlame),floatp(()=>typeof(entity["getHeat"])!=="function"?0:entity.getHeat()/this.heatCapacity)) + )); + }, + inputsHeat(tile){ + return true; + }, + onDestroyed(tile){ + this.super$onDestroyed(tile); + Sounds.explosionbig.at(tile); + const entity=tile.ent(); + if(entity.getHeat()entity.getHeat(); + },*/ +},{/* + _heat:25, + getHeat(){ + return this._heat; + }, + setHeat(a){ + this._heat=a; + }, + addHeat(b){ + this._heat+=b; + }, + coolDownHeat(){ + if(this._heat>25){ + this._heat-=Time.delta()*this._heat/1200; + }else if(this._heat<25){ + this._heat=25; + } + }, + write(stream){ + this.super$write(stream); + stream.writeShort(this._toggle); + stream.writeFloat(this._heat); + }, + read(stream,revision){ + this.super$read(stream,revision); + this._toggle=stream.readShort(); + this._heat=stream.readFloat(); + }*/ }); -metalSmelter.enableInv=true; metalSmelter.dumpToggle=true; diff --git a/scripts/blocks/production/missile-factory.js b/scripts/blocks/production/missile-factory.js index 23ca278..86c9f85 100644 --- a/scripts/blocks/production/missile-factory.js +++ b/scripts/blocks/production/missile-factory.js @@ -1,22 +1,25 @@ -const multiLib=require("multi-lib/wrapper"); -const missileFactory=multiLib.extend(GenericCrafter,GenericCrafter.GenericCrafterEntity,"missile-factory",{ - -}, -{ - _output:[ - [[["steam-power-missile",1]] ,null ,null], - [[["steam-power-doom",1]] ,null ,null], - ], - _input:[ - [[["steam-power-iron",2],["plastanium",1] ,["blast-compound",2]] ,null ,null], - [[["steam-power-uranium",2],["thorium",2] ,["steam-power-missile",1]] ,null ,null], - ], - craftTimes:[90,90], - output:[], - input:[], - itemList:[], - liquidList:[], - isSameOutput:[], -}); -missileFactory.enableInv=true; +const multiLib=require("multi-lib2/wrapper"); +const missileFactory=multiLib.extend(GenericCrafter,"missile-factory", +[ + { + input:{ + items:["steam-power-iron/2","plastanium/1","blast-compound/2"], + power:3 + }, + output:{ + items:["steam-power-missile/1"] + }, + craftTime:90 + }, + { + input:{ + items:["steam-power-uranium/2","thorium/2","steam-power-missile/1"], + power:10 + }, + output:{ + items:["steam-power-doom/1"] + }, + craftTime:90 + }, +],{},{}); missileFactory.dumpToggle=true; diff --git a/scripts/blocks/production/semiconductor-plant.js b/scripts/blocks/production/semiconductor-plant.js index e9f2c0c..797bf0f 100644 --- a/scripts/blocks/production/semiconductor-plant.js +++ b/scripts/blocks/production/semiconductor-plant.js @@ -1,24 +1,35 @@ -const multiLib=require("multi-lib/wrapper"); -const semiconductorPlant=multiLib.extend(GenericCrafter,GenericCrafter.GenericCrafterEntity,"semiconductor-plant",{ - -}, -{ - _output:[ - [[["steam-power-circuit",1] ] ,null ,null], - [[["steam-power-semiconductor",1]] ,null ,null], - [[["steam-power-computer",1] ] ,null ,null], - ], - _input:[ - [[["lead",2] ,["silicon",1] ] ,null ,1], - [[["silicon",1] ,["graphite",1],["plastanium",1]] ,null ,3], - [[["steam-power-semiconductor",1] ,["steam-power-circuit",1],["surge-alloy",1]] ,null ,9], - ], - craftTimes:[120,120,240], - output:[], - input:[], - itemList:[], - liquidList:[], - isSameOutput:[], -}); -semiconductorPlant.enableInv=true; +const multiLib=require("multi-lib2/wrapper"); +const semiconductorPlant=multiLib.extend(GenericCrafter,"semiconductor-plant", +[ + { + input:{ + items:["lead/2","silicon/1"], + power:1, + }, + output:{ + items:["steam-power-circuit/1"] + }, + craftTime:120, + }, + { + input:{ + items:["silicon/1","graphite/1","plastanium/1"], + power:3, + }, + output:{ + items:["steam-power-semiconductor/1"] + }, + craftTime:120, + }, + { + input:{ + items:["steam-power-semiconductor/1","steam-power-circuit/1","surge-alloy/1"], + power:9, + }, + output:{ + items:["steam-power-computer/1"] + }, + craftTime:240, + }, +],{},{}); semiconductorPlant.dumpToggle=true; diff --git a/scripts/blocks/production/steam-generator.js b/scripts/blocks/production/steam-generator.js index c873cbf..e5652ba 100644 --- a/scripts/blocks/production/steam-generator.js +++ b/scripts/blocks/production/steam-generator.js @@ -7,7 +7,7 @@ const steamGenerator=heatL.heatUser(LiquidConverter,GenericCrafter.GenericCrafte this.stats.remove(BlockStat.output); this.stats.add(BlockStat.output,this.outputLiquid.liquid,this.outputLiquid.amount*60,true); this.stats.remove(BlockStat.input); - this.stats.add(BlockStat.input,String(this.heatCons*60.0)+" heat/sec",""); + this.stats.add(BlockStat.input,this.heatCons*60.0+Core.bundle.get("steam-power-heat-per-sec"),""); this.stats.add(BlockStat.input,this.consumes.get(ConsumeType.liquid).liquid,this.consumes.get(ConsumeType.liquid).amount*60,true); this.stats.remove(BlockStat.productionTime); }, diff --git a/scripts/blocks/turrets/ravage.js b/scripts/blocks/turrets/ravage.js index f2aa050..9b9fa74 100644 --- a/scripts/blocks/turrets/ravage.js +++ b/scripts/blocks/turrets/ravage.js @@ -120,6 +120,59 @@ plasma2.lifetime=160; plasma2.splashDamageRadius=30; plasma2.splashDamage=600; plasma2.hitSound=Sounds.artillery; +/*const plasma3=extend(FlakBulletType,{ + vec:new Vec2(), + cColors:[Pal.lancerLaser.cpy().mul(1,1,1,0.4),Pal.lancerLaser,Color.white], + cScales:[1,0.7,0.4], + draw(b){ + for(var i=0;i{ + try{ + if(unit.dst(b){ + try {this.despawned(b); + b.remove();} + catch(e){} + })) + } + } catch(e) {return;} + })) + } + }catch(e) {return;} + } +}); +plasma3.speed=2; +plasma3.damage=0; +plasma3.knockback=2; +plasma3.lifetime=160; +plasma3.splashDamageRadius=30; +plasma3.splashDamage=1440; +plasma3.hitSound=Sounds.artillery; +plasma3.ammoMultiplier=4;*/ const ravage=extendContent(ItemTurret,"ravage",{ vec:new Vec2(), powerUse:4.5, @@ -130,7 +183,7 @@ const ravage=extendContent(ItemTurret,"ravage",{ init(){ this.hasPower=true; this.consumes.powerCond(this.powerUse,boolf(entity=>entity!=null?entity.target!=null:false)); - this.ammo(Items.graphite,plasma1,Items.phasefabric,plasma2); + this.ammo(Items.graphite,plasma1,Items.phasefabric,plasma2/*,Vars.content.getByName(ContentType.item,"steam-power-quantum-mass"),plasma3*/); this.super$init(); this.soundTimer=this.timers++; }, @@ -149,7 +202,7 @@ const ravage=extendContent(ItemTurret,"ravage",{ var afin=10*fin-Math.floor(10*fin); if(entity.timer.get(this.soundTimer,20)) Sounds.message.at(tile,1/Math.pow(2,22/12)); for(var i=0;i{ return unit.type.name=="steam-power-draug-a"; })); + this.isCounted[team]=true; }, updateCounts(ent,unit){ if(ent[0]==unit._closestFurnace[0]) return; diff --git a/scripts/units/draug-a.js b/scripts/units/draug-a.js index 3bb5bd6..e28b417 100644 --- a/scripts/units/draug-a.js +++ b/scripts/units/draug-a.js @@ -1,215 +1,152 @@ const draugA=extendContent(UnitType,"draug-a",{}); -draugA.isCounted={}; -draugA.seconds={}; -for(var i in Team.base()) { - draugA.isCounted[Team.get(i)]=true; - draugA.seconds[Team.get(i)]=0; -} const furnaces=this.global.furnaces; -function CustomState(that){ - this.super=that; -} -draugA.create(prov(()=> new JavaAdapter(MinerDrone,{ - customStateMachine:{ - _state:null, - update(){ - if(this._state!=null) this._state.update(); - }, - set(next){ - if(next==this._state) return; - if(this._state!=null) this._state.exited(); - this._state=next; - if(next!=null) next.entered(); - }, - current(){ - return this._state; +var sex=0; +draugA.create(prov(()=>{ + const e=new JavaAdapter(MinerDrone,{ + added(){ + this.state=extend(StateMachine,{ + state:null, + update(){ + if(this.state!=null) this.state.update(); + }, + set(next){ + if(next==this.state) return; + if(this.state!=null) this.state.exited(); + this.state=next; + if(next!=null) next.entered(); + }, + current(){ + return this.state; + }, + is(state){ + return this.state==state; + } + }), + this.super$added(); }, - is(state){ - return this._state==state; - } - }, - initializer(){ - this.customMine=new CustomState(this) - this.customMine.entered=function(){ - this.super.target=null; - } - this.customMine.update=function(){ - if(Time.time()%60=this.super.getItemCapacity()||(this.super.targetItem!=null&&!this.super.acceptsItem(this.super.targetItem))||this.super.item().amount>=entity.block.acceptStack(this.super.targetItem,entity.block.itemCapacity-entity.items.get(this.super.targetItem),entity.tile,this.super)){ - this.super.stateSet(this.super.customDrop); - }else{ - if(this.super.retarget()&&this.super.targetItem!=null){ - this.super.target=Vars.indexer.findClosestOre(this.super.x,this.super.y,this.super.targetItem); + customMine:extend(UnitState,{ + entered(){ + e.target=null; + }, + update(){ + if(Time.time()%60=e.getItemCapacity()||(e.targetItem!=null&&!e.acceptsItem(e.targetItem))||e.item().amount>=entity.block.acceptStack(e.targetItem,entity.block.itemCapacity-entity.items.get(e.targetItem),entity.tile,e)){ + e.setState(e.customDrop); }else{ - if(this.super.getSpawner()!=null){ - this.super.target=this.super.getSpawner(); - this.super.circle(40); + if(e.retarget()&&e.targetItem!=null){ + e.target=Vars.indexer.findClosestOre(e.x,e.y,e.targetItem); + } + if(e.target instanceof Tile){ + e.moveTo(e.type.range/1.5); + if(e.dst(e.target)0){ - Call.transferItemTo(this.super.item().item,Mathf.clamp(this.super.item().amount,0,tile.tile.block().itemCapacity-tile.items.get(this.super.item().item)),this.super.x,this.super.y,tile.tile); + }), + customDrop:new UnitState(){ + entered(){ + e.target=null; + }, + update(){ + if(e==null) return; + if(e.item().amount==0){ + e.clearItem(); + e.setState(e.customMine); + return; } - this.super.clearItem(); - this.super.stateSet(this.super.customMine); - } - this.super.circle(this.super.type.range/1.8); - } - this.customDrop.exited=function(){ - - } - this.customRetreat=new CustomState(this); - this.customRetreat.entered=function(){ - this.super.target=null; - } - this.customRetreat.update=function(){ - if(this.super==null) return; - if(this.super.health>=this.super.maxHealth()){ - this.super.stateSet(this.super.customMine); - }else if(!this.super.targetHasFlag(BlockFlag.repair)){ - if(this.super.retarget()){ - var repairPoint=Geometry.findClosest(this.super.x,this.super.y,Vars.indexer.getAllied(this.super.team,BlockFlag.repair)); - if(repairPoint!=null){ - this.super.target=repairPoint; - }else{ - this.super.stateSet(this.super.customMine); + if(Time.time()%600){ + Call.transferItemTo(e.item().item,Mathf.clamp(e.item().amount,0,tile.tile.block().itemCapacity-tile.items.get(e.item().item)),e.x,e.y,tile.tile); } + e.clearItem(); + e.setState(e.customMine); } - }else{ - this.super.circle(40); - } - } - this.customRetreat.exited=function(){ + e.circle(e.type.range/1.8); + }, + exited(){ - } - }, - _closestFurnace:[null,null], - getClosestFurnace(){ - if(furnaces.sizes[this.team]==0) return; - var escape=false; - var candi=Object.keys(furnaces.entities[this.team]).find(x=>{ - if(escape) return false; - if(!furnaces.isFurnace(Vars.world.tile(furnaces.entities[this.team][x][0].tile.x,furnaces.entities[this.team][x][0].tile.y).block())) { - escape=true; - furnaces.reset(); - return false; } - if(furnaces.entities[this.team][x][0].block==Vars.content.getByName(ContentType.block,"steam-power-advanced-furnace")&&(furnaces.entities[this.team][x][0].getToggle()!=0&&furnaces.entities[this.team][x][0].getToggle()!=1)) return false; - if(this.dst(furnaces.entities[this.team][x][0].tile)>400&&this._closestFurnace!=furnaces.entities[this.team][x]) return false; - if(furnaces.entities[this.team][x][1]{ + if(escape) return false; + if(!furnaces.isFurnace(Vars.world.tile(furnaces.entities[this.team][x][0].tile.x,furnaces.entities[this.team][x][0].tile.y).block())) { + escape=true; + furnaces.reset(); + return false; + } + if(furnaces.entities[this.team][x][0].block==Vars.content.getByName(ContentType.block,"steam-power-advanced-furnace")&&(furnaces.entities[this.team][x][0].getToggle()!=0&&furnaces.entities[this.team][x][0].getToggle()!=1)) return false; + if(this.dst(furnaces.entities[this.team][x][0].tile)>400&&this._closestFurnace!=furnaces.entities[this.team][x]) return false; + if(furnaces.entities[this.team][x][1]new JavaAdapter(HoverUnit,{ getTmpTarget(){ return this._tmpTarget; }, - drawWeapons(){ return }, + drawWeapons(){ return; }, added(){ this.super$added(); weaponYamato.shootSound=sounds["yamato-fire"]; @@ -187,34 +187,35 @@ younggam.create(prov(()=>new JavaAdapter(HoverUnit,{ }, update(){ var current=this.get_Timer(5); - if(Vars.net.client()&&this._reload!=0) this._reload+=Time.delta(); this.super$update(); - var fired=false; - if(this._beginReload){ - if(this._reload==0) { - this._tmpTarget=this.target; - Call.createBullet(soundBullet,this.team,this.x,this.y,0,1,1); - } - if(this._reload>=weaponYamato.reload){ - if(this.target==this._tmpTarget){ - fired=true; - var to=Predict.intercept(this,this.target,yamatocannon.speed); - this.type.weapon=weaponYamato; - weaponYamato.updateYamato(this,to.x,to.y); + if(!Vars.net.clent()){ + var fired=false; + if(this._beginReload){ + if(this._reload==0) { + this._tmpTarget=this.target; + Call.createBullet(soundBullet,this.team,this.x,this.y,0,1,1); } - this._reload=0; - this._beginReload=false; - }else this._reload+=Time.delta(); - } - if(this._target!=null&&!fired) if(this.dst(this._target)=weaponYamato.reload){ + if(this.target==this._tmpTarget){ + fired=true; + var to=Predict.intercept(this,this.target,yamatocannon.speed); + this.type.weapon=weaponYamato; + weaponYamato.updateYamato(this,to.x,to.y); + } + this._reload=0; + this._beginReload=false; + }else this._reload+=Time.delta(); + } + if(this._target!=null&&!fired) if(this.dst(this._target)