Block Drawer cleanup
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 144 B |
Before Width: | Height: | Size: 304 B |
BIN
core/assets-raw/sprites/blocks/production/cryofluid-mixer.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 382 B |
@ -552,3 +552,4 @@
|
||||
63151=mech-reconstructor|block-mech-reconstructor-ui
|
||||
63150=ship-reconstructor|block-ship-reconstructor-ui
|
||||
63149=radar|block-radar-ui
|
||||
63148=turret-unit-build-tower|unit-turret-unit-build-tower-ui
|
||||
|
@ -890,7 +890,7 @@ public class Blocks{
|
||||
size = 2;
|
||||
hasPower = true;
|
||||
hasLiquids = false;
|
||||
drawer = new DrawSmelter(Color.valueOf("ffef99"));
|
||||
drawer = new DrawMulti(new DrawBlock(), 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 DrawSmelter(Color.valueOf("ffef99"));
|
||||
drawer = new DrawMulti(new DrawBlock(), new DrawFlame(Color.valueOf("ffef99")));
|
||||
ambientSound = Sounds.smelter;
|
||||
ambientSoundVolume = 0.07f;
|
||||
|
||||
@ -927,7 +927,8 @@ public class Blocks{
|
||||
envEnabled |= Env.space | Env.underwater;
|
||||
envDisabled = Env.none;
|
||||
itemCapacity = 30;
|
||||
drawer = new DrawArcSmelter();
|
||||
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawArcSmelt(), new DrawBlock());
|
||||
drawer.iconOverride = new String[]{"-bottom", ""};
|
||||
fogRadius = 3;
|
||||
researchCost = with(Items.beryllium, 150, Items.graphite, 50);
|
||||
|
||||
@ -942,7 +943,7 @@ public class Blocks{
|
||||
craftTime = 30f;
|
||||
size = 2;
|
||||
hasPower = hasItems = true;
|
||||
drawer = new DrawSmelter(Color.valueOf("ffc099"));
|
||||
drawer = new DrawMulti(new DrawBlock(), new DrawFlame(Color.valueOf("ffc099")));
|
||||
ambientSound = Sounds.smelter;
|
||||
ambientSoundVolume = 0.07f;
|
||||
|
||||
@ -961,7 +962,7 @@ public class Blocks{
|
||||
hasPower = hasLiquids = true;
|
||||
craftEffect = Fx.formsmoke;
|
||||
updateEffect = Fx.plasticburn;
|
||||
drawer = new DrawGlow();
|
||||
drawer = new DrawMulti(new DrawBlock(), new DrawFade());
|
||||
|
||||
consumeLiquid(Liquids.oil, 0.25f);
|
||||
consumePower(3f);
|
||||
@ -975,7 +976,8 @@ public class Blocks{
|
||||
craftTime = 120f;
|
||||
size = 2;
|
||||
hasPower = true;
|
||||
drawer = new DrawWeave();
|
||||
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawWeave(), new DrawBlock());
|
||||
drawer.iconOverride = new String[]{"-bottom", "-weave", ""};
|
||||
envEnabled |= Env.space;
|
||||
|
||||
ambientSound = Sounds.techloop;
|
||||
@ -994,7 +996,7 @@ public class Blocks{
|
||||
size = 3;
|
||||
hasPower = true;
|
||||
itemCapacity = 20;
|
||||
drawer = new DrawSmelter();
|
||||
drawer = new DrawMulti(new DrawBlock(), new DrawFlame());
|
||||
|
||||
consumePower(4f);
|
||||
consumeItems(with(Items.copper, 3, Items.lead, 4, Items.titanium, 2, Items.silicon, 3));
|
||||
@ -1011,7 +1013,8 @@ public class Blocks{
|
||||
solid = true;
|
||||
outputsLiquid = true;
|
||||
envEnabled = Env.any;
|
||||
drawer = new DrawMixer(true);
|
||||
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidTile(Liquids.cryofluid), new DrawBlock());
|
||||
drawer.iconOverride = new String[]{"-bottom", ""};
|
||||
liquidCapacity = 24f;
|
||||
|
||||
consumePower(1f);
|
||||
@ -1050,9 +1053,7 @@ public class Blocks{
|
||||
outputLiquid = new LiquidStack(Liquids.slag, 12f / 60f);
|
||||
craftTime = 1f;
|
||||
hasLiquids = hasPower = true;
|
||||
drawer = new DrawLiquid(){{
|
||||
liquidDrawn = Liquids.slag;
|
||||
}};
|
||||
drawer = new DrawMulti(new DrawBlock(), new DrawLiquidRegion());
|
||||
|
||||
consumePower(1f);
|
||||
consumeItem(Items.scrap, 1);
|
||||
@ -1101,7 +1102,14 @@ public class Blocks{
|
||||
hasLiquids = true;
|
||||
hasPower = true;
|
||||
craftEffect = Fx.none;
|
||||
drawer = new DrawAnimation();
|
||||
drawer = new DrawMulti(
|
||||
new DrawBlock(),
|
||||
new DrawFrames(),
|
||||
new DrawLiquidRegion(),
|
||||
new DrawRegion("-top")
|
||||
);
|
||||
|
||||
drawer.iconOverride = new String[]{"", "-top"};
|
||||
|
||||
consumeItem(Items.sporePod, 1);
|
||||
consumePower(0.7f);
|
||||
@ -1114,9 +1122,11 @@ public class Blocks{
|
||||
craftTime = 40f;
|
||||
updateEffect = Fx.pulverizeSmall;
|
||||
hasItems = hasPower = true;
|
||||
drawer = new DrawRotator(){{
|
||||
drawSpinSprite = true;
|
||||
}};
|
||||
drawer = new DrawMulti(new DrawBlock(), new DrawRegion("-rotator"){{
|
||||
spinSprite = true;
|
||||
rotateSpeed = 2f;
|
||||
}}, new DrawRegion("-top"));
|
||||
drawer.iconOverride = new String[]{"", "-rotator", "-top"};
|
||||
ambientSound = Sounds.grinding;
|
||||
ambientSoundVolume = 0.025f;
|
||||
|
||||
@ -2476,7 +2486,12 @@ public class Blocks{
|
||||
attribute = Attribute.spores;
|
||||
|
||||
legacyReadWarmup = true;
|
||||
drawer = new DrawCultivator();
|
||||
drawer = new DrawMulti(
|
||||
new DrawBlock(),
|
||||
new DrawCultivator(),
|
||||
new DrawRegion("-top")
|
||||
);
|
||||
drawer.iconOverride = new String[]{"", "-top"};
|
||||
maxBoost = 2f;
|
||||
|
||||
consumePower(80f / 60f);
|
||||
|
@ -5,6 +5,10 @@ import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
/**
|
||||
* Class for holding special internal bullets.
|
||||
* Formerly used to define preset bullets for turrets; as of v7, these have been inlined at the source.
|
||||
* */
|
||||
public class Bullets{
|
||||
public static BulletType
|
||||
|
||||
@ -12,6 +16,7 @@ public class Bullets{
|
||||
|
||||
public static void load(){
|
||||
|
||||
//not allowed in weapons - used only to prevent NullPointerExceptions
|
||||
placeholder = new BasicBulletType(2.5f, 9, "ohno"){{
|
||||
width = 7f;
|
||||
height = 9f;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mindustry.mod;
|
||||
|
||||
import arc.struct.*;
|
||||
import mindustry.world.draw.*;
|
||||
|
||||
/** Generated class. Maps simple class names to concrete classes. For use in JSON mods. */
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ClassMap{
|
||||
@ -394,8 +396,8 @@ public class ClassMap{
|
||||
classes.put("UnitFactory", mindustry.world.blocks.units.UnitFactory.class);
|
||||
classes.put("UnitFactoryBuild", mindustry.world.blocks.units.UnitFactory.UnitFactoryBuild.class);
|
||||
classes.put("UnitPlan", mindustry.world.blocks.units.UnitFactory.UnitPlan.class);
|
||||
classes.put("DrawAnimation", mindustry.world.draw.DrawAnimation.class);
|
||||
classes.put("DrawArcSmelter", mindustry.world.draw.DrawArcSmelter.class);
|
||||
classes.put("DrawAnimation", DrawFrames.class);
|
||||
classes.put("DrawArcSmelter", DrawArcSmelt.class);
|
||||
classes.put("DrawBlock", mindustry.world.draw.DrawBlock.class);
|
||||
classes.put("DrawBlurSpin", mindustry.world.draw.DrawBlurSpin.class);
|
||||
classes.put("DrawBubbles", mindustry.world.draw.DrawBubbles.class);
|
||||
@ -403,16 +405,14 @@ public class ClassMap{
|
||||
classes.put("DrawCircles", mindustry.world.draw.DrawCircles.class);
|
||||
classes.put("DrawCrucibleFlame", mindustry.world.draw.DrawCrucibleFlame.class);
|
||||
classes.put("DrawCultivator", mindustry.world.draw.DrawCultivator.class);
|
||||
classes.put("DrawGlow", mindustry.world.draw.DrawGlow.class);
|
||||
classes.put("DrawGlow", DrawFade.class);
|
||||
classes.put("DrawGlowRegion", mindustry.world.draw.DrawGlowRegion.class);
|
||||
classes.put("DrawHeatInput", mindustry.world.draw.DrawHeatInput.class);
|
||||
classes.put("DrawHeatOutput", mindustry.world.draw.DrawHeatOutput.class);
|
||||
classes.put("DrawHeatRegion", mindustry.world.draw.DrawHeatRegion.class);
|
||||
classes.put("DrawLiquid", mindustry.world.draw.DrawLiquid.class);
|
||||
classes.put("DrawLiquidOutputs", mindustry.world.draw.DrawLiquidOutputs.class);
|
||||
classes.put("DrawLiquidRegion", mindustry.world.draw.DrawLiquidRegion.class);
|
||||
classes.put("DrawLiquidTile", mindustry.world.draw.DrawLiquidTile.class);
|
||||
classes.put("DrawMixer", mindustry.world.draw.DrawMixer.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);
|
||||
@ -421,10 +421,9 @@ public class ClassMap{
|
||||
classes.put("DrawPulseShape", mindustry.world.draw.DrawPulseShape.class);
|
||||
classes.put("DrawPump", mindustry.world.draw.DrawPump.class);
|
||||
classes.put("DrawRegion", mindustry.world.draw.DrawRegion.class);
|
||||
classes.put("DrawRotator", mindustry.world.draw.DrawRotator.class);
|
||||
classes.put("DrawShape", mindustry.world.draw.DrawShape.class);
|
||||
classes.put("DrawSideRegion", mindustry.world.draw.DrawSideRegion.class);
|
||||
classes.put("DrawSmelter", mindustry.world.draw.DrawSmelter.class);
|
||||
classes.put("DrawSmelter", DrawFlame.class);
|
||||
classes.put("DrawSpikes", mindustry.world.draw.DrawSpikes.class);
|
||||
classes.put("DrawTurbines", mindustry.world.draw.DrawTurbines.class);
|
||||
classes.put("DrawTurret", mindustry.world.draw.DrawTurret.class);
|
||||
|
@ -131,6 +131,10 @@ public class ContentParser{
|
||||
//try to instantiate
|
||||
return make(resolve(data.asString()));
|
||||
}
|
||||
//array is shorthand for DrawMulti
|
||||
if(data.isArray()){
|
||||
return new DrawMulti(parser.readValue(DrawBlock[].class, data));
|
||||
}
|
||||
var bc = resolve(data.getString("type", ""), DrawBlock.class);
|
||||
data.remove("type");
|
||||
var result = make(bc);
|
||||
|
@ -423,13 +423,12 @@ public class UnitType extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for(int i = 0; i < weapons.size; i++){
|
||||
var wep = weapons.get(i);
|
||||
if(wep.bullet == Bullets.placeholder || wep.bullet == null){
|
||||
throw new RuntimeException("Unit: " + name + ": weapon #" + i + " ('" + wep.name + "') does not have a bullet defined. Make sure you have a bullet: (JSON) or `bullet = ` field in your unit definition.");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(pathCost == null){
|
||||
pathCost =
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mindustry.type.weapons;
|
||||
|
||||
import arc.math.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
@ -18,6 +19,7 @@ public class BuildWeapon extends Weapon{
|
||||
|
||||
{
|
||||
rotate = true;
|
||||
bullet = new BulletType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,11 +39,10 @@ public class ItemTurret extends Turret{
|
||||
/** Makes copies of all bullets and limits their range. */
|
||||
public void limitRange(float margin){
|
||||
for(var entry : ammoTypes.copy().entries()){
|
||||
var copy = entry.value.copy();
|
||||
float realRange = copy.rangeChange + range;
|
||||
var bullet = entry.value;
|
||||
float realRange = bullet.rangeChange + range;
|
||||
//doesn't handle drag
|
||||
copy.lifetime = (realRange + margin) / copy.speed;
|
||||
ammoTypes.put(entry.key, copy);
|
||||
bullet.lifetime = (realRange + margin) / bullet.speed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,7 @@ public class PayloadTurret extends Turret{
|
||||
/** Makes copies of all bullets and limits their range. */
|
||||
public void limitRange(float margin){
|
||||
for(var entry : ammoTypes.copy().entries()){
|
||||
var copy = entry.value.copy();
|
||||
copy.lifetime = (range + margin) / copy.speed;
|
||||
ammoTypes.put(entry.key, copy);
|
||||
entry.value.lifetime = (range + margin) / entry.value.speed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawAnimation extends DrawBlock{
|
||||
public int frameCount = 3;
|
||||
public float frameSpeed = 5f;
|
||||
public boolean sine = true;
|
||||
public TextureRegion[] frames;
|
||||
public TextureRegion liquid, top;
|
||||
|
||||
@Override
|
||||
public void draw(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)],
|
||||
build.x, build.y);
|
||||
|
||||
if(build.liquids != null){
|
||||
Drawf.liquid(liquid, build.x, build.y, build.liquids.currentAmount() / build.block.liquidCapacity, build.liquids.current().color);
|
||||
}
|
||||
if(top.found()){
|
||||
Draw.rect(top, build.x, build.y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
frames = new TextureRegion[frameCount];
|
||||
for(int i = 0; i < frameCount; i++){
|
||||
frames[i] = Core.atlas.find(block.name + "-frame" + i);
|
||||
}
|
||||
|
||||
liquid = Core.atlas.find(block.name + "-liquid");
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return top.found() ? new TextureRegion[]{block.region, top} : new TextureRegion[]{block.region};
|
||||
}
|
||||
}
|
@ -1,16 +1,12 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
//TODO make non-standalone?
|
||||
public class DrawArcSmelter extends DrawBlock{
|
||||
public TextureRegion bottom;
|
||||
public class DrawArcSmelt extends DrawPartial{
|
||||
public Color flameColor = Color.valueOf("f58349"), midColor = Color.valueOf("f2d585");
|
||||
public float flameRad = 1f, circleSpace = 2f, flameRadiusScl = 3f, flameRadiusMag = 0.3f, circleStroke = 1.5f;
|
||||
|
||||
@ -18,13 +14,10 @@ public class DrawArcSmelter extends DrawBlock{
|
||||
public int particles = 25;
|
||||
public float particleLife = 40f, particleRad = 7f, particleStroke = 1.1f, particleLen = 3f;
|
||||
public boolean drawCenter = true;
|
||||
public boolean drawBottom = true, drawRegion = true;
|
||||
public Blending blending = Blending.additive;
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
if(drawBottom) Draw.rect(bottom, build.x, build.y);
|
||||
|
||||
if(build.warmup() > 0f && flameColor.a > 0.001f){
|
||||
Lines.stroke(circleStroke * build.warmup());
|
||||
|
||||
@ -52,17 +45,5 @@ public class DrawArcSmelter extends DrawBlock{
|
||||
Draw.blend();
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
if(drawRegion) Draw.rect(build.block.region, build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
bottom = Core.atlas.find(block.name + "-bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{bottom, block.region};
|
||||
}
|
||||
}
|
@ -10,16 +10,13 @@ import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawCells extends DrawBlock{
|
||||
public TextureRegion bottom, middle;
|
||||
public TextureRegion middle;
|
||||
public Color color = Color.white.cpy(), particleColorFrom = Color.black.cpy(), particleColorTo = Color.black.cpy();
|
||||
public int particles = 12;
|
||||
public float range = 4f, recurrence = 6f, radius = 3f, lifetime = 60f;
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
|
||||
Drawf.liquid(middle, build.x, build.y, build.warmup(), color);
|
||||
|
||||
if(build.warmup() > 0.001f){
|
||||
@ -46,12 +43,6 @@ public class DrawCells extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
bottom = Core.atlas.find(block.name + "-bottom");
|
||||
middle = Core.atlas.find(block.name + "-middle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{bottom, block.region};
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawCultivator extends DrawBlock{
|
||||
public class DrawCultivator extends DrawPartial{
|
||||
public Color plantColor = Color.valueOf("5541b1");
|
||||
public Color plantColorLight = Color.valueOf("7457ce");
|
||||
public Color bottomColor = Color.valueOf("474747");
|
||||
@ -18,12 +18,9 @@ public class DrawCultivator extends DrawBlock{
|
||||
public float recurrence = 6f, radius = 3f;
|
||||
|
||||
public TextureRegion middle;
|
||||
public TextureRegion top;
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
|
||||
Drawf.liquid(middle, build.x, build.y, build.warmup(), plantColor);
|
||||
|
||||
Draw.color(bottomColor, plantColorLight, build.warmup());
|
||||
@ -40,17 +37,10 @@ public class DrawCultivator extends DrawBlock{
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(top, build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
middle = Core.atlas.find(block.name + "-middle");
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{block.region, top};
|
||||
}
|
||||
}
|
||||
|
25
core/src/mindustry/world/draw/DrawFade.java
Normal file
@ -0,0 +1,25 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawFade extends DrawBlock{
|
||||
public String suffix = "-top";
|
||||
public float alpha = 0.6f, scale = 3f;
|
||||
public TextureRegion region;
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.alpha(Mathf.absin(build.totalProgress(), scale, alpha) * build.warmup());
|
||||
Draw.rect(region, build.x, build.y);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
region = Core.atlas.find(block.name + suffix);
|
||||
}
|
||||
}
|
@ -9,16 +9,17 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawSmelter extends DrawBlock{
|
||||
//TODO remake/remove
|
||||
public class DrawFlame extends DrawPartial{
|
||||
public Color flameColor = Color.valueOf("ffc999");
|
||||
public TextureRegion top;
|
||||
public float lightRadius = 60f, lightAlpha = 0.65f, lightSinScl = 10f, lightSinMag = 5;
|
||||
public float flameRadius = 3f, flameRadiusIn = 1.9f, flameRadiusScl = 5f, flameRadiusMag = 2f, flameRadiusInMag = 1f;
|
||||
|
||||
public DrawSmelter(){
|
||||
public DrawFlame(){
|
||||
}
|
||||
|
||||
public DrawSmelter(Color flameColor){
|
||||
public DrawFlame(Color flameColor){
|
||||
this.flameColor = flameColor;
|
||||
}
|
||||
|
||||
@ -30,8 +31,6 @@ public class DrawSmelter extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void draw(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){
|
||||
float g = 0.3f;
|
||||
float r = 0.06f;
|
34
core/src/mindustry/world/draw/DrawFrames.java
Normal file
@ -0,0 +1,34 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawFrames extends DrawPartial{
|
||||
/** Number of frames to draw. */
|
||||
public int frames = 3;
|
||||
/** Ticks between frames. */
|
||||
public float interval = 5f;
|
||||
/** If true, frames wil alternate back and forth in a sine wave. */
|
||||
public boolean sine = true;
|
||||
public TextureRegion[] regions;
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.rect(
|
||||
sine ?
|
||||
regions[(int)Mathf.absin(build.totalProgress(), interval, frames - 0.001f)] :
|
||||
regions[(int)((build.totalProgress() / interval) % frames)],
|
||||
build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
regions = new TextureRegion[frames];
|
||||
for(int i = 0; i < frames; i++){
|
||||
regions[i] = Core.atlas.find(block.name + "-frame" + i);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawGlow extends DrawBlock{
|
||||
public String suffix = "-top";
|
||||
public float glowAmount = 0.9f, glowScale = 3f;
|
||||
public TextureRegion top;
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
Draw.alpha(Mathf.absin(build.totalProgress(), glowScale, glowAmount) * build.warmup());
|
||||
Draw.rect(top, build.x, build.y);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
top = Core.atlas.find(block.name + suffix);
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
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.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
|
||||
public class DrawLiquid extends DrawBlock{
|
||||
public @Nullable Liquid liquidDrawn;
|
||||
public TextureRegion inLiquid, liquid, top;
|
||||
public boolean useOutputSprite = false;
|
||||
|
||||
public DrawLiquid(){
|
||||
}
|
||||
|
||||
public DrawLiquid(boolean useOutputSprite){
|
||||
this.useOutputSprite = useOutputSprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
GenericCrafter type = (GenericCrafter)build.block;
|
||||
|
||||
if((inLiquid.found() || useOutputSprite) && liquidDrawn != null){
|
||||
Drawf.liquid(useOutputSprite ? liquid : inLiquid, build.x, build.y,
|
||||
build.liquids.get(liquidDrawn) / type.liquidCapacity,
|
||||
liquidDrawn.color
|
||||
);
|
||||
}
|
||||
|
||||
if(type.outputLiquid != null && build.liquids.get(type.outputLiquid.liquid) > 0){
|
||||
Drawf.liquid(liquid, build.x, build.y,
|
||||
build.liquids.get(type.outputLiquid.liquid) / type.liquidCapacity,
|
||||
type.outputLiquid.liquid.color
|
||||
);
|
||||
}
|
||||
|
||||
if(top.found()) Draw.rect(top, build.x, build.y);
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return top.found() ? new TextureRegion[]{block.region, top} : new TextureRegion[]{block.region};
|
||||
}
|
||||
}
|
@ -24,17 +24,18 @@ public class DrawLiquidRegion extends DrawPartial{
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
if(!build.block.hasLiquids) return;
|
||||
|
||||
Liquid drawn = drawLiquid != null ? drawLiquid : build.liquids.current();
|
||||
Drawf.liquid(liquid, build.x, build.y,
|
||||
build.liquids.get(drawn) / build.block.liquidCapacity,
|
||||
Tmp.c1.set(drawn.color).a(drawn.color.a * alpha)
|
||||
build.liquids.get(drawn) / build.block.liquidCapacity * alpha,
|
||||
drawn.color
|
||||
);
|
||||
}
|
||||
|
||||
@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.");
|
||||
}
|
||||
|
||||
liquid = Core.atlas.find(block.name + suffix);
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
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.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
|
||||
public class DrawMixer extends DrawBlock{
|
||||
public @Nullable Liquid liquidDrawn;
|
||||
public TextureRegion inLiquid, liquid, top, bottom;
|
||||
public boolean useOutputSprite;
|
||||
|
||||
public DrawMixer(){
|
||||
}
|
||||
|
||||
public DrawMixer(boolean useOutputSprite){
|
||||
this.useOutputSprite = useOutputSprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
GenericCrafter crafter = (GenericCrafter)build.block;
|
||||
float rotation = build.block.rotate ? build.rotdeg() : 0;
|
||||
Draw.rect(bottom, build.x, build.y, rotation);
|
||||
|
||||
if((inLiquid.found() || useOutputSprite) && liquidDrawn != null){
|
||||
Drawf.liquid(useOutputSprite ? liquid : inLiquid, build.x, build.y,
|
||||
build.liquids.get(liquidDrawn) / build.block.liquidCapacity,
|
||||
liquidDrawn.color
|
||||
);
|
||||
}
|
||||
|
||||
if(crafter.outputLiquid != null && build.liquids.get(crafter.outputLiquid.liquid) > 0.001f){
|
||||
var liq = crafter.outputLiquid.liquid;
|
||||
|
||||
Drawf.liquid(liquid, build.x, build.y, build.liquids.get(liq) / crafter.liquidCapacity, liq.color);
|
||||
}
|
||||
|
||||
Draw.rect(top, build.x, build.y, rotation);
|
||||
}
|
||||
|
||||
@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");
|
||||
bottom = Core.atlas.find(block.name + "-bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{bottom, top};
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawRotator extends DrawBlock{
|
||||
public TextureRegion rotator, top;
|
||||
public boolean drawSpinSprite = false;
|
||||
public float spinSpeed = 2f;
|
||||
|
||||
public DrawRotator(boolean drawSpinSprite, float spinSpeed){
|
||||
this.drawSpinSprite = drawSpinSprite;
|
||||
this.spinSpeed = spinSpeed;
|
||||
}
|
||||
|
||||
public DrawRotator(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
if(drawSpinSprite){
|
||||
Drawf.spinSprite(rotator, build.x, build.y, build.totalProgress() * spinSpeed);
|
||||
}else{
|
||||
Draw.rect(rotator, build.x, build.y, build.totalProgress() * spinSpeed);
|
||||
}
|
||||
if(top.found()) Draw.rect(top, build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
rotator = Core.atlas.find(block.name + "-rotator");
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return top.found() ? new TextureRegion[]{block.region, rotator, top} : new TextureRegion[]{block.region, rotator};
|
||||
}
|
||||
}
|
@ -7,16 +7,11 @@ import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawTurbines extends DrawBlock{
|
||||
public class DrawTurbines extends DrawPartial{
|
||||
public TextureRegion[] turbines = new TextureRegion[2];
|
||||
public TextureRegion cap;
|
||||
public float turbineSpeed = 2f;
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
float totalTime = build.totalProgress();
|
||||
|
@ -8,12 +8,11 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawWeave extends DrawBlock{
|
||||
public TextureRegion weave, bottom;
|
||||
public class DrawWeave extends DrawPartial{
|
||||
public TextureRegion weave;
|
||||
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
Draw.rect(weave, build.x, build.y, build.totalProgress());
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
@ -26,18 +25,10 @@ public class DrawWeave extends DrawBlock{
|
||||
build.block.size * Vars.tilesize / 2f);
|
||||
|
||||
Draw.reset();
|
||||
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
weave = Core.atlas.find(block.name + "-weave");
|
||||
bottom = Core.atlas.find(block.name + "-bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{bottom, weave, block.region};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.g2d.TextureAtlas.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.mock.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.Log.*;
|
||||
@ -27,9 +28,11 @@ public class ImagePacker{
|
||||
//makes PNG loading slightly faster
|
||||
ArcNativesLoader.load();
|
||||
|
||||
Core.settings = new MockSettings();
|
||||
Log.logger = new NoopLogHandler();
|
||||
Vars.content = new ContentLoader();
|
||||
Vars.content.createBaseContent();
|
||||
Vars.content.init();
|
||||
Log.logger = new DefaultLogHandler();
|
||||
|
||||
Fi.get("../../../assets-raw/sprites_out").walk(path -> {
|
||||
|