Incomplete production meta system
This commit is contained in:
@@ -305,7 +305,7 @@ blocks.blockinfo = Block Info
|
|||||||
blocks.powercapacity = Power Capacity
|
blocks.powercapacity = Power Capacity
|
||||||
blocks.powershot = Power/Shot
|
blocks.powershot = Power/Shot
|
||||||
blocks.targetsair = Targets Air
|
blocks.targetsair = Targets Air
|
||||||
blocks.itemspeed = Units Moved
|
blocks.itemsmoved = Move Speed
|
||||||
blocks.shootrange = Range
|
blocks.shootrange = Range
|
||||||
blocks.size = Size
|
blocks.size = Size
|
||||||
blocks.liquidcapacity = Liquid Capacity
|
blocks.liquidcapacity = Liquid Capacity
|
||||||
@@ -351,7 +351,6 @@ unit.blocks = blocks
|
|||||||
unit.powersecond = power units/second
|
unit.powersecond = power units/second
|
||||||
unit.liquidsecond = liquid units/second
|
unit.liquidsecond = liquid units/second
|
||||||
unit.itemssecond = items/second
|
unit.itemssecond = items/second
|
||||||
unit.pixelssecond = pixels/second
|
|
||||||
unit.liquidunits = liquid units
|
unit.liquidunits = liquid units
|
||||||
unit.powerunits = power units
|
unit.powerunits = power units
|
||||||
unit.degrees = degrees
|
unit.degrees = degrees
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 509 B After Width: | Height: | Size: 509 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
@@ -284,7 +284,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
Block previous = tile.block();
|
Block previous = tile.block();
|
||||||
tile.block().update(tile);
|
tile.block().update(tile);
|
||||||
if(tile.block() == previous && cons != null){
|
if(tile.block() == previous && cons != null){
|
||||||
cons.update(this);
|
cons.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ public class Item extends UnlockableContent implements Comparable<Item>{
|
|||||||
public enum Icon{
|
public enum Icon{
|
||||||
small(8*2),
|
small(8*2),
|
||||||
medium(8*3),
|
medium(8*3),
|
||||||
large(8*4);
|
large(8*4),
|
||||||
|
xlarge(8*5);
|
||||||
|
|
||||||
public final int size;
|
public final int size;
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
table.margin(6f);
|
table.margin(6f);
|
||||||
table.defaults().size(16 * 2.5f).space(6f);
|
table.defaults().size(8 * 5).space(6f);
|
||||||
|
|
||||||
if(tile.block().hasItems){
|
if(tile.block().hasItems){
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
HandCursorListener l = new HandCursorListener();
|
HandCursorListener l = new HandCursorListener();
|
||||||
l.setEnabled(canPick);
|
l.setEnabled(canPick);
|
||||||
|
|
||||||
ItemImage image = new ItemImage(item.icon(Icon.large), () -> {
|
ItemImage image = new ItemImage(item.icon(Icon.xlarge), () -> {
|
||||||
if(tile == null || tile.entity == null){
|
if(tile == null || tile.entity == null){
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ public class Tile implements Position, TargetTrait{
|
|||||||
|
|
||||||
if(block.hasEntity()){
|
if(block.hasEntity()){
|
||||||
entity = block.newEntity().init(this, block.update);
|
entity = block.newEntity().init(this, block.update);
|
||||||
entity.cons = new ConsumeModule();
|
entity.cons = new ConsumeModule(entity);
|
||||||
if(block.hasItems) entity.items = new ItemModule();
|
if(block.hasItems) entity.items = new ItemModule();
|
||||||
if(block.hasLiquids) entity.liquids = new LiquidModule();
|
if(block.hasLiquids) entity.liquids = new LiquidModule();
|
||||||
if(block.hasPower){
|
if(block.hasPower){
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class Conveyor extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void setStats(){
|
public void setStats(){
|
||||||
super.setStats();
|
super.setStats();
|
||||||
stats.add(BlockStat.itemSpeed, speed * 60, StatUnit.pixelsSecond);
|
stats.add(BlockStat.itemsMoved, speed * 60, StatUnit.itemsSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package io.anuke.mindustry.world.blocks.production;
|
package io.anuke.mindustry.world.blocks.production;
|
||||||
|
|
||||||
import io.anuke.mindustry.entities.Effects;
|
|
||||||
import io.anuke.mindustry.entities.Effects.Effect;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.content.Fx;
|
import io.anuke.mindustry.content.Fx;
|
||||||
|
import io.anuke.mindustry.entities.Effects;
|
||||||
|
import io.anuke.mindustry.entities.Effects.Effect;
|
||||||
import io.anuke.mindustry.entities.type.TileEntity;
|
import io.anuke.mindustry.entities.type.TileEntity;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.consumers.ConsumeItem;
|
|
||||||
import io.anuke.mindustry.world.meta.BlockStat;
|
import io.anuke.mindustry.world.meta.BlockStat;
|
||||||
import io.anuke.mindustry.world.meta.StatUnit;
|
import io.anuke.mindustry.world.meta.StatUnit;
|
||||||
|
|
||||||
@@ -22,6 +21,7 @@ public class GenericCrafter extends Block{
|
|||||||
protected final int timerDump = timers++;
|
protected final int timerDump = timers++;
|
||||||
|
|
||||||
protected Item output;
|
protected Item output;
|
||||||
|
|
||||||
protected float craftTime = 80;
|
protected float craftTime = 80;
|
||||||
protected Effect craftEffect = Fx.purify;
|
protected Effect craftEffect = Fx.purify;
|
||||||
protected Effect updateEffect = Fx.none;
|
protected Effect updateEffect = Fx.none;
|
||||||
@@ -77,13 +77,9 @@ public class GenericCrafter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(entity.progress >= 1f){
|
if(entity.progress >= 1f){
|
||||||
|
entity.cons.trigger();
|
||||||
//TODO, bad design, crafter has to know that this consumes items
|
|
||||||
//there should be a separate trigger in #cons to consume discrete amounts of items
|
|
||||||
if(consumes.has(ConsumeItem.class)) tile.entity.items.remove(consumes.item(), consumes.itemAmount());
|
|
||||||
|
|
||||||
useContent(tile, output);
|
useContent(tile, output);
|
||||||
|
|
||||||
offloadNear(tile, output);
|
offloadNear(tile, output);
|
||||||
Effects.effect(craftEffect, tile.drawx(), tile.drawy());
|
Effects.effect(craftEffect, tile.drawx(), tile.drawy());
|
||||||
entity.progress = 0f;
|
entity.progress = 0f;
|
||||||
@@ -94,6 +90,11 @@ public class GenericCrafter extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProduce(Tile tile){
|
||||||
|
return super.canProduce(tile);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity newEntity(){
|
public TileEntity newEntity(){
|
||||||
return new GenericCrafterEntity();
|
return new GenericCrafterEntity();
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.world.blocks.sandbox;
|
|||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.graphics.Color;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.scene.style.TextureRegionDrawable;
|
import io.anuke.arc.scene.style.TextureRegionDrawable;
|
||||||
import io.anuke.arc.scene.ui.ButtonGroup;
|
import io.anuke.arc.scene.ui.ButtonGroup;
|
||||||
@@ -13,9 +12,7 @@ import io.anuke.mindustry.content.Liquids;
|
|||||||
import io.anuke.mindustry.entities.type.Player;
|
import io.anuke.mindustry.entities.type.Player;
|
||||||
import io.anuke.mindustry.entities.type.TileEntity;
|
import io.anuke.mindustry.entities.type.TileEntity;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.graphics.Pal;
|
|
||||||
import io.anuke.mindustry.type.Liquid;
|
import io.anuke.mindustry.type.Liquid;
|
||||||
import io.anuke.mindustry.ui.Bar;
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
@@ -38,11 +35,10 @@ public class LiquidSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayBars(Tile tile, Table bars){
|
public void setBars(){
|
||||||
TileEntity entity = tile.entity;
|
super.setBars();
|
||||||
|
|
||||||
bars.add(new Bar("blocks.health", Pal.health, entity::healthf).blink(Color.WHITE));
|
bars.remove("liquid");
|
||||||
bars.row();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ public abstract class Consume{
|
|||||||
}).size(10 * scale).get().addListener(new Tooltip<>(t));
|
}).size(10 * scale).get().addListener(new Tooltip<>(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**Called when a consumption is triggered manually.*/
|
||||||
|
public void trigger(Block block, TileEntity entity){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void buildTooltip(Table table);
|
public abstract void buildTooltip(Table table);
|
||||||
|
|
||||||
public abstract String getIcon();
|
public abstract String getIcon();
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ public class ConsumeItem extends Consume{
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trigger(Block block, TileEntity entity){
|
||||||
|
entity.items.remove(item, amount);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTooltip(Table table){
|
public void buildTooltip(Table table){
|
||||||
table.add(new ItemImage(new ItemStack(item, amount))).size(8 * 4);
|
table.add(new ItemImage(new ItemStack(item, amount))).size(8 * 4);
|
||||||
|
|||||||
@@ -46,6 +46,17 @@ public class ConsumeItemFilter extends Consume{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trigger(Block block, TileEntity entity){
|
||||||
|
for(int i = 0; i < content.items().size; i++){
|
||||||
|
Item item = content.item(i);
|
||||||
|
if(entity.items != null && entity.items.has(item) && this.filter.test(item)){
|
||||||
|
entity.items.remove(item, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean valid(Block block, TileEntity entity){
|
public boolean valid(Block block, TileEntity entity){
|
||||||
for(int i = 0; i < content.items().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
|
|||||||
@@ -37,6 +37,13 @@ public class ConsumeItems extends Consume{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trigger(Block block, TileEntity entity){
|
||||||
|
for(ItemStack stack : items){
|
||||||
|
entity.items.remove(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean valid(Block block, TileEntity entity){
|
public boolean valid(Block block, TileEntity entity){
|
||||||
return entity.items != null && entity.items.has(items);
|
return entity.items != null && entity.items.has(items);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class ConsumePower extends Consume{
|
|||||||
@Override
|
@Override
|
||||||
public void display(BlockStats stats){
|
public void display(BlockStats stats){
|
||||||
if(isBuffered){
|
if(isBuffered){
|
||||||
stats.add(BlockStat.powerCapacity, powerCapacity, StatUnit.powerSecond);
|
stats.add(BlockStat.powerCapacity, powerCapacity, StatUnit.none);
|
||||||
}else{
|
}else{
|
||||||
stats.add(BlockStat.powerUse, powerPerTick * 60f, StatUnit.powerSecond);
|
stats.add(BlockStat.powerUse, powerPerTick * 60f, StatUnit.powerSecond);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class BlockBars{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String name){
|
public void remove(String name){
|
||||||
|
if(!bars.containsKey(name)) throw new RuntimeException("No bar with name '" + name + "' found; current bars: " + bars.keys().toArray());
|
||||||
bars.remove(name);
|
bars.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public enum BlockStat{
|
|||||||
itemCapacity(StatCategory.items),
|
itemCapacity(StatCategory.items),
|
||||||
inputItemCapacity(StatCategory.items),
|
inputItemCapacity(StatCategory.items),
|
||||||
outputItemCapacity(StatCategory.items),
|
outputItemCapacity(StatCategory.items),
|
||||||
itemSpeed(StatCategory.items),
|
itemsMoved(StatCategory.items),
|
||||||
|
|
||||||
liquidCapacity(StatCategory.liquids),
|
liquidCapacity(StatCategory.liquids),
|
||||||
liquidOutput(StatCategory.liquids),
|
liquidOutput(StatCategory.liquids),
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ public enum StatUnit{
|
|||||||
powerSecond,
|
powerSecond,
|
||||||
liquidSecond,
|
liquidSecond,
|
||||||
itemsSecond,
|
itemsSecond,
|
||||||
pixelsSecond,
|
|
||||||
liquidUnits,
|
liquidUnits,
|
||||||
powerUnits,
|
powerUnits,
|
||||||
degrees,
|
degrees,
|
||||||
|
|||||||
@@ -9,10 +9,13 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class ConsumeModule extends BlockModule{
|
public class ConsumeModule extends BlockModule{
|
||||||
private boolean valid;
|
private boolean valid;
|
||||||
private TileEntity entity;
|
private final TileEntity entity;
|
||||||
|
|
||||||
public void update(TileEntity entity){
|
public ConsumeModule(TileEntity entity){
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(){
|
||||||
boolean prevValid = valid();
|
boolean prevValid = valid();
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
@@ -27,8 +30,14 @@ public class ConsumeModule extends BlockModule{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void trigger(){
|
||||||
|
for(Consume cons : entity.tile.block().consumes.all()){
|
||||||
|
cons.trigger(entity.tile.block(), entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean valid(){
|
public boolean valid(){
|
||||||
return valid && (entity == null || entity.tile.block().canProduce(entity.tile));
|
return valid && entity.tile.block().canProduce(entity.tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
4
core/src/io/anuke/mindustry/world/producers/Produce.java
Normal file
4
core/src/io/anuke/mindustry/world/producers/Produce.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package io.anuke.mindustry.world.producers;
|
||||||
|
|
||||||
|
public class Produce{
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package io.anuke.mindustry.world.producers;
|
||||||
|
|
||||||
|
public class ProduceItem{
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user