Add plastanium diode

This commit is contained in:
Patrick 'Quezler' Mounier
2019-10-31 12:39:45 +01:00
parent 3467b62cc4
commit ce53de0df4
9 changed files with 1992 additions and 1869 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@@ -892,6 +892,7 @@ block.coal-centrifuge.name = Coal Centrifuge
block.power-node.name = Power Node
block.power-node-large.name = Large Power Node
block.surge-tower.name = Surge Tower
block.diode.name = Diode
block.battery.name = Battery
block.battery-large.name = Large Battery
block.combustion-generator.name = Combustion Generator
@@ -1120,6 +1121,7 @@ block.phase-conduit.description = Advanced liquid transport block. Uses power to
block.power-node.description = Transmits power to connected nodes. The node will receive power from or supply power to any adjacent blocks.
block.power-node-large.description = An advanced power node with greater range.
block.surge-tower.description = An extremely long-range power node with fewer available connections.
block.diode.description = Forwards power in only one direction. Needs batteries on either end.
block.battery.description = Stores power as a buffer in times of surplus energy. Outputs power in times of deficit.
block.battery-large.description = Stores much more power than a regular battery.
block.combustion-generator.description = Generates power by burning flammable materials, such as coal.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 737 B

After

Width:  |  Height:  |  Size: 740 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 KiB

After

Width:  |  Height:  |  Size: 931 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 KiB

After

Width:  |  Height:  |  Size: 331 KiB

View File

@@ -63,7 +63,7 @@ public class Blocks implements ContentList{
//power
combustionGenerator, thermalGenerator, turbineGenerator, differentialGenerator, rtgGenerator, solarPanel, largeSolarPanel, thoriumReactor,
impactReactor, battery, batteryLarge, powerNode, powerNodeLarge, surgeTower,
impactReactor, battery, batteryLarge, powerNode, powerNodeLarge, surgeTower, diode,
//production
mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, waterExtractor, oilExtractor, cultivator,
@@ -1065,6 +1065,10 @@ public class Blocks implements ContentList{
laserRange = 30f;
}};
diode = new PowerDiode("diode"){{
requirements(Category.power, ItemStack.with(Items.silicon, 10, Items.phasefabric, 5, Items.plastanium, 2, Items.metaglass, 1));
}};
battery = new Battery("battery"){{
requirements(Category.power, ItemStack.with(Items.copper, 4, Items.lead, 20));
consumes.powerBuffered(4000f);

View File

@@ -0,0 +1,61 @@
package io.anuke.mindustry.world.blocks.power;
import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.world;
public class PowerDiode extends Block {
public PowerDiode(String name) {
super(name);
rotate = true;
update = true;
solid = true;
insulated = true;
}
@Override
public void update(Tile tile) {
super.update(tile);
Tile back = getNearby(tile, (tile.rotation() + 2) % 4);
Tile front = getNearby(tile, tile.rotation());
if(back.block() != null && back.block() instanceof Battery &&
front.block() != null && front.block() instanceof Battery){
float backCapacity = back.block().consumes.getPower().capacity;
float frontCapacity = front.block().consumes.getPower().capacity;
float backPower = backCapacity * back.entity.power.satisfaction;
float frontPower = frontCapacity * front.entity.power.satisfaction;
if(backPower > frontPower && front.entity.power.satisfaction < 1f){
float send = Mathf.clamp((backPower - frontPower) / 2, 0f, frontCapacity);
back.entity.power.satisfaction -= send / backCapacity;
front.entity.power.satisfaction += send / frontCapacity;
}
tile.entity.noSleep();
} else {
tile.entity.sleep();
}
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid) {
super.drawPlace(x, y, rotation, valid);
}
public Tile getNearby(Tile tile, int rotation){
int x = tile.x;
int y = tile.y;
if(rotation == 0) return world.ltile(x + 1, y);
if(rotation == 1) return world.ltile(x, y + 1);
if(rotation == 2) return world.ltile(x - 1, y);
if(rotation == 3) return world.ltile(x, y - 1);
return null;
}
}