Block drawer icon system fix

This commit is contained in:
Anuke
2022-03-06 14:16:52 -05:00
parent fb2b266661
commit d3ec3f7ebf
37 changed files with 109 additions and 133 deletions

View File

@@ -890,7 +890,7 @@ public class Blocks{
size = 2;
hasPower = true;
hasLiquids = false;
drawer = new DrawMulti(new DrawBlock(), new DrawFlame(Color.valueOf("ffef99")));
drawer = new DrawMulti(new DrawDefault(), new DrawFlame(Color.valueOf("ffef99")));
ambientSound = Sounds.smelter;
ambientSoundVolume = 0.07f;
@@ -908,7 +908,7 @@ public class Blocks{
hasLiquids = false;
itemCapacity = 30;
boostScale = 0.15f;
drawer = new DrawMulti(new DrawBlock(), new DrawFlame(Color.valueOf("ffef99")));
drawer = new DrawMulti(new DrawDefault(), new DrawFlame(Color.valueOf("ffef99")));
ambientSound = Sounds.smelter;
ambientSoundVolume = 0.07f;
@@ -927,8 +927,7 @@ public class Blocks{
envEnabled |= Env.space | Env.underwater;
envDisabled = Env.none;
itemCapacity = 30;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawArcSmelt(), new DrawBlock());
drawer.iconOverride = new String[]{"-bottom", ""};
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawArcSmelt(), new DrawDefault());
fogRadius = 3;
researchCost = with(Items.beryllium, 150, Items.graphite, 50);
@@ -943,7 +942,7 @@ public class Blocks{
craftTime = 30f;
size = 2;
hasPower = hasItems = true;
drawer = new DrawMulti(new DrawBlock(), new DrawFlame(Color.valueOf("ffc099")));
drawer = new DrawMulti(new DrawDefault(), new DrawFlame(Color.valueOf("ffc099")));
ambientSound = Sounds.smelter;
ambientSoundVolume = 0.07f;
@@ -962,7 +961,7 @@ public class Blocks{
hasPower = hasLiquids = true;
craftEffect = Fx.formsmoke;
updateEffect = Fx.plasticburn;
drawer = new DrawMulti(new DrawBlock(), new DrawFade());
drawer = new DrawMulti(new DrawDefault(), new DrawFade());
consumeLiquid(Liquids.oil, 0.25f);
consumePower(3f);
@@ -976,8 +975,7 @@ public class Blocks{
craftTime = 120f;
size = 2;
hasPower = true;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawWeave(), new DrawBlock());
drawer.iconOverride = new String[]{"-bottom", "-weave", ""};
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawWeave(), new DrawDefault());
envEnabled |= Env.space;
ambientSound = Sounds.techloop;
@@ -996,7 +994,7 @@ public class Blocks{
size = 3;
hasPower = true;
itemCapacity = 20;
drawer = new DrawMulti(new DrawBlock(), new DrawFlame());
drawer = new DrawMulti(new DrawDefault(), new DrawFlame());
consumePower(4f);
consumeItems(with(Items.copper, 3, Items.lead, 4, Items.titanium, 2, Items.silicon, 3));
@@ -1013,8 +1011,7 @@ public class Blocks{
solid = true;
outputsLiquid = true;
envEnabled = Env.any;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidTile(Liquids.cryofluid), new DrawBlock());
drawer.iconOverride = new String[]{"-bottom", ""};
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidTile(Liquids.cryofluid), new DrawDefault());
liquidCapacity = 24f;
consumePower(1f);
@@ -1053,7 +1050,7 @@ public class Blocks{
outputLiquid = new LiquidStack(Liquids.slag, 12f / 60f);
craftTime = 1f;
hasLiquids = hasPower = true;
drawer = new DrawMulti(new DrawBlock(), new DrawLiquidRegion());
drawer = new DrawMulti(new DrawDefault(), new DrawLiquidRegion());
consumePower(1f);
consumeItem(Items.scrap, 1);
@@ -1103,14 +1100,12 @@ public class Blocks{
hasPower = true;
craftEffect = Fx.none;
drawer = new DrawMulti(
new DrawBlock(),
new DrawDefault(),
new DrawFrames(),
new DrawLiquidRegion(),
new DrawRegion("-top")
);
drawer.iconOverride = new String[]{"", "-top"};
consumeItem(Items.sporePod, 1);
consumePower(0.7f);
}};
@@ -1122,11 +1117,10 @@ public class Blocks{
craftTime = 40f;
updateEffect = Fx.pulverizeSmall;
hasItems = hasPower = true;
drawer = new DrawMulti(new DrawBlock(), new DrawRegion("-rotator"){{
drawer = new DrawMulti(new DrawDefault(), new DrawRegion("-rotator"){{
spinSprite = true;
rotateSpeed = 2f;
}}, new DrawRegion("-top"));
drawer.iconOverride = new String[]{"", "-rotator", "-top"};
ambientSound = Sounds.grinding;
ambientSoundVolume = 0.025f;
@@ -1188,7 +1182,6 @@ public class Blocks{
}}
);
drawer.iconOverride = new String[]{"-bottom", ""};
regionRotated1 = 3;
outputLiquids = LiquidStack.with(Liquids.ozone, 4f / 60, Liquids.hydrogen, 6f / 60);
liquidOutputDirections = new int[]{1, 3};
@@ -1199,7 +1192,7 @@ public class Blocks{
size = 3;
hasLiquids = true;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidTile(Liquids.nitrogen, 4.1f), new DrawBlock(), new DrawHeatInput(),
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidTile(Liquids.nitrogen, 4.1f), new DrawDefault(), new DrawHeatInput(),
new DrawParticles(){{
color = Color.valueOf("d4f0ff");
alpha = 0.6f;
@@ -1232,8 +1225,7 @@ public class Blocks{
rotateDraw = false;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidRegion(), new DrawBlock(), new DrawHeatOutput());
drawer.iconOverride = new String[]{"-bottom", "", "-top1"};
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidRegion(), new DrawDefault(), new DrawHeatOutput());
regionRotated1 = 2;
craftTime = 60f * 3f;
@@ -1246,9 +1238,8 @@ public class Blocks{
researchCostMultiplier = 4f;
drawer = new DrawMulti(new DrawHeatOutput(true));
drawer = new DrawMulti(new DrawDefault(), new DrawHeatOutput());
rotateDraw = false;
drawer.iconOverride = new String[]{""};
size = 2;
heatOutput = 3f;
regionRotated1 = 1;
@@ -1258,8 +1249,7 @@ public class Blocks{
phaseHeater = new HeatProducer("phase-heater"){{
requirements(Category.crafting, with(Items.oxide, 30, Items.carbide, 30, Items.beryllium, 30));
drawer = new DrawMulti(new DrawHeatOutput(true));
drawer.iconOverride = new String[]{""};
drawer = new DrawMulti(new DrawDefault(), new DrawHeatOutput());
size = 2;
heatOutput = 10f;
craftTime = 60f * 8f;
@@ -1273,7 +1263,7 @@ public class Blocks{
researchCostMultiplier = 10f;
size = 3;
drawer = new DrawMulti(new DrawHeatOutput(true), new DrawHeatInput("-heat"));
drawer = new DrawMulti(new DrawDefault(), new DrawHeatOutput(), new DrawHeatInput("-heat"));
regionRotated1 = 1;
}};
@@ -1291,8 +1281,7 @@ public class Blocks{
size = 3;
itemCapacity = 20;
hasPower = hasItems = true;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawCrucibleFlame(), new DrawBlock(), new DrawHeatInput());
drawer.iconOverride = new String[]{"-bottom", ""};
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawCrucibleFlame(), new DrawDefault(), new DrawHeatInput());
ambientSound = Sounds.smelter;
ambientSoundVolume = 0.07f;
@@ -1324,8 +1313,7 @@ public class Blocks{
}});
}
drawer = new DrawMulti(drawers.and(new DrawBlock()));
drawer.iconOverride = new String[]{"-bottom", ""};
drawer = new DrawMulti(drawers.and(new DrawDefault()));
craftTime = 60f * 2f;
@@ -1357,14 +1345,13 @@ public class Blocks{
strokeMax = 2.5f;
radius = 10f;
amount = 3;
}}, new DrawLiquidRegion(Liquids.slag), new DrawBlock(), new DrawHeatInput(),
}}, new DrawLiquidRegion(Liquids.slag), new DrawDefault(), new DrawHeatInput(),
new DrawHeatRegion(){{
color = Color.valueOf("ff6060ff");
}},
new DrawHeatRegion("-vents"){{
color.a = 1f;
}});
drawer.iconOverride = new String[]{"-bottom", ""};
consumeItem(Items.silicon, 3);
//TODO must consume from 2 pumps, 1, or 1.5?
@@ -1389,9 +1376,7 @@ public class Blocks{
particleLife = 200f;
reverse = true;
particleSizeInterp = Interp.one;
}}, new DrawBlock(), new DrawHeatInput(), new DrawHeatRegion("-heat-top"));
drawer.iconOverride = new String[]{"-bottom", ""};
}}, new DrawDefault(), new DrawHeatInput(), new DrawHeatRegion("-heat-top"));
size = 3;
@@ -1428,10 +1413,9 @@ public class Blocks{
layerSpeed = -0.9f;
}}, new DrawMultiWeave(){{
glowColor = new Color(1f, 0.4f, 0.4f, 0.8f);
}}, new DrawBlock(), new DrawHeatInput(), new DrawHeatRegion("-vents"){{
}}, new DrawDefault(), new DrawHeatInput(), new DrawHeatRegion("-vents"){{
color = new Color(1f, 0.4f, 0.3f, 1f);
}});
drawer.iconOverride = new String[]{"-bottom", "-weave", ""};
consumeItems(with(Items.thorium, 2, Items.sand, 6));
consumeLiquid(Liquids.ozone, 2f / 60f);
@@ -1738,7 +1722,7 @@ public class Blocks{
Color col = Color.valueOf("8ca9e8");
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidTile(Liquids.hydrogen, 9f / 4f), new DrawBlock(), new DrawGlowRegion(){{
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidTile(Liquids.hydrogen, 9f / 4f), new DrawDefault(), new DrawGlowRegion(){{
color = Color.sky;
}}, new DrawPulseShape(false){{
layer = Layer.effect;
@@ -2191,7 +2175,7 @@ public class Blocks{
consume(new ConsumeItemFlammable());
consume(new ConsumeItemExplode());
drawer = new DrawMulti(new DrawBlock(), new DrawWarmupRegion());
drawer = new DrawMulti(new DrawDefault(), new DrawWarmupRegion());
}};
thermalGenerator = new ThermalGenerator("thermal-generator"){{
@@ -2212,7 +2196,6 @@ public class Blocks{
consumeLiquid(Liquids.water, 0.1f);
hasLiquids = true;
size = 2;
drawer.iconOverride = new String[]{"", "-turbine0", "-turbine1"};
generateEffect = Fx.generatespark;
ambientSound = Sounds.smelter;
@@ -2221,7 +2204,7 @@ public class Blocks{
consume(new ConsumeItemFlammable());
consume(new ConsumeItemExplode());
drawer = new DrawMulti(new DrawBlock(), new DrawWarmupRegion(), new DrawTurbines());
drawer = new DrawMulti(new DrawDefault(), new DrawWarmupRegion(), new DrawTurbines());
}};
differentialGenerator = new ConsumeGenerator("differential-generator"){{
@@ -2235,7 +2218,7 @@ public class Blocks{
generateEffect = Fx.generatespark;
ambientSoundVolume = 0.03f;
drawer = new DrawMulti(new DrawBlock(), new DrawWarmupRegion());
drawer = new DrawMulti(new DrawDefault(), new DrawWarmupRegion());
consumeItem(Items.pyratite);
consumeLiquid(Liquids.cryofluid, 0.1f);
@@ -2249,7 +2232,7 @@ public class Blocks{
envEnabled = Env.any;
generateEffect = Fx.generatespark;
drawer = new DrawMulti(new DrawBlock(), new DrawWarmupRegion());
drawer = new DrawMulti(new DrawDefault(), new DrawWarmupRegion());
consume(new ConsumeItemRadioactive());
}};
@@ -2356,12 +2339,11 @@ public class Blocks{
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawPistons(){{
sinMag = 3f;
sinScl = 5f;
}}, new DrawRegion("-mid"), new DrawLiquidTile(Liquids.arkycite, 37f / 4f), new DrawBlock(), new DrawGlowRegion(){{
}}, new DrawRegion("-mid"), new DrawLiquidTile(Liquids.arkycite, 37f / 4f), new DrawDefault(), new DrawGlowRegion(){{
alpha = 1f;
glowScale = 5f;
color = Color.valueOf("c967b099");
}});
drawer.iconOverride = new String[]{"-bottom", ""};
generateEffect = Fx.none;
liquidCapacity = 20f * 5;
@@ -2381,7 +2363,7 @@ public class Blocks{
sinScl = 5f;
sides = 8;
sideOffset = Mathf.PI / 2f;
}}, new DrawRegion("-mid"), new DrawLiquidTile(Liquids.arkycite, 38f / 4f), new DrawBlock(), new DrawGlowRegion(){{
}}, new DrawRegion("-mid"), new DrawLiquidTile(Liquids.arkycite, 38f / 4f), new DrawDefault(), new DrawGlowRegion(){{
alpha = 1f;
glowScale = 5f;
color = Pal.slagOrange;
@@ -2395,7 +2377,6 @@ public class Blocks{
liquidOutput = new LiquidStack(Liquids.water, 5f / 60f);
drawer.iconOverride = new String[]{"-bottom", ""};
generateEffect = Fx.none;
ambientSound = Sounds.smelter;
@@ -2487,11 +2468,10 @@ public class Blocks{
legacyReadWarmup = true;
drawer = new DrawMulti(
new DrawBlock(),
new DrawDefault(),
new DrawCultivator(),
new DrawRegion("-top")
);
drawer.iconOverride = new String[]{"", "-top"};
maxBoost = 2f;
consumePower(80f / 60f);
@@ -2523,8 +2503,7 @@ public class Blocks{
baseEfficiency = 0f;
displayEfficiency = false;
craftEffect = Fx.turbinegenerate;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawBlurSpin("-rotator", 6f), new DrawRegion("-mid"), new DrawLiquidTile(Liquids.water, 38f / 4f), new DrawBlock());
drawer.iconOverride = new String[]{"-bottom", "-rotator", ""};
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawBlurSpin("-rotator", 6f), new DrawRegion("-mid"), new DrawLiquidTile(Liquids.water, 38f / 4f), new DrawDefault());
craftTime = 120f;
size = 3;
ambientSound = Sounds.hum;

View File

@@ -415,11 +415,10 @@ public class ClassMap{
classes.put("DrawLiquidTile", mindustry.world.draw.DrawLiquidTile.class);
classes.put("DrawMulti", mindustry.world.draw.DrawMulti.class);
classes.put("DrawMultiWeave", mindustry.world.draw.DrawMultiWeave.class);
classes.put("DrawPartial", mindustry.world.draw.DrawPartial.class);
classes.put("DrawParticles", mindustry.world.draw.DrawParticles.class);
classes.put("DrawPistons", mindustry.world.draw.DrawPistons.class);
classes.put("DrawPulseShape", mindustry.world.draw.DrawPulseShape.class);
classes.put("DrawPump", mindustry.world.draw.DrawPump.class);
classes.put("DrawPump", DrawPumpLiquid.class);
classes.put("DrawRegion", mindustry.world.draw.DrawRegion.class);
classes.put("DrawShape", mindustry.world.draw.DrawShape.class);
classes.put("DrawSideRegion", mindustry.world.draw.DrawSideRegion.class);

View File

@@ -135,7 +135,7 @@ public class ContentParser{
if(data.isArray()){
return new DrawMulti(parser.readValue(DrawBlock[].class, data));
}
var bc = resolve(data.getString("type", ""), DrawBlock.class);
var bc = resolve(data.getString("type", ""), DrawDefault.class);
data.remove("type");
var result = make(bc);
readFields(result, data);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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. */

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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");

View 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);
}
}

View File

@@ -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;

View File

@@ -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];

View File

@@ -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;

View File

@@ -47,7 +47,6 @@ public class DrawHeatInput extends DrawBlock{
}
}
Draw.z(Layer.block);
}
@Override

View File

@@ -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
}

View File

@@ -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

View File

@@ -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[]{};
}
}

View File

@@ -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.");

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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");

View File

@@ -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){}
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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};
}
}

View File

@@ -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;

View File

@@ -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]};
}
}

View File

@@ -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