Fixed some generator bugs, implemented laser drill properly

This commit is contained in:
Anuken 2018-03-05 23:26:53 -05:00
parent 45a3be7642
commit 6a564f6693
8 changed files with 328 additions and 310 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Mon Mar 05 21:35:42 EST 2018
#Mon Mar 05 23:15:19 EST 2018
version=release
androidBuildCode=399
androidBuildCode=400
name=Mindustry
code=3.4
build=custom build

View File

@ -66,6 +66,7 @@ public class Recipes {
new Recipe(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
new Recipe(production, ProductionBlocks.quartzextractor, stack(Item.titanium, 40), stack(Item.dirium, 40)),
new Recipe(production, ProductionBlocks.biomatterextractor, stack(Item.titanium, 40), stack(Item.dirium, 40)),
new Recipe(production, ProductionBlocks.laserdrill, stack(Item.titanium, 40), stack(Item.dirium, 40)),
new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
new Recipe(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)),

View File

@ -194,8 +194,9 @@ public class Generator extends PowerBlock{
if(target != null){
boolean interfering = isInterfering(target, rotation);
t1.trns(rotation * 90, target.block().size * tilesize / 2 + 2f +
(interfering ? Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - tilesize / 2f * target.block().size + 1 : 0));
t1.trns(rotation * 90, 1 * tilesize / 2 + 2f +
(interfering ? Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(),
target.worldy()) / 2f - tilesize / 2f * 1 + 1 : 0));
t2.trns(rotation * 90, size * tilesize / 2 + 2f);
@ -254,7 +255,7 @@ public class Generator extends PowerBlock{
if(other != null && other.block() instanceof PowerAcceptor){
Tile linked = other.getLinked();
if(linked == null || linked instanceof PowerAcceptor){
if(linked == null || linked.block() instanceof PowerAcceptor){
return other;
}
}

View File

@ -86,7 +86,7 @@ public class Drill extends Block{
Draw.color();
}
boolean isValid(Tile tile){
protected boolean isValid(Tile tile){
return tile.floor() == resource || (resource != null && resource.drops != null && resource.drops.equals(tile.floor().drops));
}

View File

@ -1,6 +1,10 @@
package io.anuke.mindustry.world.blocks.types.production;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.world.BlockBar;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
import io.anuke.mindustry.world.blocks.types.PowerBlock.PowerEntity;
@ -12,35 +16,35 @@ public class PowerDrill extends Drill implements PowerAcceptor {
/**power use per frame.*/
public float powerUse = 0.08f;
private Array<ItemStack> toAdd = new Array<>();
public PowerDrill(String name){
super(name);
bars.add(new BlockBar(Color.YELLOW, true, tile -> tile.<PowerEntity>entity().power / powerCapacity));
}
@Override
public void update(Tile tile){
toAdd.clear();
PowerEntity entity = tile.entity();
int mines = 0;
float used = Math.min(entity.power * Timers.delta(), powerCapacity-0.1f);
float used = Math.min(powerUse * Timers.delta(), powerCapacity-0.1f);
if(entity.power >= used){
entity.power -= used;
}
if(isMultiblock()){
for(Tile other : tile.getLinkedTiles(tempTiles)){
if(isValid(other)){
mines ++;
}
for(Tile other : tile.getLinkedTiles(tempTiles)){
if(isValid(other)){
toAdd.add(other.floor().drops);
}
}else{
if(isValid(tile)) mines = 1;
}
if(mines > 0 && entity.power > powerUse && entity.timer.get(timerDrill, 60 * time)
&& tile.entity.getItem(result) < capacity){
for(int i = 0; i < mines; i ++) offloadNear(tile, result);
if(toAdd.size > 0 && entity.power > powerUse && entity.timer.get(timerDrill, 60 * time)
&& tile.entity.totalItems() < capacity){
for(ItemStack stack : toAdd) offloadNear(tile, stack.item);
Effects.effect(drillEffect, tile.drawx(), tile.drawy());
}
@ -77,4 +81,9 @@ public class PowerDrill extends Drill implements PowerAcceptor {
public TileEntity getEntity() {
return new PowerEntity();
}
@Override
protected boolean isValid(Tile tile){
return tile.floor().drops != null;
}
}