Making DrawBlock more generic
This commit is contained in:
@@ -3,9 +3,9 @@ package mindustry.world.draw;
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawAnimation extends DrawBlock{
|
||||
public int frameCount = 3;
|
||||
@@ -15,12 +15,12 @@ public class DrawAnimation extends DrawBlock{
|
||||
public TextureRegion liquid, top;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
Draw.rect(
|
||||
sine ?
|
||||
frames[(int)Mathf.absin(build.totalProgress, frameSpeed, frameCount - 0.001f)] :
|
||||
frames[(int)((build.totalProgress / frameSpeed) % frameCount)],
|
||||
frames[(int)Mathf.absin(build.totalProgress(), frameSpeed, frameCount - 0.001f)] :
|
||||
frames[(int)((build.totalProgress() / frameSpeed) % frameCount)],
|
||||
build.x, build.y);
|
||||
|
||||
if(build.liquids != null){
|
||||
|
||||
@@ -5,8 +5,8 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawArcSmelter extends DrawBlock{
|
||||
public TextureRegion top, bottom;
|
||||
@@ -21,23 +21,23 @@ public class DrawArcSmelter extends DrawBlock{
|
||||
public Blending blending = Blending.additive;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
if(drawBottom) Draw.rect(bottom, build.x, build.y);
|
||||
|
||||
if(build.warmup > 0f && flameColor.a > 0.001f){
|
||||
Lines.stroke(circleStroke * build.warmup);
|
||||
if(build.warmup() > 0f && flameColor.a > 0.001f){
|
||||
Lines.stroke(circleStroke * build.warmup());
|
||||
|
||||
float si = Mathf.absin(flameRadiusScl, flameRadiusMag);
|
||||
float a = alpha * build.warmup;
|
||||
float a = alpha * build.warmup();
|
||||
Draw.blend(blending);
|
||||
|
||||
Draw.color(midColor, a);
|
||||
if(drawCenter) Fill.circle(build.x, build.y, flameRad + si);
|
||||
|
||||
Draw.color(flameColor, a);
|
||||
if(drawCenter) Lines.circle(build.x, build.y, (flameRad + circleSpace + si) * build.warmup);
|
||||
if(drawCenter) Lines.circle(build.x, build.y, (flameRad + circleSpace + si) * build.warmup());
|
||||
|
||||
Lines.stroke(particleStroke * build.warmup);
|
||||
Lines.stroke(particleStroke * build.warmup());
|
||||
|
||||
float base = (Time.time / particleLife);
|
||||
rand.setSeed(build.id);
|
||||
@@ -45,7 +45,7 @@ public class DrawArcSmelter extends DrawBlock{
|
||||
float fin = (rand.random(1f) + base) % 1f, fout = 1f - fin;
|
||||
float angle = rand.random(360f);
|
||||
float len = particleRad * Interp.pow2Out.apply(fin);
|
||||
Lines.lineAngle(build.x + Angles.trnsx(angle, len), build.y + Angles.trnsy(angle, len), angle, particleLen * fout * build.warmup);
|
||||
Lines.lineAngle(build.x + Angles.trnsx(angle, len), build.y + Angles.trnsy(angle, len), angle, particleLen * fout * build.warmup());
|
||||
}
|
||||
|
||||
Draw.blend();
|
||||
|
||||
@@ -4,6 +4,7 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
@@ -13,19 +14,27 @@ import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
public class DrawBlock{
|
||||
protected static final Rand rand = new Rand();
|
||||
|
||||
/** Draws the block. */
|
||||
public void draw(GenericCrafterBuild build){
|
||||
/** @deprecated no longer called! not specific to generic crafters! */
|
||||
@Deprecated
|
||||
public void draw(GenericCrafterBuild build){}
|
||||
|
||||
/** @deprecated no longer called! not specific to generic crafters! */
|
||||
@Deprecated
|
||||
public void drawLight(GenericCrafterBuild build){}
|
||||
|
||||
/** Draws the block itself. */
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y, build.drawrot());
|
||||
}
|
||||
|
||||
/** Draws any extra light for the block. */
|
||||
public void drawLight(GenericCrafterBuild build){
|
||||
public void drawLights(Building build){
|
||||
|
||||
}
|
||||
|
||||
/** Draws the planned version of this block. */
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
crafter.drawPlanBase(plan, list);
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
block.drawDefaultRequestRegion(plan, list);
|
||||
}
|
||||
|
||||
/** Load any relevant texture regions. */
|
||||
@@ -37,4 +46,9 @@ public class DrawBlock{
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{block.region};
|
||||
}
|
||||
|
||||
public GenericCrafter expectCrafter(Block block){
|
||||
if(!(block instanceof GenericCrafter crafter)) throw new ClassCastException("This drawer requires the block to be a GenericCrafter. Use a different drawer.");
|
||||
return crafter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawBubbles extends DrawBlock{
|
||||
public Color color = Color.valueOf("7457ce");
|
||||
@@ -22,14 +22,14 @@ public class DrawBubbles extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
if(build.warmup <= 0.001f) return;
|
||||
public void drawBase(Building build){
|
||||
if(build.warmup() <= 0.001f) return;
|
||||
|
||||
Draw.color(color);
|
||||
Draw.alpha(build.warmup);
|
||||
Draw.alpha(build.warmup());
|
||||
|
||||
rand.setSeed(build.id);
|
||||
for(int i = 0; i < amount; i++){
|
||||
@@ -37,7 +37,7 @@ public class DrawBubbles extends DrawBlock{
|
||||
float life = 1f - ((Time.time / timeScl + rand.random(recurrence)) % recurrence);
|
||||
|
||||
if(life > 0){
|
||||
Lines.stroke(build.warmup * (life + strokeMin));
|
||||
Lines.stroke(build.warmup() * (life + strokeMin));
|
||||
Lines.poly(build.x + x, build.y + y, sides, (1f - life) * radius);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawCells extends DrawBlock{
|
||||
public TextureRegion bottom, middle;
|
||||
@@ -16,13 +16,13 @@ public class DrawCells extends DrawBlock{
|
||||
public float range = 4f, recurrence = 6f, radius = 3f, lifetime = 60f;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
|
||||
Drawf.liquid(middle, build.x, build.y, build.warmup, color);
|
||||
Drawf.liquid(middle, build.x, build.y, build.warmup(), color);
|
||||
|
||||
if(build.warmup > 0.001f){
|
||||
if(build.warmup() > 0.001f){
|
||||
rand.setSeed(build.id);
|
||||
for(int i = 0; i < particles; i++){
|
||||
float offset = rand.nextFloat() * 999999f;
|
||||
@@ -33,7 +33,7 @@ public class DrawCells extends DrawBlock{
|
||||
|
||||
if(fin > 0){
|
||||
Draw.color(particleColorFrom, particleColorTo, ca);
|
||||
Draw.alpha(build.warmup);
|
||||
Draw.alpha(build.warmup());
|
||||
|
||||
Fill.circle(build.x + x, build.y + y, fslope * radius);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.Interp.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawCrucible extends DrawBlock{
|
||||
public TextureRegion top, bottom;
|
||||
@@ -20,21 +20,21 @@ public class DrawCrucible extends DrawBlock{
|
||||
public Interp particleInterp = new PowIn(1.5f);
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
|
||||
if(build.warmup > 0f && flameColor.a > 0.001f){
|
||||
Lines.stroke(circleStroke * build.warmup);
|
||||
if(build.warmup() > 0f && flameColor.a > 0.001f){
|
||||
Lines.stroke(circleStroke * build.warmup());
|
||||
|
||||
float si = Mathf.absin(flameRadiusScl, flameRadiusMag);
|
||||
float a = alpha * build.warmup;
|
||||
float a = alpha * build.warmup();
|
||||
Draw.blend(Blending.additive);
|
||||
|
||||
Draw.color(midColor, a);
|
||||
Fill.circle(build.x, build.y, flameRad + si);
|
||||
|
||||
Draw.color(flameColor, a);
|
||||
Lines.circle(build.x, build.y, (flameRad + circleSpace + si) * build.warmup);
|
||||
Lines.circle(build.x, build.y, (flameRad + circleSpace + si) * build.warmup());
|
||||
|
||||
float base = (Time.time / particleLife);
|
||||
rand.setSeed(build.id);
|
||||
@@ -46,7 +46,7 @@ public class DrawCrucible extends DrawBlock{
|
||||
Fill.circle(
|
||||
build.x + Angles.trnsx(angle, len),
|
||||
build.y + Angles.trnsy(angle, len),
|
||||
particleSize * fin * build.warmup
|
||||
particleSize * fin * build.warmup()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawCultivator extends DrawBlock{
|
||||
public Color plantColor = Color.valueOf("5541b1");
|
||||
@@ -21,12 +21,12 @@ public class DrawCultivator extends DrawBlock{
|
||||
public TextureRegion top;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
|
||||
Drawf.liquid(middle, build.x, build.y, build.warmup, plantColor);
|
||||
Drawf.liquid(middle, build.x, build.y, build.warmup(), plantColor);
|
||||
|
||||
Draw.color(bottomColor, plantColorLight, build.warmup);
|
||||
Draw.color(bottomColor, plantColorLight, build.warmup());
|
||||
|
||||
rand.setSeed(build.pos());
|
||||
for(int i = 0; i < bubbles; i++){
|
||||
@@ -34,7 +34,7 @@ public class DrawCultivator extends DrawBlock{
|
||||
float life = 1f - ((Time.time / timeScl + rand.random(recurrence)) % recurrence);
|
||||
|
||||
if(life > 0){
|
||||
Lines.stroke(build.warmup * (life + strokeMin));
|
||||
Lines.stroke(build.warmup() * (life + strokeMin));
|
||||
Lines.poly(build.x + x, build.y + y, sides, (1f - life) * radius);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package mindustry.world.draw;
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawGlow extends DrawBlock{
|
||||
public String suffix = "-top";
|
||||
@@ -12,9 +12,9 @@ public class DrawGlow extends DrawBlock{
|
||||
public TextureRegion top;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
Draw.alpha(Mathf.absin(build.totalProgress, glowScale, glowAmount) * build.warmup);
|
||||
Draw.alpha(Mathf.absin(build.totalProgress(), glowScale, glowAmount) * build.warmup());
|
||||
Draw.rect(top, build.x, build.y);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@@ -6,10 +6,9 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawGlowRegion extends DrawBlock{
|
||||
@@ -21,14 +20,14 @@ public class DrawGlowRegion extends DrawBlock{
|
||||
public TextureRegion top;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
if(build.warmup <= 0.001f) return;
|
||||
public void drawBase(Building build){
|
||||
if(build.warmup() <= 0.001f) return;
|
||||
|
||||
float z = Draw.z();
|
||||
Draw.z(layer);
|
||||
Draw.blend(blending);
|
||||
Draw.color(color);
|
||||
Draw.alpha((Mathf.absin(build.totalProgress, glowScale, alpha) * glowIntensity + 1f - glowIntensity) * build.warmup * alpha);
|
||||
Draw.alpha((Mathf.absin(build.totalProgress(), glowScale, alpha) * glowIntensity + 1f - glowIntensity) * build.warmup() * alpha);
|
||||
Draw.rect(top, build.x, build.y);
|
||||
Draw.reset();
|
||||
Draw.blend();
|
||||
@@ -41,5 +40,5 @@ public class DrawGlowRegion extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
import mindustry.world.blocks.production.HeatCrafter.*;
|
||||
|
||||
/** Not standalone. */
|
||||
@@ -17,7 +17,7 @@ public class DrawHeatInput extends DrawBlock{
|
||||
public TextureRegion heat;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
|
||||
Draw.z(Layer.blockAdditive);
|
||||
if(build instanceof HeatCrafterBuild hc){
|
||||
|
||||
@@ -6,11 +6,10 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.heat.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawHeatOutput extends DrawBlock{
|
||||
public TextureRegion heat, glow, top1, top2;
|
||||
@@ -20,7 +19,7 @@ public class DrawHeatOutput extends DrawBlock{
|
||||
public boolean drawRegion = false;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(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());
|
||||
@@ -38,7 +37,7 @@ public class DrawHeatOutput extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
import mindustry.world.consumers.*;
|
||||
|
||||
public class DrawLiquid extends DrawBlock{
|
||||
@@ -21,7 +21,7 @@ public class DrawLiquid extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
GenericCrafter type = (GenericCrafter)build.block;
|
||||
|
||||
@@ -45,6 +45,8 @@ public class DrawLiquid extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
expectCrafter(block);
|
||||
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
liquid = Core.atlas.find(block.name + "-liquid");
|
||||
inLiquid = Core.atlas.find(block.name + "-input-liquid");
|
||||
|
||||
@@ -4,16 +4,16 @@ import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** This must be used in conjunction with another DrawBlock; it only draws outputs. */
|
||||
public class DrawLiquidOutputs extends DrawBlock{
|
||||
public TextureRegion[][] liquidOutputRegions;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
GenericCrafter crafter = (GenericCrafter)build.block;
|
||||
if(crafter.outputLiquids == null) return;
|
||||
|
||||
@@ -27,7 +27,8 @@ public class DrawLiquidOutputs extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
GenericCrafter crafter = (GenericCrafter)block;
|
||||
if(crafter.outputLiquids == null) return;
|
||||
|
||||
for(int i = 0; i < crafter.outputLiquids.length; i++){
|
||||
@@ -41,7 +42,7 @@ public class DrawLiquidOutputs extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
GenericCrafter crafter = (GenericCrafter)block;
|
||||
var crafter = expectCrafter(block);
|
||||
|
||||
if(crafter.outputLiquids == null) return;
|
||||
|
||||
|
||||
@@ -4,11 +4,10 @@ import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawLiquidRegion extends DrawBlock{
|
||||
@@ -24,10 +23,10 @@ public class DrawLiquidRegion extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
|
||||
Liquid drawn = drawLiquid != null ? drawLiquid : build.liquids.current();
|
||||
Drawf.liquid(liquid, build.x, build.y,
|
||||
|
||||
@@ -2,11 +2,11 @@ package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
import mindustry.world.consumers.*;
|
||||
|
||||
public class DrawMixer extends DrawBlock{
|
||||
@@ -21,7 +21,7 @@ public class DrawMixer extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
GenericCrafter crafter = (GenericCrafter)build.block;
|
||||
float rotation = build.block.rotate ? build.rotdeg() : 0;
|
||||
Draw.rect(bottom, build.x, build.y, rotation);
|
||||
@@ -45,6 +45,8 @@ public class DrawMixer extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
expectCrafter(block);
|
||||
|
||||
inLiquid = Core.atlas.find(block.name + "-input-liquid");
|
||||
liquid = Core.atlas.find(block.name + "-liquid");
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
|
||||
@@ -3,9 +3,8 @@ package mindustry.world.draw;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** combined several DrawBlocks into one */
|
||||
public class DrawMulti extends DrawBlock{
|
||||
@@ -21,23 +20,23 @@ public class DrawMulti extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
for(var draw : drawers){
|
||||
draw.draw(build);
|
||||
draw.drawBase(build);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
for(var draw : drawers){
|
||||
draw.drawPlan(crafter, plan, list);
|
||||
draw.drawPlan(block, plan, list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(GenericCrafterBuild build){
|
||||
public void drawLights(Building build){
|
||||
for(var draw : drawers){
|
||||
draw.drawLight(build);
|
||||
draw.drawLights(build);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawRegion extends DrawBlock{
|
||||
@@ -23,7 +22,7 @@ public class DrawRegion extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
float z = Draw.z();
|
||||
if(layer > 0) Draw.z(layer);
|
||||
Draw.rect(region, build.x, build.y);
|
||||
@@ -31,7 +30,7 @@ public class DrawRegion extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawRotator extends DrawBlock{
|
||||
public TextureRegion rotator, top;
|
||||
@@ -12,12 +12,12 @@ public class DrawRotator extends DrawBlock{
|
||||
public float spinSpeed = 2f;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
if(drawSpinSprite){
|
||||
Drawf.spinSprite(rotator, build.x, build.y, build.totalProgress * spinSpeed);
|
||||
Drawf.spinSprite(rotator, build.x, build.y, build.totalProgress() * spinSpeed);
|
||||
}else{
|
||||
Draw.rect(rotator, build.x, build.y, build.totalProgress * spinSpeed);
|
||||
Draw.rect(rotator, build.x, build.y, build.totalProgress() * spinSpeed);
|
||||
}
|
||||
if(top.found()) Draw.rect(top, build.x, build.y);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawSmelter extends DrawBlock{
|
||||
public Color flameColor = Color.valueOf("ffc999");
|
||||
@@ -29,24 +29,24 @@ public class DrawSmelter extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y, build.block.rotate ? build.rotdeg() : 0);
|
||||
|
||||
if(build.warmup > 0f && flameColor.a > 0.001f){
|
||||
if(build.warmup() > 0f && flameColor.a > 0.001f){
|
||||
float g = 0.3f;
|
||||
float r = 0.06f;
|
||||
float cr = Mathf.random(0.1f);
|
||||
|
||||
Draw.z(Layer.block + 0.01f);
|
||||
|
||||
Draw.alpha(build.warmup);
|
||||
Draw.alpha(build.warmup());
|
||||
Draw.rect(top, build.x, build.y);
|
||||
|
||||
Draw.alpha(((1f - g) + Mathf.absin(Time.time, 8f, g) + Mathf.random(r) - r) * build.warmup);
|
||||
Draw.alpha(((1f - g) + Mathf.absin(Time.time, 8f, g) + Mathf.random(r) - r) * build.warmup());
|
||||
|
||||
Draw.tint(flameColor);
|
||||
Fill.circle(build.x, build.y, flameRadius + Mathf.absin(Time.time, flameRadiusScl, flameRadiusMag) + cr);
|
||||
Draw.color(1f, 1f, 1f, build.warmup);
|
||||
Draw.color(1f, 1f, 1f, build.warmup());
|
||||
Fill.circle(build.x, build.y, flameRadiusIn + Mathf.absin(Time.time, flameRadiusScl, flameRadiusInMag) + cr);
|
||||
|
||||
Draw.color();
|
||||
@@ -54,7 +54,7 @@ public class DrawSmelter extends DrawBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(GenericCrafterBuild build){
|
||||
Drawf.light(build.team, build.x, build.y, (lightRadius + Mathf.absin(lightSinScl, lightSinMag)) * build.warmup * build.block.size, flameColor, lightAlpha);
|
||||
public void drawLights(Building build){
|
||||
Drawf.light(build.team, build.x, build.y, (lightRadius + Mathf.absin(lightSinScl, lightSinMag)) * build.warmup() * build.block.size, flameColor, lightAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
84
core/src/mindustry/world/draw/DrawTurret.java
Normal file
84
core/src/mindustry/world/draw/DrawTurret.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.defense.turrets.Turret.*;
|
||||
|
||||
/** Extend to implement custom drawing behavior for a turret. */
|
||||
public class DrawTurret extends DrawBlock{
|
||||
protected static final Rand rand = new Rand();
|
||||
|
||||
public String basePrefix = "";
|
||||
public TextureRegion base, liquid, top, heat;
|
||||
|
||||
public DrawTurret(String basePrefix){
|
||||
this.basePrefix = basePrefix;
|
||||
}
|
||||
|
||||
public DrawTurret(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBase(Building build){
|
||||
Turret turret = (Turret)build.block;
|
||||
TurretBuild tb = (TurretBuild)build;
|
||||
|
||||
Draw.rect(base, build.x, build.y);
|
||||
Draw.color();
|
||||
|
||||
Draw.z(Layer.turret);
|
||||
|
||||
Drawf.shadow(build.block.region, build.x + tb.recoilOffset.x - turret.elevation, build.y + tb.recoilOffset.y - turret.elevation, tb.drawrot());
|
||||
|
||||
drawTurret(turret, tb);
|
||||
drawHeat(turret, tb);
|
||||
}
|
||||
|
||||
public void drawTurret(Turret block, TurretBuild build){
|
||||
Draw.rect(block.region, build.x + build.recoilOffset.x, build.y + build.recoilOffset.y, build.drawrot());
|
||||
|
||||
if(liquid.found()){
|
||||
Drawf.liquid(liquid, build.x + build.recoilOffset.x, build.y + build.recoilOffset.y, build.liquids.currentAmount() / block.liquidCapacity, build.liquids.current().color, build.drawrot());
|
||||
}
|
||||
|
||||
if(top.found()){
|
||||
Draw.rect(top, build.x + build.recoilOffset.x, build.y + build.recoilOffset.y, build.drawrot());
|
||||
}
|
||||
}
|
||||
|
||||
public void drawHeat(Turret block, TurretBuild build){
|
||||
if(build.heat <= 0.00001f || !heat.found()) return;
|
||||
|
||||
Draw.color(block.heatColor, build.heat);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.rect(heat, build.x + build.recoilOffset.x, build.y + build.recoilOffset.y, build.drawrot());
|
||||
Draw.blend();
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
/** Load any relevant texture regions. */
|
||||
@Override
|
||||
public void load(Block block){
|
||||
if(!(block instanceof Turret)) throw new ClassCastException("This drawer can only be used on turrets.");
|
||||
|
||||
liquid = Core.atlas.find(block.name + "-liquid");
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
heat = Core.atlas.find(block.name + "-heat");
|
||||
base = Core.atlas.find(block.name + "-base");
|
||||
|
||||
//TODO test this for mods, e.g. exotic
|
||||
if(!base.found() && block.minfo.mod != null) base = Core.atlas.find(block.minfo.mod.name + "-block-" + block.size);
|
||||
if(!base.found()) base = Core.atlas.find(basePrefix + "block-" + block.size);
|
||||
}
|
||||
|
||||
/** @return the generated icons to be used for this block. */
|
||||
public TextureRegion[] icons(Turret block){
|
||||
return top.found() ? new TextureRegion[]{base, block.region, top} : new TextureRegion[]{base, block.region};
|
||||
}
|
||||
}
|
||||
@@ -4,23 +4,23 @@ import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawWeave extends DrawBlock{
|
||||
public TextureRegion weave, bottom;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
Draw.rect(weave, build.x, build.y, build.totalProgress);
|
||||
Draw.rect(weave, build.x, build.y, build.totalProgress());
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(build.warmup);
|
||||
Draw.alpha(build.warmup());
|
||||
|
||||
Lines.lineAngleCenter(
|
||||
build.x + Mathf.sin(build.totalProgress, 6f, Vars.tilesize / 3f * build.block.size),
|
||||
build.x + Mathf.sin(build.totalProgress(), 6f, Vars.tilesize / 3f * build.block.size),
|
||||
build.y,
|
||||
90,
|
||||
build.block.size * Vars.tilesize / 2f);
|
||||
|
||||
Reference in New Issue
Block a user