Added fusion reactor
BIN
core/assets-raw/sprites/blocks/power/fusionreactor-bottom.png
Normal file
After Width: | Height: | Size: 261 B |
BIN
core/assets-raw/sprites/blocks/power/fusionreactor-light.png
Normal file
After Width: | Height: | Size: 180 B |
BIN
core/assets-raw/sprites/blocks/power/fusionreactor-plasma-0.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
core/assets-raw/sprites/blocks/power/fusionreactor-plasma-1.png
Normal file
After Width: | Height: | Size: 295 B |
BIN
core/assets-raw/sprites/blocks/power/fusionreactor-plasma-2.png
Normal file
After Width: | Height: | Size: 310 B |
BIN
core/assets-raw/sprites/blocks/power/fusionreactor-plasma-3.png
Normal file
After Width: | Height: | Size: 288 B |
BIN
core/assets-raw/sprites/blocks/power/fusionreactor-top.png
Normal file
After Width: | Height: | Size: 977 B |
BIN
core/assets-raw/sprites/blocks/power/fusionreactor.png
Normal file
After Width: | Height: | Size: 422 B |
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 103 KiB |
@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Mar 31 17:19:49 EDT 2018
|
#Sat Mar 31 22:36:10 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=773
|
androidBuildCode=804
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
@ -97,6 +97,7 @@ public class Recipes {
|
|||||||
new Recipe(power, PowerBlocks.solarpanel, stack(Items.iron, 30), stack(Items.silicon, 20)),
|
new Recipe(power, PowerBlocks.solarpanel, stack(Items.iron, 30), stack(Items.silicon, 20)),
|
||||||
new Recipe(power, PowerBlocks.largesolarpanel, stack(Items.iron, 30), stack(Items.silicon, 20)),
|
new Recipe(power, PowerBlocks.largesolarpanel, stack(Items.iron, 30), stack(Items.silicon, 20)),
|
||||||
new Recipe(power, PowerBlocks.nuclearReactor, stack(Items.titanium, 40), stack(Items.densealloy, 40), stack(Items.steel, 50)),
|
new Recipe(power, PowerBlocks.nuclearReactor, stack(Items.titanium, 40), stack(Items.densealloy, 40), stack(Items.steel, 50)),
|
||||||
|
new Recipe(power, PowerBlocks.fusionReactor, stack(Items.titanium, 40), stack(Items.densealloy, 40), stack(Items.steel, 50)),
|
||||||
|
|
||||||
new Recipe(power, PowerBlocks.shieldgenerator, stack(Items.titanium, 30), stack(Items.densealloy, 30)),
|
new Recipe(power, PowerBlocks.shieldgenerator, stack(Items.titanium, 30), stack(Items.densealloy, 30)),
|
||||||
|
|
||||||
|
@ -49,6 +49,12 @@ public class PowerBlocks {
|
|||||||
breaktime *= 2.3f;
|
breaktime *= 2.3f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
fusionReactor = new FusionReactor("fusionreactor") {{
|
||||||
|
size = 4;
|
||||||
|
health = 600;
|
||||||
|
breaktime *= 4f;
|
||||||
|
}},
|
||||||
|
|
||||||
repairturret = new RepairTurret("repairturret") {{
|
repairturret = new RepairTurret("repairturret") {{
|
||||||
range = 30;
|
range = 30;
|
||||||
reload = 20f;
|
reload = 20f;
|
||||||
@ -85,7 +91,7 @@ public class PowerBlocks {
|
|||||||
size = 2;
|
size = 2;
|
||||||
powerSpeed = 1f;
|
powerSpeed = 1f;
|
||||||
maxNodes = 5;
|
maxNodes = 5;
|
||||||
laserRange = 6.5f;
|
laserRange = 7.5f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
teleporter = new Teleporter("teleporter");
|
teleporter = new Teleporter("teleporter");
|
||||||
|
@ -5,7 +5,6 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import io.anuke.mindustry.content.Recipes;
|
import io.anuke.mindustry.content.Recipes;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.entities.Player;
|
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.graphics.fx.Fx;
|
import io.anuke.mindustry.graphics.fx.Fx;
|
||||||
@ -101,15 +100,16 @@ public class Placement {
|
|||||||
Vector2 offset = type.getPlaceOffset();
|
Vector2 offset = type.getPlaceOffset();
|
||||||
rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
|
rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
|
||||||
|
|
||||||
|
if(type.solid || type.solidifes)
|
||||||
synchronized (Entities.entityLock) {
|
synchronized (Entities.entityLock) {
|
||||||
rect.setSize(tilesize*2f).setCenter(x*tilesize, y*tilesize);
|
rect.setSize(tilesize*2f).setCenter(x*tilesize + type.getPlaceOffset().x, y*tilesize + type.getPlaceOffset().y);
|
||||||
boolean[] result = {false};
|
boolean[] result = {false};
|
||||||
|
|
||||||
Units.getNearby(rect, e -> {
|
Units.getNearby(rect, e -> {
|
||||||
if (e == null) return; //not sure why this happens?
|
if (e == null) return; //not sure why this happens?
|
||||||
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
||||||
|
|
||||||
if (Placement.rect.overlaps(rect)) {
|
if (Placement.rect.overlaps(rect) && !e.isFlying()) {
|
||||||
result[0] = true;
|
result[0] = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -117,14 +117,6 @@ public class Placement {
|
|||||||
if(result[0]) return false;
|
if(result[0]) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type.solid || type.solidifes) {
|
|
||||||
for (Player player : playerGroup.all()) {
|
|
||||||
if (!player.mech.flying && rect.overlaps(player.hitbox.getRect(player.x, player.y))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
if(tile == null || (isSpawnPoint(tile) && (type.solidifes || type.solid))) return false;
|
if(tile == null || (isSpawnPoint(tile) && (type.solidifes || type.solid))) return false;
|
||||||
|
@ -0,0 +1,100 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types.power;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.mindustry.content.Liquids;
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.types.production.GenericCrafter.GenericCrafterEntity;
|
||||||
|
import io.anuke.ucore.core.Graphics;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
public class FusionReactor extends PowerGenerator {
|
||||||
|
protected int plasmas = 4;
|
||||||
|
protected float powerUsage = 0.5f;
|
||||||
|
protected float maxPowerProduced = 1.5f;
|
||||||
|
protected float liquidUsage = 1f;
|
||||||
|
protected Liquid inputLiquid = Liquids.water;
|
||||||
|
protected float warmupSpeed = 0.001f;
|
||||||
|
|
||||||
|
public FusionReactor(String name) {
|
||||||
|
super(name);
|
||||||
|
hasPower = true;
|
||||||
|
hasLiquids = true;
|
||||||
|
powerCapacity = 100f;
|
||||||
|
liquidCapacity = 30f;
|
||||||
|
hasInventory = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
FusionReactorEntity entity = tile.entity();
|
||||||
|
|
||||||
|
float powerUse = Math.min(powerCapacity, powerUsage * Timers.delta());
|
||||||
|
float liquidUse = Math.min(liquidCapacity, liquidUsage * Timers.delta());
|
||||||
|
|
||||||
|
if(entity.power.amount >= powerUse && entity.liquid.amount >= liquidUse){
|
||||||
|
entity.power.amount -= powerUse;
|
||||||
|
entity.liquid.amount -= liquidUse;
|
||||||
|
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, warmupSpeed);
|
||||||
|
}else{
|
||||||
|
entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float powerAdded = Math.min(powerCapacity - entity.power.amount, maxPowerProduced * Mathf.pow(entity.warmup, 3f) * Timers.delta());
|
||||||
|
entity.power.amount += powerAdded;
|
||||||
|
entity.totalProgress += entity.warmup * Timers.delta();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Tile tile) {
|
||||||
|
FusionReactorEntity entity = tile.entity();
|
||||||
|
|
||||||
|
Draw.rect(name + "-bottom", tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
|
Graphics.setAdditiveBlending();
|
||||||
|
|
||||||
|
for(int i = 0; i < plasmas; i ++){
|
||||||
|
float r = 29f + Mathf.absin(Timers.time(), 2f + i*1f, 5f - i*0.5f);
|
||||||
|
|
||||||
|
Draw.color(Color.valueOf("ffd06b"), Color.valueOf("ff361b"), (float)i/plasmas);
|
||||||
|
Draw.alpha((0.3f + Mathf.absin(Timers.time(), 2f+i*2f, 0.3f+i*0.05f)) * entity.warmup);
|
||||||
|
Draw.rect(name + "-plasma-" + i, tile.drawx(), tile.drawy(), r, r, Timers.time()*(12+i*6f) * entity.warmup);
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
|
|
||||||
|
Graphics.setNormalBlending();
|
||||||
|
|
||||||
|
Draw.rect(name, tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
|
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
|
Draw.color(Color.valueOf("858585"), Color.valueOf("fea080"), entity.warmup + Mathf.absin(entity.totalProgress, 3f, entity.warmup*0.5f));
|
||||||
|
Draw.rect(name + "-light", tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] getIcon() {
|
||||||
|
return new TextureRegion[]{Draw.region(name + "-bottom"), Draw.region(name), Draw.region(name + "-top")};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getEntity() {
|
||||||
|
return new FusionReactorEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
||||||
|
return super.acceptLiquid(tile, source, liquid, amount) && liquid == inputLiquid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FusionReactorEntity extends GenericCrafterEntity{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -191,12 +191,9 @@ public class PowerDistributor extends PowerBlock{
|
|||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldDistribute(Tile tile, Tile other){
|
protected boolean shouldDistribute(Tile tile, Tile other) {
|
||||||
if(other.block() instanceof PowerDistributor){
|
return !(other.block() instanceof PowerDistributor)
|
||||||
return other.entity.power.amount / other.block().powerCapacity <
|
|| other.entity.power.amount / other.block().powerCapacity < tile.entity.power.amount / powerCapacity;
|
||||||
tile.entity.power.amount / powerCapacity;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void distributeLaserPower(Tile tile){
|
protected void distributeLaserPower(Tile tile){
|
||||||
@ -266,11 +263,12 @@ public class PowerDistributor extends PowerBlock{
|
|||||||
if(link.block() instanceof PowerDistributor){
|
if(link.block() instanceof PowerDistributor){
|
||||||
DistributorEntity oe = link.entity();
|
DistributorEntity oe = link.entity();
|
||||||
|
|
||||||
return Vector2.dst(tile.drawx(), tile.drawy(), link.worldx(), link.worldy()) <= Math.max(laserRange * tilesize,
|
return Vector2.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy()) <= Math.max(laserRange * tilesize,
|
||||||
((PowerDistributor)link.block()).laserRange * tilesize) - tilesize/2f &&
|
((PowerDistributor)link.block()).laserRange * tilesize) - tilesize/2f
|
||||||
|
+ (link.block().size-1)*tilesize/2f + (tile.block().size-1)*tilesize/2f &&
|
||||||
oe.links.size < ((PowerDistributor)link.block()).maxNodes;
|
oe.links.size < ((PowerDistributor)link.block()).maxNodes;
|
||||||
}else{
|
}else{
|
||||||
return Vector2.dst(tile.drawx(), tile.drawy(), link.worldx(), link.worldy())
|
return Vector2.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy())
|
||||||
<= laserRange * tilesize - tilesize/2f + (link.block().size-1)*tilesize;
|
<= laserRange * tilesize - tilesize/2f + (link.block().size-1)*tilesize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ import io.anuke.ucore.graphics.Draw;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class GenericCrafter extends Block{
|
public class GenericCrafter extends Block{
|
||||||
protected final int timerDump = timers++;
|
protected final int timerDump = timers++;
|
||||||
|
|
||||||
@ -132,6 +136,17 @@ public class GenericCrafter extends Block{
|
|||||||
public float progress;
|
public float progress;
|
||||||
public float totalProgress;
|
public float totalProgress;
|
||||||
public float warmup;
|
public float warmup;
|
||||||
public float craftTime;
|
|
||||||
|
@Override
|
||||||
|
public void write(DataOutputStream stream) throws IOException {
|
||||||
|
stream.writeFloat(progress);
|
||||||
|
stream.writeFloat(warmup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(DataInputStream stream) throws IOException {
|
||||||
|
progress = stream.readFloat();
|
||||||
|
warmup = stream.readFloat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class Separator extends Block {
|
|||||||
|
|
||||||
Draw.color(Color.valueOf("858585"));
|
Draw.color(Color.valueOf("858585"));
|
||||||
Lines.stroke(spinnerThickness);
|
Lines.stroke(spinnerThickness);
|
||||||
Lines.spikes(tile.drawx(), tile.drawy(), spinnerRadius, spinnerLength, 3, entity.craftTime*spinnerSpeed);
|
Lines.spikes(tile.drawx(), tile.drawy(), spinnerRadius, spinnerLength, 3, entity.totalProgress*spinnerSpeed);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ public class Separator extends Block {
|
|||||||
float liquidUsed = Math.min(liquidCapacity, liquidUse * Timers.delta());
|
float liquidUsed = Math.min(liquidCapacity, liquidUse * Timers.delta());
|
||||||
float powerUsed = Math.min(powerCapacity, powerUse * Timers.delta());
|
float powerUsed = Math.min(powerCapacity, powerUse * Timers.delta());
|
||||||
|
|
||||||
entity.craftTime += entity.warmup*Timers.delta();
|
entity.totalProgress += entity.warmup*Timers.delta();
|
||||||
|
|
||||||
if(entity.liquid.amount >= liquidUsed && entity.inventory.hasItem(item) &&
|
if(entity.liquid.amount >= liquidUsed && entity.inventory.hasItem(item) &&
|
||||||
(!hasPower || entity.power.amount >= powerUsed)){
|
(!hasPower || entity.power.amount >= powerUsed)){
|
||||||
|