Making DrawBlock more generic
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user