mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-04 13:02:37 -08:00
commit
0441338752
23 changed files with 373 additions and 268 deletions
BIN
core/assets-raw/sprites/blocks/block-middle.png
Normal file
BIN
core/assets-raw/sprites/blocks/block-middle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 172 B |
BIN
core/assets-raw/sprites/blocks/smelter-middle.png
Normal file
BIN
core/assets-raw/sprites/blocks/smelter-middle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 179 B |
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
|
@ -163,6 +163,16 @@ public class Fx{
|
|||
Draw.reset();
|
||||
});
|
||||
}),
|
||||
|
||||
fuelburn = new Effect(23, e -> {
|
||||
Angles.randLenVectors(e.id, 5, e.ifract()*9f, (x, y)->{
|
||||
float len = e.fract()*4f;
|
||||
Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.ifract());
|
||||
//Draw.alpha(e.fract());
|
||||
Draw.rect("circle", e.x + x, e.y + y, len, len);
|
||||
Draw.reset();
|
||||
});
|
||||
}),
|
||||
|
||||
laserspark = new Effect(14, e -> {
|
||||
Angles.randLenVectors(e.id, 8, 1f + e.ifract()*11f, (x, y)->{
|
||||
|
|
@ -306,7 +316,7 @@ public class Fx{
|
|||
smelt = new Effect(10, e -> {
|
||||
Draw.thickness(1f);
|
||||
Draw.color(Color.YELLOW, Color.RED, e.ifract());
|
||||
Draw.spikes(e.x, e.y, e.ifract() * 5f, 2, 8);
|
||||
Draw.spikes(e.x, e.y, e.ifract() * 5f, 1f, 8);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,11 @@ import io.anuke.mindustry.world.Map;
|
|||
import io.anuke.ucore.core.Inputs.DeviceType;
|
||||
import io.anuke.ucore.core.KeyBinds;
|
||||
import io.anuke.ucore.core.KeyBinds.Keybind;
|
||||
import io.anuke.ucore.scene.ui.SettingsDialog.SettingsTable.Setting;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
/**Used for generating a bundle from existing strings in the game.*/
|
||||
public class BundleGen {
|
||||
private static FileHandle file;
|
||||
|
||||
|
|
@ -25,12 +28,12 @@ public class BundleGen {
|
|||
file.writeString("", false);
|
||||
write("about.text=" + join(Vars.aboutText));
|
||||
write("discord.text=Join the mindustry discord!\n[orange]");
|
||||
/*
|
||||
|
||||
Mathf.each(table -> {
|
||||
for(Setting setting : table.getSettings()){
|
||||
write("setting." + setting.name + ".name=" + setting.title);
|
||||
}
|
||||
}, Vars.ui.getPrefs().game, Vars.ui.getPrefs().graphics, Vars.ui.getPrefs().sound);*/
|
||||
}, Vars.ui.settings.game, Vars.ui.settings.graphics, Vars.ui.settings.sound);
|
||||
|
||||
for(Map map : Vars.world.maps().list()){
|
||||
write("map." + map.name + ".name=" + map.name);
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public class Block{
|
|||
tile.entity.addItem(item, 1);
|
||||
}
|
||||
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,19 +20,23 @@ public class ProductionBlocks{
|
|||
}
|
||||
},
|
||||
|
||||
smelter = new Crafter("smelter"){
|
||||
smelter = new Smelter("smelter"){
|
||||
{
|
||||
health = 70;
|
||||
requirements = new Item[]{Item.coal, Item.iron};
|
||||
inputs = new Item[]{Item.iron};
|
||||
fuel = Item.coal;
|
||||
result = Item.steel;
|
||||
}
|
||||
},
|
||||
|
||||
crucible = new Crafter("crucible"){
|
||||
crucible = new Smelter("crucible"){
|
||||
{
|
||||
health = 90;
|
||||
requirements = new Item[]{Item.titanium, Item.steel};
|
||||
inputs = new Item[]{Item.titanium, Item.steel};
|
||||
fuel = Item.coal;
|
||||
result = Item.dirium;
|
||||
burnDuration = 80f;
|
||||
craftTime = 40f;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ public class BlockPart extends Block implements PowerAcceptor, LiquidAcceptor{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
return dest.getLinked().block().acceptItem(item, dest.getLinked(), source);
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return tile.getLinked().block().acceptItem(item, tile.getLinked(), source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class CoreBlock extends Block {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import io.anuke.mindustry.resource.Item;
|
|||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
|
|
@ -70,7 +69,7 @@ public class PowerTurret extends Turret implements PowerAcceptor{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ import io.anuke.ucore.util.Strings;
|
|||
public class ShieldBlock extends PowerBlock{
|
||||
public float shieldRadius = 40f;
|
||||
public float powerDrain = 0.005f;
|
||||
public float powerPerDamage = 0.1f;
|
||||
public float powerPerDamage = 0.07f;
|
||||
public float maxRadius = 40f;
|
||||
public float radiusScale = 240f;
|
||||
public float radiusScale = 300f;
|
||||
|
||||
public ShieldBlock(String name) {
|
||||
super(name);
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ public class Turret extends Block{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
return item == ammo && dest.<TurretEntity>entity().ammo < maxammo;
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return item == ammo && tile.<TurretEntity>entity().ammo < maxammo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -128,11 +128,11 @@ public class Conveyor extends Block{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
int direction = source == null ? 0 : Math.abs(source.relativeTo(dest.x, dest.y) - dest.getRotation());
|
||||
float minitem = dest.<ConveyorEntity>entity().minitem;
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
int direction = source == null ? 0 : Math.abs(source.relativeTo(tile.x, tile.y) - tile.getRotation());
|
||||
float minitem = tile.<ConveyorEntity>entity().minitem;
|
||||
return (((direction == 0) && minitem > 0.05f) ||
|
||||
((direction %2 == 1) && minitem > 0.52f)) && (source == null || !(source.block().rotate && (source.getRotation() + 2) % 4 == dest.getRotation()));
|
||||
((direction %2 == 1) && minitem > 0.52f)) && (source == null || !(source.block().rotate && (source.getRotation() + 2) % 4 == tile.getRotation()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.world.blocks.types.distribution;
|
|||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.UCore;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
|
||||
public class Junction extends Block{
|
||||
|
|
@ -32,11 +31,11 @@ public class Junction extends Block{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
int dir = source.relativeTo(dest.x, dest.y);
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
int dir = source.relativeTo(tile.x, tile.y);
|
||||
if(dir == -1) return false;
|
||||
Tile to = dest.getNearby()[dir];
|
||||
return to != null && to.block().acceptItem(item, to, dest);
|
||||
Tile to = tile.getNearby()[dir];
|
||||
return to != null && to.block().acceptItem(item, to, tile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ public class LiquidItemJunction extends LiquidBlock{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
int dir = source.relativeTo(dest.x, dest.y);
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
int dir = source.relativeTo(tile.x, tile.y);
|
||||
|
||||
if((dir+dest.getRotation()) % 2 == 0) return false;
|
||||
if((dir+ tile.getRotation()) % 2 == 0) return false;
|
||||
|
||||
Tile to = dest.getNearby()[dir];
|
||||
return to != null && to.block().acceptItem(item, to, dest);
|
||||
Tile to = tile.getNearby()[dir];
|
||||
return to != null && to.block().acceptItem(item, to, tile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ public class Router extends Block{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
int items = dest.entity.totalItems();
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
int items = tile.entity.totalItems();
|
||||
return items < capacity;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ public class Sorter extends Junction implements Configurable{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
if(source.block() instanceof Sorter) return false;
|
||||
Tile to = getTileTarget(item, dest, source, false);
|
||||
Tile to = getTileTarget(item, tile, source, false);
|
||||
|
||||
return to != null && to.block().acceptItem(item, to, dest);
|
||||
return to != null && to.block().acceptItem(item, to, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -5,21 +5,22 @@ import com.badlogic.gdx.utils.Array;
|
|||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||
import io.anuke.mindustry.world.blocks.types.PowerBlock;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Teleporter extends Block implements Configurable{
|
||||
public class Teleporter extends PowerBlock implements Configurable{
|
||||
public static final Color[] colorArray = {Color.ROYAL, Color.ORANGE, Color.SCARLET, Color.FOREST, Color.PURPLE, Color.GOLD, Color.PINK, Color.BLACK};
|
||||
public static final int colors = colorArray.length;
|
||||
|
||||
|
|
@ -29,6 +30,8 @@ public class Teleporter extends Block implements Configurable{
|
|||
private Array<Tile> removal = new Array<>();
|
||||
private Array<Tile> returns = new Array<>();
|
||||
|
||||
protected float powerPerItem = 1f;
|
||||
|
||||
static{
|
||||
for(int i = 0; i < colors; i ++){
|
||||
teleporters[i] = new ObjectSet<>();
|
||||
|
|
@ -40,6 +43,13 @@ public class Teleporter extends Block implements Configurable{
|
|||
update = true;
|
||||
solid = true;
|
||||
health = 80;
|
||||
powerCapacity = 30f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getStats(Array<String> list){
|
||||
super.getStats(list);
|
||||
list.add("[powerinfo]Power/item: " + Strings.toFixed(powerPerItem, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -103,18 +113,22 @@ public class Teleporter extends Block implements Configurable{
|
|||
|
||||
@Override
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
PowerEntity entity = tile.entity();
|
||||
|
||||
Array<Tile> links = findLinks(tile);
|
||||
|
||||
if(links.size > 0){
|
||||
Tile target = links.get(Mathf.random(0, links.size-1));
|
||||
target.entity.addItem(item, 1);
|
||||
}
|
||||
|
||||
entity.power -= powerPerItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
Array<Tile> links = findLinks(dest);
|
||||
return links.size > 0;
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
PowerEntity entity = tile.entity();
|
||||
return entity.power >= powerPerItem && findLinks(tile).size > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -147,7 +161,7 @@ public class Teleporter extends Block implements Configurable{
|
|||
return returns;
|
||||
}
|
||||
|
||||
public static class TeleporterEntity extends TileEntity{
|
||||
public static class TeleporterEntity extends PowerEntity{
|
||||
public byte color = 0;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ public class TunnelConveyor extends Block{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
int rot = source.relativeTo(dest.x, dest.y);
|
||||
if(rot != (dest.getRotation() + 2)%4) return false;
|
||||
Tile tunnel = getDestTunnel(dest, item);
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
int rot = source.relativeTo(tile.x, tile.y);
|
||||
if(rot != (tile.getRotation() + 2)%4) return false;
|
||||
Tile tunnel = getDestTunnel(tile, item);
|
||||
|
||||
if(tunnel != null){
|
||||
Tile to = tunnel.getNearby()[tunnel.getRotation()];
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
package io.anuke.mindustry.world.blocks.types.production;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
|
||||
public class Crafter extends Block{
|
||||
protected final int timerDump = timers++;
|
||||
|
||||
protected Item[] requirements;
|
||||
protected Item result;
|
||||
|
||||
int capacity = 20;
|
||||
|
||||
public Crafter(String name) {
|
||||
super(name);
|
||||
update = true;
|
||||
solid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getStats(Array<String> list){
|
||||
super.getStats(list);
|
||||
list.add("[craftinfo]Input: " + Arrays.toString(requirements));
|
||||
list.add("[craftinfo]Output: " + result);
|
||||
list.add("[craftinfo]Capacity per input type: " + capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
|
||||
if(tile.entity.timer.get(timerDump, 5) && tile.entity.hasItem(result)){
|
||||
tryDump(tile, -1, result);
|
||||
}
|
||||
|
||||
for(Item item : requirements){
|
||||
if(!tile.entity.hasItem(item)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// crafter full - it has to be emptied before it can craft again.
|
||||
if(tile.entity.getItem(result) >= capacity){
|
||||
return;
|
||||
}
|
||||
|
||||
for(Item item : requirements){
|
||||
tile.entity.removeItem(item, 1);
|
||||
}
|
||||
|
||||
offloadNear(tile, result);
|
||||
Effects.effect(Fx.smelt, tile.entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
for(Item req : requirements){
|
||||
if(item == req){
|
||||
return dest.entity.getItem(item) < capacity;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
// each req item has its input buffer + 1 buffer for output.
|
||||
int totalCapacity = (requirements.length + 1) * capacity;
|
||||
float fract = ((float)tile.entity.totalItems())/totalCapacity;
|
||||
|
||||
Vars.renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 6, fract);
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,6 @@ import io.anuke.ucore.core.Draw;
|
|||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
//TODO possibly proken
|
||||
|
|
|
|||
|
|
@ -0,0 +1,144 @@
|
|||
package io.anuke.mindustry.world.blocks.types.production;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Smelter extends Block{
|
||||
protected final int timerDump = timers++;
|
||||
protected final int timerCraft = timers++;
|
||||
|
||||
protected Item[] inputs;
|
||||
protected Item fuel;
|
||||
protected Item result;
|
||||
|
||||
protected float craftTime = 30f; //time to craft one item, so max 2 items per second by default
|
||||
protected float burnDuration = 60f; //by default, the fuel will burn 60 frames, so that's 2 items/fuel at most
|
||||
protected Effect craftEffect = Fx.smelt, burnEffect = Fx.fuelburn;
|
||||
|
||||
protected int capacity = 30;
|
||||
|
||||
public Smelter(String name) {
|
||||
super(name);
|
||||
update = true;
|
||||
solid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getStats(Array<String> list){
|
||||
super.getStats(list);
|
||||
list.add("[craftinfo]Input: " + Arrays.toString(inputs));
|
||||
list.add("[craftinfo]Fuel: " + fuel);
|
||||
list.add("[craftinfo]Output: " + result);
|
||||
list.add("[craftinfo]Fuel Duration: " + Strings.toFixed(burnDuration/60f, 1));
|
||||
list.add("[craftinfo]Max output/second: " + Strings.toFixed(60f/craftTime, 1));
|
||||
list.add("[craftinfo]Input Capacity: " + capacity);
|
||||
list.add("[craftinfo]Output Capacity: " + capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
CrafterEntity entity = tile.entity();
|
||||
|
||||
if(entity.timer.get(timerDump, 5) && entity.hasItem(result)){
|
||||
tryDump(tile, -1, result);
|
||||
}
|
||||
|
||||
//add fuel
|
||||
if(entity.getItem(fuel) > 0 && entity.burnTime <= 0f){
|
||||
entity.removeItem(fuel, 1);
|
||||
entity.burnTime += burnDuration;
|
||||
Effects.effect(burnEffect, entity.x + Mathf.range(2f), entity.y + Mathf.range(2f));
|
||||
}
|
||||
|
||||
//decrement burntime
|
||||
if(entity.burnTime > 0){
|
||||
entity.burnTime -= Timers.delta();
|
||||
}
|
||||
|
||||
//make sure it has all the items
|
||||
for(Item item : inputs){
|
||||
if(!entity.hasItem(item)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(entity.getItem(result) >= capacity //output full
|
||||
|| entity.burnTime <= 0 //not burning
|
||||
|| !entity.timer.get(timerCraft, craftTime)){ //not yet time
|
||||
return;
|
||||
}
|
||||
|
||||
for(Item item : inputs){
|
||||
entity.removeItem(item, 1);
|
||||
}
|
||||
|
||||
offloadNear(tile, result);
|
||||
Effects.effect(craftEffect, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
int amount = 0;
|
||||
boolean isInput = false;
|
||||
|
||||
for(Item req : inputs){
|
||||
if(req == item) isInput = true;
|
||||
amount += tile.entity.getItem(req);
|
||||
}
|
||||
|
||||
return (isInput && amount < capacity) || (item == fuel && tile.entity.getItem(fuel) < capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
CrafterEntity entity = tile.entity();
|
||||
|
||||
//draw glowing center
|
||||
if(entity.burnTime > 0){
|
||||
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.color();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
//all required items are put into one big capacity buffer
|
||||
int totalCapacity = capacity;
|
||||
int amount = 0;
|
||||
|
||||
for(Item item : inputs){
|
||||
amount += tile.entity.getItem(item);
|
||||
}
|
||||
|
||||
float fract = ((float)amount)/totalCapacity;
|
||||
|
||||
Vars.renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 6, fract);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity() {
|
||||
return new CrafterEntity();
|
||||
}
|
||||
|
||||
public class CrafterEntity extends TileEntity{
|
||||
public float burnTime;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue