Making DrawBlock more generic
This commit is contained in:
@@ -986,7 +986,6 @@ public class Blocks implements ContentList{
|
||||
liquidOutputDirections = new int[]{1, 3};
|
||||
}};
|
||||
|
||||
//TODO sprite
|
||||
oxidationChamber = new HeatProducer("oxidation-chamber"){{
|
||||
requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30));
|
||||
size = 3;
|
||||
@@ -999,20 +998,19 @@ public class Blocks implements ContentList{
|
||||
|
||||
rotateDraw = false;
|
||||
|
||||
//TODO rotor?
|
||||
//TODO vent
|
||||
//TODO vent?
|
||||
iconOverride = new String[]{"-bottom", "", "-top1", "-glass"};
|
||||
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidRegion(), new DrawBlock(), new DrawHeatOutput(), new DrawRegion("-glass"));
|
||||
|
||||
craftTime = 60f * 3f;
|
||||
liquidCapacity = 30f;
|
||||
heatOutput = 8f;
|
||||
heatOutput = 5f;
|
||||
}};
|
||||
|
||||
//TODO check sprite correctness
|
||||
heatReactor = new HeatProducer("heat-reactor"){{
|
||||
//TODO quadvent
|
||||
//TODO quadvent?
|
||||
//TODO coolant?
|
||||
//TODO extra output, should have other uses
|
||||
requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30));
|
||||
size = 3;
|
||||
craftTime = 60f * 10f;
|
||||
@@ -1512,8 +1510,7 @@ public class Blocks implements ContentList{
|
||||
//TODO different name
|
||||
reinforcedPump = new Pump("reinforced-pump"){{
|
||||
requirements(Category.liquid, with(Items.beryllium, 70, Items.tungsten, 20, Items.silicon, 20));
|
||||
//TODO CUSTOM DRAW ANIMATION
|
||||
//TODO balance consumption
|
||||
//TODO CUSTOM DRAW ANIMATION - pistons - repurpose DrawBlock?
|
||||
consumes.liquid(Liquids.hydrogen, 1.5f / 60f);
|
||||
|
||||
pumpAmount = 0.4f;
|
||||
@@ -1726,7 +1723,7 @@ public class Blocks implements ContentList{
|
||||
spinSpeed = 0.6f;
|
||||
spinners = true;
|
||||
hasLiquids = true;
|
||||
liquidOutput = new LiquidStack(Liquids.water, 5f / 60f / 9f);
|
||||
liquidOutput = new LiquidStack(Liquids.water, 10f / 60f / 9f);
|
||||
liquidCapacity = 20f;
|
||||
}};
|
||||
|
||||
@@ -2446,11 +2443,11 @@ public class Blocks implements ContentList{
|
||||
}}
|
||||
);
|
||||
|
||||
draw = new DrawTurret("reinforced-");
|
||||
shootLength = 0f;
|
||||
outlineColor = Pal.darkOutline;
|
||||
size = 2;
|
||||
envEnabled |= Env.space;
|
||||
basePrefix = "reinforced";
|
||||
reloadTime = 40f;
|
||||
restitution = 0.03f;
|
||||
range = 180;
|
||||
|
||||
@@ -379,6 +379,20 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return power != null && (block.consumes.has(ConsumeType.power) && !block.consumes.getPower().buffered) ? power.status : 1f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the building's 'warmup', a smooth value from 0 to 1.
|
||||
* usually used for crafters and things that need to spin up before reaching full efficiency.
|
||||
* many blocks will just return 0.
|
||||
* */
|
||||
public float warmup(){
|
||||
return 0f;
|
||||
}
|
||||
|
||||
/** @return total time this block has been producing something; non-crafter blocks usually return Time.time. */
|
||||
public float totalProgress(){
|
||||
return Time.time;
|
||||
}
|
||||
|
||||
public BlockStatus status(){
|
||||
return cons.status();
|
||||
}
|
||||
|
||||
@@ -578,6 +578,11 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawDefaultRequestRegion(plan, list);
|
||||
}
|
||||
|
||||
/** this is a different method so subclasses can call it even after overriding the base */
|
||||
public void drawDefaultRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
TextureRegion reg = getRequestRegion(plan, list);
|
||||
Draw.rect(reg, plan.drawx(), plan.drawy(), !rotate || !rotateDraw ? 0 : plan.rotation * 90);
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import mindustry.core.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
@@ -18,10 +17,13 @@ import static mindustry.Vars.*;
|
||||
|
||||
public class LiquidTurret extends Turret{
|
||||
public ObjectMap<Liquid, BulletType> ammoTypes = new ObjectMap<>();
|
||||
public @Load("@-liquid") TextureRegion liquidRegion;
|
||||
public @Load("@-top") TextureRegion topRegion;
|
||||
public boolean extinguish = true;
|
||||
|
||||
/** @deprecated loaded in {@link #draw} instead, unused */
|
||||
public @Deprecated @Load("@-liquid") TextureRegion liquidRegion;
|
||||
/** @deprecated loaded in {@link #draw} instead, unused */
|
||||
public @Deprecated @Load("@-top") TextureRegion topRegion;
|
||||
|
||||
public LiquidTurret(String name){
|
||||
super(name);
|
||||
acceptCoolant = false;
|
||||
@@ -66,22 +68,7 @@ public class LiquidTurret extends Turret{
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(){
|
||||
if(topRegion.found()) return new TextureRegion[]{baseRegion, region, topRegion};
|
||||
return super.icons();
|
||||
}
|
||||
|
||||
public class LiquidTurretBuild extends TurretBuild{
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
if(liquidRegion.found()){
|
||||
Drawf.liquid(liquidRegion, x + recoilOffset.x, y + recoilOffset.y, liquids.currentAmount() / liquidCapacity, liquids.current().color, rotation - 90);
|
||||
}
|
||||
if(topRegion.found()) Draw.rect(topRegion, x + recoilOffset.x, y + recoilOffset.y, rotation - 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldActiveSound(){
|
||||
|
||||
@@ -24,7 +24,7 @@ import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.drawturret.*;
|
||||
import mindustry.world.draw.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@@ -79,12 +79,14 @@ public class Turret extends ReloadTurret{
|
||||
|
||||
public Sortf unitSort = UnitSorts.closest;
|
||||
|
||||
public @Nullable String basePrefix;
|
||||
public @Load(value = "@-base", fallback = "block-@size") TextureRegion baseRegion;
|
||||
public @Load("@-heat") TextureRegion heatRegion;
|
||||
/** @deprecated loaded in {@link #draw} instead, unused */
|
||||
public @Deprecated @Load(value = "@-base", fallback = "block-@size") TextureRegion baseRegion;
|
||||
/** @deprecated loaded in {@link #draw} instead, unused */
|
||||
public @Deprecated @Load("@-heat") TextureRegion heatRegion;
|
||||
|
||||
public float elevation = -1f;
|
||||
|
||||
public DrawTurret draw = new DrawTurret();
|
||||
public DrawBlock draw = new DrawTurret();
|
||||
|
||||
/** @deprecated use bulletOffset; this will always be zero. **/
|
||||
@Deprecated
|
||||
@@ -140,10 +142,6 @@ public class Turret extends ReloadTurret{
|
||||
super.load();
|
||||
|
||||
draw.load(this);
|
||||
|
||||
if(basePrefix != null){
|
||||
baseRegion = Core.atlas.find(basePrefix + "-block-" + size);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,6 +172,11 @@ public class Turret extends ReloadTurret{
|
||||
public BlockUnitc unit = (BlockUnitc)UnitTypes.block.create(team);
|
||||
public boolean wasShooting, charging;
|
||||
|
||||
@Override
|
||||
public float drawrot(){
|
||||
return rotation - 90;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canControl(){
|
||||
return playerControllable;
|
||||
@@ -258,15 +261,7 @@ public class Turret extends ReloadTurret{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(baseRegion, x, y);
|
||||
Draw.color();
|
||||
|
||||
Draw.z(Layer.turret);
|
||||
|
||||
Drawf.shadow(region, x + recoilOffset.x - elevation, y + recoilOffset.y - elevation, rotation - 90);
|
||||
|
||||
draw.draw(Turret.this, this);
|
||||
draw.drawHeat(Turret.this, this);
|
||||
draw.drawBase(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.draw.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class HeatProducer extends GenericCrafter{
|
||||
public float heatOutput = 10f;
|
||||
@@ -26,7 +27,8 @@ public class HeatProducer extends GenericCrafter{
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
//TODO heat prod stats
|
||||
|
||||
stats.add(Stat.output, heatOutput, StatUnit.heatUnits);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -112,7 +112,10 @@ public class BeamNode extends PowerBlock{
|
||||
float w = laserWidth + Mathf.absin(pulseScl, pulseMag);
|
||||
|
||||
for(int i = 0; i < 4; i ++){
|
||||
if(dests[i] != null && (!(links[i].block instanceof BeamNode) || (links[i].tileX() != tileX() && links[i].tileY() != tileY()) || links[i].id > id)){
|
||||
if(dests[i] != null && (!(links[i].block instanceof BeamNode node) ||
|
||||
(links[i].tileX() != tileX() && links[i].tileY() != tileY()) ||
|
||||
(links[i].id > id && range >= node.range) || range > node.range)){
|
||||
|
||||
int dst = Math.max(Math.abs(dests[i].x - tile.x), Math.abs(dests[i].y - tile.y));
|
||||
//don't draw lasers for adjacent blocks
|
||||
if(dst > 1 + size/2){
|
||||
|
||||
@@ -114,7 +114,7 @@ public class BurstDrill extends Drill{
|
||||
float a = Mathf.clamp(fract * arrows - arrowFract);
|
||||
Tmp.v1.trns(i * 90 + 45, j * arrowSpacing);
|
||||
|
||||
//TODO maybe just use arrow alpha and that drawn on the base?
|
||||
//TODO maybe just use arrow alpha and draw gray on the base?
|
||||
Draw.z(Layer.block);
|
||||
Draw.color(baseArrowColor, arrowColor, a);
|
||||
Draw.rect(arrowRegion, x + Tmp.v1.x, y + Tmp.v1.y, i * 90);
|
||||
|
||||
@@ -145,13 +145,13 @@ public class GenericCrafter extends Block{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
drawer.draw(this);
|
||||
drawer.drawBase(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(){
|
||||
super.drawLight();
|
||||
drawer.drawLight(this);
|
||||
drawer.drawLights(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,6 +200,16 @@ public class GenericCrafter extends Block{
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float warmup(){
|
||||
return warmup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float totalProgress(){
|
||||
return totalProgress;
|
||||
}
|
||||
|
||||
public void craft(){
|
||||
consume();
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.heat.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class HeatCrafter extends GenericCrafter{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
//TODO heat stats
|
||||
stats.add(Stat.input, heatRequirement, StatUnit.heatUnits);
|
||||
}
|
||||
|
||||
public class HeatCrafterBuild extends GenericCrafterBuild{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package mindustry.world.drawturret;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
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{
|
||||
protected static final Rand rand = new Rand();
|
||||
|
||||
/** Draws the block. */
|
||||
public void draw(Turret block, TurretBuild build){
|
||||
Draw.rect(block.region, build.x + build.recoilOffset.x, build.y + build.recoilOffset.y, build.rotation - 90);
|
||||
}
|
||||
|
||||
public void drawHeat(Turret block, TurretBuild build){
|
||||
if(build.heat <= 0.00001f || !block.heatRegion.found()) return;
|
||||
|
||||
Draw.color(block.heatColor, build.heat);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.rect(block.heatRegion, build.x + build.recoilOffset.x, build.y + build.recoilOffset.y, build.rotation - 90);
|
||||
Draw.blend();
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
/** Load any relevant texture regions. */
|
||||
public void load(Turret block){
|
||||
|
||||
}
|
||||
|
||||
/** @return the generated icons to be used for this block. */
|
||||
public TextureRegion[] icons(Turret block){
|
||||
return new TextureRegion[]{block.baseRegion, block.region};
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public enum StatUnit{
|
||||
itemsSecond,
|
||||
liquidUnits,
|
||||
powerUnits,
|
||||
heatUnits,
|
||||
degrees,
|
||||
seconds,
|
||||
minutes,
|
||||
|
||||
Reference in New Issue
Block a user