Added pulverizer, new temporary laser graphics, debug power blocks
This commit is contained in:
@@ -114,7 +114,8 @@ public class BlockLoader {
|
||||
DistributionBlocks.conduit,
|
||||
ProductionBlocks.coaldrill,
|
||||
WeaponBlocks.chainturret,
|
||||
SpecialBlocks.enemySpawn
|
||||
SpecialBlocks.enemySpawn,
|
||||
DebugBlocks.powerVoid
|
||||
//add any new block sections here
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public class Recipe {
|
||||
public Block result;
|
||||
public ItemStack[] requirements;
|
||||
public Section section;
|
||||
public boolean desktopOnly = false;
|
||||
public boolean desktopOnly = false, debugOnly = false;
|
||||
|
||||
public Recipe(Section section, Block result, ItemStack... requirements){
|
||||
this.result = result;
|
||||
@@ -18,4 +18,9 @@ public class Recipe {
|
||||
desktopOnly = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Recipe setDebug(){
|
||||
debugOnly = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ package io.anuke.mindustry.resource;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.DefenseBlocks;
|
||||
import io.anuke.mindustry.world.blocks.DistributionBlocks;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
import io.anuke.mindustry.world.blocks.WeaponBlocks;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.debug;
|
||||
import static io.anuke.mindustry.resource.Section.*;
|
||||
|
||||
public class Recipes {
|
||||
@@ -85,7 +83,10 @@ public class Recipes {
|
||||
new Recipe(liquid, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
|
||||
|
||||
new Recipe(production, ProductionBlocks.pump, stack(Item.steel, 10)),
|
||||
new Recipe(production, ProductionBlocks.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5))
|
||||
new Recipe(production, ProductionBlocks.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5)),
|
||||
|
||||
new Recipe(units, DebugBlocks.powerVoid, stack(Item.steel, 10)).setDebug(),
|
||||
new Recipe(units, DebugBlocks.powerInfinite, stack(Item.steel, 10), stack(Item.dirium, 5)).setDebug()
|
||||
);
|
||||
|
||||
private static ItemStack stack(Item item, int amount){
|
||||
@@ -107,8 +108,9 @@ public class Recipes {
|
||||
|
||||
public static Array<Recipe> getBy(Section section, Array<Recipe> r){
|
||||
for(Recipe recipe : list){
|
||||
if(recipe.section == section && !(Vars.android && recipe.desktopOnly))
|
||||
if(recipe.section == section && !(Vars.android && recipe.desktopOnly) && !(!debug && recipe.debugOnly)) {
|
||||
r.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
34
core/src/io/anuke/mindustry/world/blocks/DebugBlocks.java
Normal file
34
core/src/io/anuke/mindustry/world/blocks/DebugBlocks.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.PowerBlock;
|
||||
import io.anuke.mindustry.world.blocks.types.distribution.PowerLaser;
|
||||
|
||||
public class DebugBlocks {
|
||||
public static final Block
|
||||
|
||||
powerVoid = new PowerBlock("powervoid") {
|
||||
{
|
||||
powerCapacity = Float.MAX_VALUE;
|
||||
}
|
||||
},
|
||||
|
||||
powerInfinite = new PowerLaser("powerinfinite") {
|
||||
{
|
||||
powerCapacity = 100f;
|
||||
laserDirections = 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsPower(Tile tile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
super.update(tile);
|
||||
tile.<GeneratorEntity>entity().power = powerCapacity;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.resource.Liquid;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.CoreBlock;
|
||||
@@ -104,15 +105,13 @@ public class ProductionBlocks{
|
||||
}
|
||||
},
|
||||
|
||||
pulverizer = new LiquidCrafter("siliconextractor"){
|
||||
pulverizer = new PowerSmelter("pulverizer"){
|
||||
{
|
||||
input = Item.sand;
|
||||
inputAmount = 5;
|
||||
inputLiquid = Liquid.water;
|
||||
liquidAmount = 18.99f;
|
||||
output = Item.sand;
|
||||
inputs = new ItemStack[]{new ItemStack(Item.stone, 5)};
|
||||
result = Item.sand;
|
||||
health = 50;
|
||||
purifyTime = 50;
|
||||
craftTime = 60f;
|
||||
powerDrain = 0.02f;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -173,7 +172,7 @@ public class ProductionBlocks{
|
||||
}
|
||||
},
|
||||
|
||||
sandextractor = new Omnidrill("omnidrill"){
|
||||
sandextractor = new Omnidrill("sandextractor"){
|
||||
{
|
||||
time = 4;
|
||||
}
|
||||
|
||||
@@ -29,17 +29,6 @@ public abstract class PowerBlock extends Block implements PowerAcceptor{
|
||||
list.add("[powerinfo]Power Capacity: " + powerCapacity);
|
||||
}
|
||||
|
||||
/**Tries adding all the power with no remainder, returns success.*/
|
||||
public boolean tryAddPower(Tile tile, float amount){
|
||||
PowerEntity entity = tile.entity();
|
||||
|
||||
if(entity.power + amount <= powerCapacity){
|
||||
entity.power += amount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsPower(Tile tile){
|
||||
PowerEntity entity = tile.entity();
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.world.Layer;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -134,13 +135,13 @@ public class Generator extends PowerBlock{
|
||||
public void drawLayer(Tile tile){
|
||||
if(!Settings.getBool("lasers")) return;
|
||||
|
||||
PowerEntity entity = tile.entity();
|
||||
GeneratorEntity entity = tile.entity();
|
||||
|
||||
for(int i = 0; i < laserDirections; i++){
|
||||
if(entity.power > powerSpeed){
|
||||
Draw.alpha(1f);
|
||||
entity.laserThickness = Mathf.lerpDelta(entity.laserThickness, 1f, 0.05f);
|
||||
}else{
|
||||
Draw.alpha(0.5f);
|
||||
entity.laserThickness = Mathf.lerpDelta(entity.laserThickness, 0.2f, 0.05f);
|
||||
}
|
||||
drawLaserTo(tile, (tile.getRotation() + i) - laserDirections / 2);
|
||||
}
|
||||
@@ -153,6 +154,15 @@ public class Generator extends PowerBlock{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity() {
|
||||
return new GeneratorEntity();
|
||||
}
|
||||
|
||||
public static class GeneratorEntity extends PowerEntity{
|
||||
float laserThickness = 0.5f;
|
||||
}
|
||||
|
||||
protected void distributeLaserPower(Tile tile){
|
||||
PowerEntity entity = tile.entity();
|
||||
|
||||
@@ -177,6 +187,10 @@ public class Generator extends PowerBlock{
|
||||
|
||||
Tile target = laserTarget(tile, rotation);
|
||||
|
||||
GeneratorEntity entity = tile.entity();
|
||||
|
||||
float scale = 1f * entity.laserThickness;
|
||||
|
||||
if(target != null){
|
||||
boolean interfering = isInterfering(target, rotation);
|
||||
|
||||
@@ -202,11 +216,14 @@ public class Generator extends PowerBlock{
|
||||
if(relative == -1){
|
||||
Shapes.laser("laser", "laserend", tile.worldx() + t2.x, tile.worldy() + t2.y,
|
||||
target.worldx() - t1.x + Mathf.range(r),
|
||||
target.worldy() - t1.y + Mathf.range(r), 0.7f);
|
||||
target.worldy() - t1.y + Mathf.range(r), scale);
|
||||
}else{
|
||||
float s = 18f;
|
||||
float sclx = (relative == 1 || relative == 3) ? entity.laserThickness : 1f;
|
||||
float scly = (relative == 1 || relative == 3) ? 1f : entity.laserThickness;
|
||||
Draw.rect("laserfull",
|
||||
tile.worldx() + Geometry.d4[relative].x * width * tilesize / 2f,
|
||||
tile.worldy() + Geometry.d4[relative].y * width * tilesize / 2f);
|
||||
tile.worldy() + Geometry.d4[relative].y * width * tilesize / 2f , s * sclx, s * scly);
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
|
||||
@@ -109,7 +109,7 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||
return liquidCapacity;
|
||||
}
|
||||
|
||||
public static class LiquidPowerEntity extends PowerEntity{
|
||||
public static class LiquidPowerEntity extends GeneratorEntity{
|
||||
public Liquid liquid;
|
||||
public float liquidAmount;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
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.PowerBlock;
|
||||
@@ -21,7 +22,7 @@ public class PowerSmelter extends PowerBlock {
|
||||
protected final int timerDump = timers++;
|
||||
protected final int timerCraft = timers++;
|
||||
|
||||
protected Item[] inputs;
|
||||
protected ItemStack[] inputs;
|
||||
protected Item result;
|
||||
protected float powerDrain = 0.01f;
|
||||
|
||||
@@ -43,8 +44,8 @@ public class PowerSmelter extends PowerBlock {
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
for(Item item : inputs){
|
||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.getItem(item)/capacity));
|
||||
for(ItemStack item : inputs){
|
||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.getItem(item.item)/capacity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +83,8 @@ public class PowerSmelter extends PowerBlock {
|
||||
entity.heat = Mathf.clamp(entity.heat);
|
||||
|
||||
//make sure it has all the items
|
||||
for(Item item : inputs){
|
||||
if(!entity.hasItem(item)){
|
||||
for(ItemStack item : inputs){
|
||||
if(!entity.hasItem(item.item, item.amount)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -94,8 +95,8 @@ public class PowerSmelter extends PowerBlock {
|
||||
return;
|
||||
}
|
||||
|
||||
for(Item item : inputs){
|
||||
entity.removeItem(item, 1);
|
||||
for(ItemStack item : inputs){
|
||||
entity.removeItem(item.item, item.amount);
|
||||
}
|
||||
|
||||
offloadNear(tile, result);
|
||||
@@ -106,8 +107,8 @@ public class PowerSmelter extends PowerBlock {
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
boolean isInput = false;
|
||||
|
||||
for(Item req : inputs){
|
||||
if(req == item){
|
||||
for(ItemStack req : inputs){
|
||||
if(req.item == item){
|
||||
isInput = true;
|
||||
break;
|
||||
}
|
||||
@@ -120,12 +121,12 @@ public class PowerSmelter extends PowerBlock {
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
Smelter.CrafterEntity entity = tile.entity();
|
||||
PowerSmelterEntity entity = tile.entity();
|
||||
|
||||
//draw glowing center
|
||||
if(entity.burnTime > 0){
|
||||
if(entity.heat > 0f){
|
||||
Draw.color(1f, 1f, 1f, Mathf.absin(Timers.time(), 9f, 0.4f) + Mathf.random(0.05f));
|
||||
Draw.rect("smelter-middle", tile.worldx(), tile.worldy());
|
||||
Draw.rect("smelter-middle", tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user