Partial 7.0 merge - API preview
This commit is contained in:
@@ -15,17 +15,21 @@ public class DrawAnimation extends DrawBlock{
|
||||
public TextureRegion liquid, top;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild entity){
|
||||
Draw.rect(entity.block.region, entity.x, entity.y);
|
||||
public void draw(GenericCrafterBuild build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
Draw.rect(
|
||||
sine ?
|
||||
frames[(int)Mathf.absin(entity.totalProgress, frameSpeed, frameCount - 0.001f)] :
|
||||
frames[(int)((entity.totalProgress / frameSpeed) % frameCount)],
|
||||
entity.x, entity.y);
|
||||
Draw.color(Color.clear, entity.liquids.current().color, entity.liquids.total() / entity.block.liquidCapacity);
|
||||
Draw.rect(liquid, entity.x, entity.y);
|
||||
Draw.color();
|
||||
Draw.rect(top, entity.x, entity.y);
|
||||
frames[(int)Mathf.absin(build.totalProgress, frameSpeed, frameCount - 0.001f)] :
|
||||
frames[(int)((build.totalProgress / frameSpeed) % frameCount)],
|
||||
build.x, build.y);
|
||||
if(build.liquids != null){
|
||||
Draw.color(Color.clear, build.liquids.current().color, build.liquids.total() / build.block.liquidCapacity);
|
||||
Draw.rect(liquid, build.x, build.y);
|
||||
Draw.color();
|
||||
}
|
||||
if(top.found()){
|
||||
Draw.rect(top, build.x, build.y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
69
core/src/mindustry/world/draw/DrawArcSmelter.java
Normal file
69
core/src/mindustry/world/draw/DrawArcSmelter.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
//TODO
|
||||
public class DrawArcSmelter extends DrawBlock{
|
||||
public TextureRegion top, bottom;
|
||||
public Color flameColor = Color.valueOf("f58349"), midColor = Color.valueOf("f2d585");
|
||||
public float flameRad = 1f, circleSpace = 2f, flameRadiusScl = 3f, flameRadiusMag = 0.3f, circleStroke = 1.5f;
|
||||
|
||||
public float alpha = 0.68f;
|
||||
public int particles = 25;
|
||||
public float particleLife = 40f, particleRad = 7f, particleStroke = 1.1f, particleLen = 3f;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
|
||||
if(build.warmup > 0f && flameColor.a > 0.001f){
|
||||
|
||||
|
||||
Lines.stroke(circleStroke * build.warmup);
|
||||
|
||||
float si = Mathf.absin(flameRadiusScl, flameRadiusMag);
|
||||
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.stroke(particleStroke * build.warmup);
|
||||
|
||||
float base = (Time.time / particleLife);
|
||||
rand.setSeed(build.id);
|
||||
for(int i = 0; i < particles; i++){
|
||||
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);
|
||||
}
|
||||
|
||||
Draw.blend();
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
Draw.rect(top, build.x, build.y);
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
bottom = Core.atlas.find(block.name + "-bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{bottom, block.region, top};
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,23 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** An implementation of custom rendering behavior for a block.
|
||||
* This is used mostly for mods. */
|
||||
public class DrawBlock{
|
||||
protected static final Rand rand = new Rand();
|
||||
|
||||
/** Draws the block. */
|
||||
public void draw(GenericCrafterBuild entity){
|
||||
Draw.rect(entity.block.region, entity.x, entity.y, entity.block.rotate ? entity.rotdeg() : 0);
|
||||
public void draw(GenericCrafterBuild build){
|
||||
Draw.rect(build.block.region, build.x, build.y, build.block.rotate ? build.rotdeg() : 0);
|
||||
}
|
||||
|
||||
/** Draws any extra light for the block. */
|
||||
public void drawLight(GenericCrafterBuild build){
|
||||
|
||||
}
|
||||
|
||||
/** Load any relevant texture regions. */
|
||||
|
||||
57
core/src/mindustry/world/draw/DrawCells.java
Normal file
57
core/src/mindustry/world/draw/DrawCells.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawCells extends DrawBlock{
|
||||
public TextureRegion bottom, 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(GenericCrafterBuild build){
|
||||
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
|
||||
Drawf.liquid(middle, build.x, build.y, build.warmup, color);
|
||||
|
||||
if(build.warmup > 0.001f){
|
||||
rand.setSeed(build.id);
|
||||
for(int i = 0; i < particles; i++){
|
||||
float offset = rand.nextFloat() * 999999f;
|
||||
float x = rand.range(range), y = rand.range(range);
|
||||
float fin = 1f - (((Time.time + offset) / lifetime) % recurrence);
|
||||
float ca = rand.random(0.1f, 1f);
|
||||
float fslope = Mathf.slope(fin);
|
||||
|
||||
if(fin > 0){
|
||||
Draw.color(particleColorFrom, particleColorTo, ca);
|
||||
Draw.alpha(build.warmup);
|
||||
|
||||
Fill.circle(build.x + x, build.y + y, fslope * radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
}
|
||||
|
||||
@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};
|
||||
}
|
||||
}
|
||||
56
core/src/mindustry/world/draw/DrawCultivator.java
Normal file
56
core/src/mindustry/world/draw/DrawCultivator.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawCultivator extends DrawBlock{
|
||||
public Color plantColor = Color.valueOf("5541b1");
|
||||
public Color plantColorLight = Color.valueOf("7457ce");
|
||||
public Color bottomColor = Color.valueOf("474747");
|
||||
|
||||
public int bubbles = 12, sides = 8;
|
||||
public float strokeMin = 0.2f, spread = 3f, timeScl = 70f;
|
||||
public float recurrence = 6f, radius = 3f;
|
||||
|
||||
public TextureRegion middle;
|
||||
public TextureRegion top;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild 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);
|
||||
|
||||
rand.setSeed(build.pos());
|
||||
for(int i = 0; i < bubbles; i++){
|
||||
float x = rand.range(spread), y = rand.range(spread);
|
||||
float life = 1f - ((Time.time / timeScl + rand.random(recurrence)) % recurrence);
|
||||
|
||||
if(life > 0){
|
||||
Lines.stroke(build.warmup * (life + strokeMin));
|
||||
Lines.poly(build.x + x, build.y + y, sides, (1f - life) * radius);
|
||||
}
|
||||
}
|
||||
|
||||
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};
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,10 @@ public class DrawGlow extends DrawBlock{
|
||||
public TextureRegion top;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild entity){
|
||||
Draw.rect(entity.block.region, entity.x, entity.y);
|
||||
Draw.alpha(Mathf.absin(entity.totalProgress, glowScale, glowAmount) * entity.warmup);
|
||||
Draw.rect(top, entity.x, entity.y);
|
||||
public void draw(GenericCrafterBuild 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,19 +10,19 @@ public class DrawMixer extends DrawBlock{
|
||||
public TextureRegion liquid, top, bottom;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild entity){
|
||||
float rotation = entity.block.rotate ? entity.rotdeg() : 0;
|
||||
public void draw(GenericCrafterBuild build){
|
||||
float rotation = build.block.rotate ? build.rotdeg() : 0;
|
||||
|
||||
Draw.rect(bottom, entity.x, entity.y, rotation);
|
||||
Draw.rect(bottom, build.x, build.y, rotation);
|
||||
|
||||
if(entity.liquids.total() > 0.001f){
|
||||
Draw.color(((GenericCrafter)entity.block).outputLiquid.liquid.color);
|
||||
Draw.alpha(entity.liquids.get(((GenericCrafter)entity.block).outputLiquid.liquid) / entity.block.liquidCapacity);
|
||||
Draw.rect(liquid, entity.x, entity.y, rotation);
|
||||
if(build.liquids.total() > 0.001f){
|
||||
Draw.color(((GenericCrafter)build.block).outputLiquid.liquid.color);
|
||||
Draw.alpha(build.liquids.get(((GenericCrafter)build.block).outputLiquid.liquid) / build.block.liquidCapacity);
|
||||
Draw.rect(liquid, build.x, build.y, rotation);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
Draw.rect(top, entity.x, entity.y, rotation);
|
||||
Draw.rect(top, build.x, build.y, rotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,9 +9,9 @@ public class DrawRotator extends DrawBlock{
|
||||
public TextureRegion rotator;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild entity){
|
||||
Draw.rect(entity.block.region, entity.x, entity.y);
|
||||
Draw.rect(rotator, entity.x, entity.y, entity.totalProgress * 2f);
|
||||
public void draw(GenericCrafterBuild build){
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
Draw.rect(rotator, build.x, build.y, build.totalProgress * 2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
57
core/src/mindustry/world/draw/DrawSmelter.java
Normal file
57
core/src/mindustry/world/draw/DrawSmelter.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawSmelter extends DrawBlock{
|
||||
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 DrawSmelter(Color flameColor){
|
||||
this.flameColor = flameColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild 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;
|
||||
float cr = Mathf.random(0.1f);
|
||||
|
||||
Draw.z(Layer.block + 0.01f);
|
||||
|
||||
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.rect(top, build.x, build.y);
|
||||
Fill.circle(build.x, build.y, flameRadiusIn + Mathf.absin(Time.time, flameRadiusScl, flameRadiusInMag) + cr);
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -12,22 +12,22 @@ public class DrawWeave extends DrawBlock{
|
||||
public TextureRegion weave, bottom;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild entity){
|
||||
Draw.rect(bottom, entity.x, entity.y);
|
||||
Draw.rect(weave, entity.x, entity.y, entity.totalProgress);
|
||||
public void draw(GenericCrafterBuild build){
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
Draw.rect(weave, build.x, build.y, build.totalProgress);
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(entity.warmup);
|
||||
Draw.alpha(build.warmup);
|
||||
|
||||
Lines.lineAngleCenter(
|
||||
entity.x + Mathf.sin(entity.totalProgress, 6f, Vars.tilesize / 3f * entity.block.size),
|
||||
entity.y,
|
||||
build.x + Mathf.sin(build.totalProgress, 6f, Vars.tilesize / 3f * build.block.size),
|
||||
build.y,
|
||||
90,
|
||||
entity.block.size * Vars.tilesize / 2f);
|
||||
build.block.size * Vars.tilesize / 2f);
|
||||
|
||||
Draw.reset();
|
||||
|
||||
Draw.rect(entity.block.region, entity.x, entity.y);
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user