mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-10-06 04:47:14 +03:00
Improve ArmorPlateAbility draw (#9581)
* Improve ArmorPlateAbility draw * Revert to tinting Just make a white shine sprite. Or none-white if you want some interesting visuals with the colors. * Fix not applying z when drawShine = false
This commit is contained in:
parent
52b5a950f9
commit
037f752b73
@ -2,7 +2,6 @@ uniform sampler2D u_texture;
|
|||||||
|
|
||||||
uniform float u_time;
|
uniform float u_time;
|
||||||
uniform float u_progress;
|
uniform float u_progress;
|
||||||
uniform vec4 u_color;
|
|
||||||
uniform vec2 u_uv;
|
uniform vec2 u_uv;
|
||||||
uniform vec2 u_uv2;
|
uniform vec2 u_uv2;
|
||||||
uniform vec2 u_texsize;
|
uniform vec2 u_texsize;
|
||||||
@ -14,8 +13,7 @@ void main(){
|
|||||||
vec2 coords = (v_texCoords - u_uv) / (u_uv2 - u_uv);
|
vec2 coords = (v_texCoords - u_uv) / (u_uv2 - u_uv);
|
||||||
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
||||||
|
|
||||||
vec4 c = texture2D(u_texture, v_texCoords);
|
vec4 c = texture2D(u_texture, v_texCoords);
|
||||||
|
|
||||||
c.a *= u_progress;
|
c.a *= u_progress;
|
||||||
c.a *= step(abs(sin(coords.y*3.0 + u_time)), 0.9);
|
c.a *= step(abs(sin(coords.y*3.0 + u_time)), 0.9);
|
||||||
|
|
||||||
|
@ -12,10 +12,20 @@ import mindustry.world.meta.*;
|
|||||||
|
|
||||||
public class ArmorPlateAbility extends Ability{
|
public class ArmorPlateAbility extends Ability{
|
||||||
public TextureRegion plateRegion;
|
public TextureRegion plateRegion;
|
||||||
public Color color = Color.valueOf("d1efff");
|
public TextureRegion shineRegion;
|
||||||
|
public String plateSuffix = "-armor";
|
||||||
|
public String shineSuffix = "-shine";
|
||||||
|
/** Color of the shine. If null, uses team color. */
|
||||||
|
public @Nullable Color color = null;
|
||||||
|
public float shineSpeed = 1f;
|
||||||
|
public float z = -1;
|
||||||
|
|
||||||
|
/** Whether to draw the plate region. */
|
||||||
|
public boolean drawPlate = true;
|
||||||
|
/** Whether to draw the shine over the plate region. */
|
||||||
|
public boolean drawShine = true;
|
||||||
|
|
||||||
public float healthMultiplier = 0.2f;
|
public float healthMultiplier = 0.2f;
|
||||||
public float z = Layer.effect;
|
|
||||||
|
|
||||||
protected float warmup;
|
protected float warmup;
|
||||||
|
|
||||||
@ -34,24 +44,39 @@ public class ArmorPlateAbility extends Ability{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Unit unit){
|
public void draw(Unit unit){
|
||||||
|
if(!drawPlate && !drawShine) return;
|
||||||
|
|
||||||
if(warmup > 0.001f){
|
if(warmup > 0.001f){
|
||||||
if(plateRegion == null){
|
if(plateRegion == null){
|
||||||
plateRegion = Core.atlas.find(unit.type.name + "-armor", unit.type.region);
|
plateRegion = Core.atlas.find(unit.type.name + plateSuffix, unit.type.region);
|
||||||
|
shineRegion = Core.atlas.find(unit.type.name + shineSuffix, plateRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.draw(z <= 0 ? Draw.z() : z, () -> {
|
float pz = Draw.z();
|
||||||
Shaders.armor.region = plateRegion;
|
if(z > 0) Draw.z(z);
|
||||||
Shaders.armor.progress = warmup;
|
|
||||||
Shaders.armor.time = -Time.time / 20f;
|
|
||||||
|
|
||||||
Draw.rect(Shaders.armor.region, unit.x, unit.y, unit.rotation - 90f);
|
if(drawPlate){
|
||||||
Draw.color(color);
|
Draw.alpha(warmup);
|
||||||
Draw.shader(Shaders.armor);
|
Draw.rect(plateRegion, unit.x, unit.y, unit.rotation - 90f);
|
||||||
Draw.rect(Shaders.armor.region, unit.x, unit.y, unit.rotation - 90f);
|
Draw.alpha(1f);
|
||||||
Draw.shader();
|
}
|
||||||
|
|
||||||
Draw.reset();
|
if(drawShine){
|
||||||
});
|
Draw.draw(Draw.z(), () -> {
|
||||||
|
Shaders.armor.region = shineRegion;
|
||||||
|
Shaders.armor.progress = warmup;
|
||||||
|
Shaders.armor.time = -Time.time / 20f * shineSpeed;
|
||||||
|
|
||||||
|
Draw.color(color == null ? unit.team.color : color);
|
||||||
|
Draw.shader(Shaders.armor);
|
||||||
|
Draw.rect(shineRegion, unit.x, unit.y, unit.rotation - 90f);
|
||||||
|
Draw.shader();
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.z(pz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user