Block drawer icon system fix
This commit is contained in:
@@ -29,7 +29,7 @@ public class RegenProjector extends Block{
|
||||
public float optionalMultiplier = 2f;
|
||||
public float optionalUseTime = 60f * 8f;
|
||||
|
||||
public DrawBlock drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawSideRegion(true));
|
||||
public DrawBlock drawer = new DrawDefault();
|
||||
|
||||
public float effectChance = 0.003f;
|
||||
public Color baseColor = Pal.accent;
|
||||
|
||||
@@ -13,7 +13,7 @@ import mindustry.world.draw.*;
|
||||
|
||||
public class HeatConductor extends Block{
|
||||
public float visualMaxHeat = 15f;
|
||||
public DrawBlock drawer = new DrawBlock();
|
||||
public DrawBlock drawer = new DrawDefault();
|
||||
|
||||
public HeatConductor(String name){
|
||||
super(name);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class HeatProducer extends GenericCrafter{
|
||||
public HeatProducer(String name){
|
||||
super(name);
|
||||
|
||||
drawer = new DrawHeatOutput(true);
|
||||
drawer = new DrawMulti(new DrawDefault(), new DrawHeatOutput());
|
||||
rotateDraw = false;
|
||||
rotate = true;
|
||||
canOverdrive = false;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class PowerGenerator extends PowerDistributor{
|
||||
/** The amount of power produced per tick in case of an efficiency of 1.0, which represents 100%. */
|
||||
public float powerProduction;
|
||||
public Stat generationType = Stat.basePowerGeneration;
|
||||
public DrawBlock drawer = new DrawBlock();
|
||||
public DrawBlock drawer = new DrawDefault();
|
||||
|
||||
public PowerGenerator(String name){
|
||||
super(name);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GenericCrafter extends Block{
|
||||
/** Only used for legacy cultivator blocks. */
|
||||
public boolean legacyReadWarmup = false;
|
||||
|
||||
public DrawBlock drawer = new DrawBlock();
|
||||
public DrawBlock drawer = new DrawDefault();
|
||||
|
||||
public GenericCrafter(String name){
|
||||
super(name);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Pump extends LiquidBlock{
|
||||
public float pumpAmount = 0.2f;
|
||||
/** Interval in-between item consumptions, if applicable. */
|
||||
public float consumeTime = 60f * 5f;
|
||||
public DrawBlock draw = new DrawPump();
|
||||
public DrawBlock draw = new DrawMulti(new DrawDefault(), new DrawPumpLiquid());
|
||||
|
||||
public Pump(String name){
|
||||
super(name);
|
||||
|
||||
@@ -6,7 +6,7 @@ import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class DrawArcSmelt extends DrawPartial{
|
||||
public class DrawArcSmelt extends DrawBlock{
|
||||
public Color flameColor = Color.valueOf("f58349"), midColor = Color.valueOf("f2d585");
|
||||
public float flameRad = 1f, circleSpace = 2f, flameRadiusScl = 3f, flameRadiusMag = 0.3f, circleStroke = 1.5f;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import mindustry.world.blocks.production.*;
|
||||
|
||||
/** An implementation of custom rendering behavior for a crafter block.
|
||||
* This is used mostly for mods. */
|
||||
public class DrawBlock{
|
||||
public abstract class DrawBlock{
|
||||
protected static final Rand rand = new Rand();
|
||||
|
||||
/** If set, the icon is overridden to be these strings, in order. Each string is a suffix. */
|
||||
@@ -24,7 +24,7 @@ public class DrawBlock{
|
||||
|
||||
/** Draws the block itself. */
|
||||
public void draw(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y, build.drawrot());
|
||||
|
||||
}
|
||||
|
||||
/** Draws any extra light for the block. */
|
||||
@@ -34,7 +34,7 @@ public class DrawBlock{
|
||||
|
||||
/** Draws the planned version of this block. */
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
block.drawDefaultPlanRegion(plan, list);
|
||||
|
||||
}
|
||||
|
||||
/** Load any relevant texture regions. */
|
||||
|
||||
@@ -2,8 +2,6 @@ package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
@@ -28,8 +26,8 @@ public class DrawBlurSpin extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{region};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@ import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class DrawBubbles extends DrawPartial{
|
||||
public class DrawBubbles extends DrawBlock{
|
||||
public Color color = Color.valueOf("7457ce");
|
||||
|
||||
public int amount = 12, sides = 8;
|
||||
|
||||
@@ -6,7 +6,7 @@ import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class DrawCircles extends DrawPartial{
|
||||
public class DrawCircles extends DrawBlock{
|
||||
public Color color = Color.valueOf("7457ce");
|
||||
|
||||
public int amount = 5, sides = 15;
|
||||
|
||||
@@ -7,7 +7,7 @@ import arc.math.Interp.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class DrawCrucibleFlame extends DrawPartial{
|
||||
public class DrawCrucibleFlame extends DrawBlock{
|
||||
public Color flameColor = Color.valueOf("f58349"), midColor = Color.valueOf("f2d585");
|
||||
public float flameRad = 1f, circleSpace = 2f, flameRadiusScl = 10f, flameRadiusMag = 0.6f, circleStroke = 1.5f;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawCultivator extends DrawPartial{
|
||||
public class DrawCultivator extends DrawBlock{
|
||||
public Color plantColor = Color.valueOf("5541b1");
|
||||
public Color plantColorLight = Color.valueOf("7457ce");
|
||||
public Color bottomColor = Color.valueOf("474747");
|
||||
|
||||
20
core/src/mindustry/world/draw/DrawDefault.java
Normal file
20
core/src/mindustry/world/draw/DrawDefault.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawDefault extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y, build.drawrot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
block.drawDefaultPlanRegion(plan, list);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
//TODO remake/remove
|
||||
public class DrawFlame extends DrawPartial{
|
||||
public class DrawFlame extends DrawBlock{
|
||||
public Color flameColor = Color.valueOf("ffc999");
|
||||
public TextureRegion top;
|
||||
public float lightRadius = 60f, lightAlpha = 0.65f, lightSinScl = 10f, lightSinMag = 5;
|
||||
|
||||
@@ -6,7 +6,7 @@ import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawFrames extends DrawPartial{
|
||||
public class DrawFrames extends DrawBlock{
|
||||
/** Number of frames to draw. */
|
||||
public int frames = 3;
|
||||
/** Ticks between frames. */
|
||||
@@ -24,6 +24,11 @@ public class DrawFrames extends DrawPartial{
|
||||
build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{regions[0]};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
regions = new TextureRegion[frames];
|
||||
|
||||
@@ -9,7 +9,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawGlowRegion extends DrawPartial{
|
||||
public class DrawGlowRegion extends DrawBlock{
|
||||
public Blending blending = Blending.additive;
|
||||
public String suffix = "-glow";
|
||||
public float alpha = 0.9f, glowScale = 10f, glowIntensity = 0.5f;
|
||||
|
||||
@@ -47,7 +47,6 @@ public class DrawHeatInput extends DrawBlock{
|
||||
}
|
||||
}
|
||||
Draw.z(Layer.block);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,19 +16,9 @@ public class DrawHeatOutput extends DrawBlock{
|
||||
|
||||
public Color heatColor = new Color(1f, 0.22f, 0.22f, 0.8f);
|
||||
public float heatPulse = 0.3f, heatPulseScl = 10f, glowMult = 1.2f;
|
||||
public boolean drawRegion = false;
|
||||
|
||||
public DrawHeatOutput(){
|
||||
}
|
||||
|
||||
public DrawHeatOutput(boolean drawRegion){
|
||||
this.drawRegion = drawRegion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
if(drawRegion) Draw.rect(build.block.region, build.x, build.y);
|
||||
|
||||
Draw.rect(build.rotation > 1 ? top2 : top1, build.x, build.y, build.rotdeg());
|
||||
|
||||
if(build instanceof HeatBlock heater && heater.heat() > 0){
|
||||
@@ -45,7 +35,6 @@ public class DrawHeatOutput extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
if(drawRegion) Draw.rect(block.region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(plan.rotation > 1 ? top2 : top1, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
|
||||
@@ -57,9 +46,6 @@ public class DrawHeatOutput extends DrawBlock{
|
||||
top2 = Core.atlas.find(block.name + "-top2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{block.region, top1};
|
||||
}
|
||||
//TODO currently no icons due to concerns with rotation
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ public class DrawHeatRegion extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
|
||||
Draw.z(Layer.blockAdditive);
|
||||
if(build instanceof HeatCrafterBuild hc && hc.heat > 0){
|
||||
Draw.blend(Blending.additive);
|
||||
@@ -36,7 +35,6 @@ public class DrawHeatRegion extends DrawBlock{
|
||||
Draw.color();
|
||||
}
|
||||
Draw.z(Layer.block);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,9 +54,9 @@ public class DrawLiquidOutputs extends DrawBlock{
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
//can't display these properly
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return super.icons(block);
|
||||
return new TextureRegion[]{};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,13 @@ package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawLiquidRegion extends DrawPartial{
|
||||
public class DrawLiquidRegion extends DrawBlock{
|
||||
public Liquid drawLiquid;
|
||||
public TextureRegion liquid;
|
||||
public String suffix = "-liquid";
|
||||
@@ -31,6 +30,7 @@ public class DrawLiquidRegion extends DrawPartial{
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
if(!block.hasLiquids){
|
||||
throw new RuntimeException("Block '" + block + "' has a DrawLiquidRegion, but hasLiquids is false! Make sure it is true.");
|
||||
|
||||
@@ -5,7 +5,7 @@ import mindustry.type.*;
|
||||
import mindustry.world.blocks.liquid.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawLiquidTile extends DrawPartial{
|
||||
public class DrawLiquidTile extends DrawBlock{
|
||||
public Liquid drawLiquid;
|
||||
public float padding;
|
||||
public float alpha = 1f;
|
||||
|
||||
@@ -10,8 +10,6 @@ import mindustry.world.*;
|
||||
/** combined several DrawBlocks into one */
|
||||
public class DrawMulti extends DrawBlock{
|
||||
public DrawBlock[] drawers = {};
|
||||
/** specifies the drawer index that sources the icon (since there can only be one icon source) */
|
||||
public int iconIndex = 0;
|
||||
|
||||
public DrawMulti(){
|
||||
}
|
||||
@@ -61,6 +59,10 @@ public class DrawMulti extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return drawers.length <= iconIndex ? super.icons(block) : drawers[iconIndex].icons(block);
|
||||
var result = new Seq<TextureRegion>();
|
||||
for(var draw : drawers){
|
||||
result.addAll(draw.icons(block));
|
||||
}
|
||||
return result.toArray(TextureRegion.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,11 @@ public class DrawMultiWeave extends DrawBlock{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{weave};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
weave = Core.atlas.find(block.name + "-weave");
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public abstract class DrawPartial extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import mindustry.graphics.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class DrawPulseShape extends DrawPartial{
|
||||
public class DrawPulseShape extends DrawBlock{
|
||||
public Color color = Pal.accent.cpy();
|
||||
public float stroke = 2f, timeScl = 100f, minStroke = 0.2f;
|
||||
public float radiusScl = 1f;
|
||||
|
||||
@@ -7,13 +7,11 @@ import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.Pump.*;
|
||||
|
||||
public class DrawPump extends DrawBlock{
|
||||
public class DrawPumpLiquid extends DrawBlock{
|
||||
public TextureRegion liquid;
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
|
||||
if(!(build instanceof PumpBuild pump) || pump.liquidDrop == null) return;
|
||||
|
||||
Drawf.liquid(liquid, build.x, build.y, build.liquids.get(pump.liquidDrop) / build.block.liquidCapacity, pump.liquidDrop.color);
|
||||
@@ -43,6 +43,11 @@ public class DrawRegion extends DrawBlock{
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{region};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
region = Core.atlas.find(block.name + suffix);
|
||||
|
||||
@@ -5,7 +5,7 @@ import arc.graphics.g2d.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class DrawShape extends DrawPartial{
|
||||
public class DrawShape extends DrawBlock{
|
||||
public Color color = Pal.accent.cpy();
|
||||
public int sides = 4;
|
||||
public float radius = 2f, timeScl = 1f, layer = -1f, x, y;
|
||||
|
||||
@@ -8,26 +8,16 @@ import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawSideRegion extends DrawBlock{
|
||||
public boolean drawRegion = false;
|
||||
public TextureRegion top1, top2;
|
||||
|
||||
public DrawSideRegion(){
|
||||
}
|
||||
|
||||
public DrawSideRegion(boolean drawRegion){
|
||||
this.drawRegion = drawRegion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
if(drawRegion) Draw.rect(build.block.region, build.x, build.y);
|
||||
|
||||
Draw.rect(build.rotation > 1 ? top2 : top1, build.x, build.y, build.rotdeg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
if(drawRegion) Draw.rect(block.region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(plan.rotation > 1 ? top2 : top1, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
|
||||
@@ -39,7 +29,7 @@ public class DrawSideRegion extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{block.region, top1};
|
||||
return new TextureRegion[]{top1};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class DrawSpikes extends DrawPartial{
|
||||
public class DrawSpikes extends DrawBlock{
|
||||
public Color color = Color.valueOf("7457ce");
|
||||
|
||||
public int amount = 10, layers = 1;
|
||||
|
||||
@@ -2,12 +2,10 @@ package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawTurbines extends DrawPartial{
|
||||
public class DrawTurbines extends DrawBlock{
|
||||
public TextureRegion[] turbines = new TextureRegion[2];
|
||||
public TextureRegion cap;
|
||||
public float turbineSpeed = 2f;
|
||||
@@ -33,4 +31,9 @@ public class DrawTurbines extends DrawPartial{
|
||||
turbines[i] = Core.atlas.find(block.name + "-turbine" + i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{turbines[0], turbines[1]};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawWeave extends DrawPartial{
|
||||
public class DrawWeave extends DrawBlock{
|
||||
public TextureRegion weave;
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user