mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-10 07:47:25 +07:00
Class cleanup
This commit is contained in:
@ -33,6 +33,7 @@ import io.anuke.mindustry.world.blocks.units.UnitFactory;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeItemFilter;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
|
||||
import io.anuke.mindustry.world.meta.Attribute;
|
||||
import io.anuke.mindustry.world.modules.LiquidModule;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
@ -426,7 +427,7 @@ public class Blocks implements ContentList{
|
||||
consumes.power(0.60f);
|
||||
}};
|
||||
|
||||
plastaniumCompressor = new PlastaniumCompressor("plastanium-compressor"){{
|
||||
plastaniumCompressor = new GenericCrafter("plastanium-compressor"){{
|
||||
requirements(Category.crafting, ItemStack.with(Items.silicon, 160, Items.lead, 230, Items.graphite, 120, Items.titanium, 160));
|
||||
hasItems = true;
|
||||
liquidCapacity = 60f;
|
||||
@ -441,6 +442,18 @@ public class Blocks implements ContentList{
|
||||
consumes.liquid(Liquids.oil, 0.25f);
|
||||
consumes.power(3f);
|
||||
consumes.item(Items.titanium, 2);
|
||||
|
||||
int topRegion = reg("-top");
|
||||
|
||||
drawer = tile -> {
|
||||
super.draw(tile);
|
||||
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
|
||||
Draw.alpha(Mathf.absin(entity.totalProgress, 3f, 0.9f) * entity.warmup);
|
||||
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy());
|
||||
Draw.reset();
|
||||
};
|
||||
}};
|
||||
|
||||
phaseWeaver = new GenericCrafter("phase-weaver"){{
|
||||
@ -453,7 +466,7 @@ public class Blocks implements ContentList{
|
||||
consumes.items(new ItemStack(Items.thorium, 4), new ItemStack(Items.sand, 10));
|
||||
consumes.power(5f);
|
||||
|
||||
int bottomRegion = addr(name + "-bottom"), weaveRegion = addr(name + "-weave");
|
||||
int bottomRegion = reg("-bottom"), weaveRegion = reg("-weave");
|
||||
|
||||
drawer = tile -> {
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
@ -499,7 +512,7 @@ public class Blocks implements ContentList{
|
||||
consumes.items(new ItemStack(Items.titanium, 2), new ItemStack(Items.lead, 4), new ItemStack(Items.silicon, 3), new ItemStack(Items.copper, 3));
|
||||
}};
|
||||
|
||||
cryofluidMixer = new LiquidMixer("cryofluidmixer"){{
|
||||
cryofluidMixer = new GenericCrafter("cryofluidmixer"){{
|
||||
requirements(Category.crafting, ItemStack.with(Items.lead, 130, Items.silicon, 80, Items.thorium, 90));
|
||||
outputLiquid = new LiquidStack(Liquids.cryofluid, 0.3f);
|
||||
craftTime = 5f;
|
||||
@ -514,6 +527,27 @@ public class Blocks implements ContentList{
|
||||
consumes.power(1f);
|
||||
consumes.item(Items.titanium);
|
||||
consumes.liquid(Liquids.water, 0.3f);
|
||||
|
||||
int liquidRegion = reg("-liquid"), topRegion = reg("-top"), bottomRegion = reg("-bottom");
|
||||
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
||||
|
||||
drawer = tile -> {
|
||||
LiquidModule mod = tile.entity.liquids;
|
||||
|
||||
int rotation = rotate ? tile.getRotation() * 90 : 0;
|
||||
|
||||
Draw.rect(reg(bottomRegion), tile.drawx(), tile.drawy(), rotation);
|
||||
|
||||
if(mod.total() > 0.001f){
|
||||
Draw.color(outputLiquid.liquid.color);
|
||||
Draw.alpha(mod.get(outputLiquid.liquid) / liquidCapacity);
|
||||
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy(), rotation);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy(), rotation);
|
||||
};
|
||||
}};
|
||||
|
||||
blastMixer = new GenericCrafter("blast-mixer"){{
|
||||
@ -584,7 +618,7 @@ public class Blocks implements ContentList{
|
||||
consumes.liquid(Liquids.water, 0.15f);
|
||||
}};
|
||||
|
||||
sporePress = new Compressor("spore-press"){{
|
||||
sporePress = new GenericCrafter("spore-press"){{
|
||||
requirements(Category.crafting, ItemStack.with(Items.lead, 70, Items.silicon, 60));
|
||||
liquidCapacity = 60f;
|
||||
craftTime = 20f;
|
||||
@ -595,9 +629,28 @@ public class Blocks implements ContentList{
|
||||
|
||||
consumes.item(Items.sporePod, 1);
|
||||
consumes.power(0.60f);
|
||||
|
||||
int[] frameRegions = new int[3];
|
||||
for(int i = 0; i < 3; i++){
|
||||
frameRegions[i] = reg("-frame" + i);
|
||||
}
|
||||
|
||||
int liquidRegion = reg("-liquid");
|
||||
int topRegion =reg("-top");
|
||||
|
||||
drawer = tile -> {
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Draw.rect(reg(frameRegions[(int) Mathf.absin(entity.totalProgress, 5f, 2.999f)]), tile.drawx(), tile.drawy());
|
||||
Draw.color(Color.CLEAR, tile.entity.liquids.current().color, tile.entity.liquids.total() / liquidCapacity);
|
||||
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy());
|
||||
};
|
||||
}};
|
||||
|
||||
pulverizer = new Pulverizer("pulverizer"){{
|
||||
pulverizer = new GenericCrafter("pulverizer"){{
|
||||
requirements(Category.crafting, ItemStack.with(Items.copper, 60, Items.lead, 50));
|
||||
outputItem = new ItemStack(Items.sand, 1);
|
||||
craftEffect = Fx.pulverize;
|
||||
@ -607,6 +660,15 @@ public class Blocks implements ContentList{
|
||||
|
||||
consumes.item(Items.scrap, 1);
|
||||
consumes.power(0.50f);
|
||||
|
||||
int rotatorRegion = reg("-rotator");
|
||||
|
||||
drawer = tile -> {
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Draw.rect(reg(rotatorRegion), tile.drawx(), tile.drawy(), entity.totalProgress * 2f);
|
||||
};
|
||||
}};
|
||||
|
||||
incinerator = new Incinerator("incinerator"){{
|
||||
|
@ -334,9 +334,9 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
}
|
||||
|
||||
/**Adds a region by name to be loaded. Returns an ID to looks this region up by in {@link #reg(int)}.*/
|
||||
protected int addr(String name){
|
||||
cacheRegionStrings.add(name);
|
||||
/**Adds a region by name to be loaded, with the final name "{name}-suffix". Returns an ID to looks this region up by in {@link #reg(int)}.*/
|
||||
protected int reg(String suffix){
|
||||
cacheRegionStrings.add(name + suffix);
|
||||
return cacheRegionStrings.size - 1;
|
||||
}
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class Compressor extends GenericCrafter{
|
||||
protected TextureRegion liquidRegion, topRegion;
|
||||
protected TextureRegion[] frameRegions;
|
||||
|
||||
public Compressor(String name){
|
||||
super(name);
|
||||
hasLiquids = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
frameRegions = new TextureRegion[3];
|
||||
for(int i = 0; i < 3; i++){
|
||||
frameRegions[i] = Core.atlas.find(name + "-frame" + i);
|
||||
}
|
||||
|
||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Draw.rect(frameRegions[(int) Mathf.absin(entity.totalProgress, 5f, 2.999f)], tile.drawx(), tile.drawy());
|
||||
Draw.color(Color.CLEAR, tile.entity.liquids.current().color, tile.entity.liquids.total() / liquidCapacity);
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")};
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ public class Drill extends Block{
|
||||
protected final static float hardnessDrillMultiplier = 50f;
|
||||
protected final int timerDump = timers++;
|
||||
|
||||
protected final Array<Tile> drawTiles = new Array<>();
|
||||
protected final ObjectIntMap<Item> oreCount = new ObjectIntMap<>();
|
||||
protected final Array<Item> itemArray = new Array<>();
|
||||
|
||||
@ -270,14 +269,14 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
public static class DrillEntity extends TileEntity{
|
||||
public float progress;
|
||||
public int index;
|
||||
public float warmup;
|
||||
public float drillTime;
|
||||
public float lastDrillSpeed;
|
||||
float progress;
|
||||
int index;
|
||||
float warmup;
|
||||
float drillTime;
|
||||
float lastDrillSpeed;
|
||||
|
||||
public int dominantItems;
|
||||
public Item dominantItem;
|
||||
int dominantItems;
|
||||
Item dominantItem;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
@ -31,6 +33,7 @@ public class GenericCrafter extends Block{
|
||||
protected float updateEffectChance = 0.04f;
|
||||
|
||||
protected Consumer<Tile> drawer = null;
|
||||
protected Supplier<TextureRegion[]> drawIcons = null;
|
||||
|
||||
public GenericCrafter(String name){
|
||||
super(name);
|
||||
@ -62,6 +65,12 @@ public class GenericCrafter extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return drawIcons == null ? super.generateIcons() : drawIcons.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
@ -122,6 +131,8 @@ public class GenericCrafter extends Block{
|
||||
return itemCapacity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class GenericCrafterEntity extends TileEntity{
|
||||
public float progress;
|
||||
public float totalProgress;
|
||||
|
@ -1,47 +0,0 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.modules.LiquidModule;
|
||||
|
||||
public class LiquidMixer extends GenericCrafter{
|
||||
protected TextureRegion liquidRegion, bottomRegion, topRegion;
|
||||
|
||||
public LiquidMixer(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
bottomRegion = Core.atlas.find(name + "-bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
LiquidModule mod = tile.entity.liquids;
|
||||
|
||||
int rotation = rotate ? tile.getRotation() * 90 : 0;
|
||||
|
||||
Draw.rect(bottomRegion, tile.drawx(), tile.drawy(), rotation);
|
||||
|
||||
if(mod.total() > 0.001f){
|
||||
Draw.color(outputLiquid.liquid.color);
|
||||
Draw.alpha(mod.get(outputLiquid.liquid) / liquidCapacity);
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy(), rotation);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy(), rotation);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
|
||||
public class PlastaniumCompressor extends GenericCrafter{
|
||||
protected TextureRegion topRegion;
|
||||
|
||||
public PlastaniumCompressor(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
|
||||
Draw.alpha(Mathf.absin(entity.totalProgress, 3f, 0.9f) * entity.warmup);
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
|
||||
public class Pulverizer extends GenericCrafter{
|
||||
protected TextureRegion rotatorRegion;
|
||||
|
||||
public Pulverizer(String name){
|
||||
super(name);
|
||||
hasItems = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
rotatorRegion = Core.atlas.find(name + "-rotator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Draw.rect(rotatorRegion, tile.drawx(), tile.drawy(), entity.totalProgress * 2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator")};
|
||||
}
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
@ -30,7 +28,7 @@ public class Separator extends Block{
|
||||
protected float spinnerSpeed = 2f;
|
||||
|
||||
protected Color color = Color.valueOf("858585");
|
||||
protected TextureRegion liquidRegion;
|
||||
protected int liquidRegion;
|
||||
|
||||
public Separator(String name){
|
||||
super(name);
|
||||
@ -38,13 +36,8 @@ public class Separator extends Block{
|
||||
solid = true;
|
||||
hasItems = true;
|
||||
hasLiquids = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||
liquidRegion = reg("liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,7 +60,7 @@ public class Separator extends Block{
|
||||
|
||||
Draw.color(tile.entity.liquids.current().color);
|
||||
Draw.alpha(tile.entity.liquids.total() / liquidCapacity);
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy());
|
||||
|
||||
Draw.color(color);
|
||||
Lines.stroke(spinnerThickness);
|
||||
|
Reference in New Issue
Block a user