mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 23:28:52 +07:00
Experimenting with abilities
This commit is contained in:
parent
b23ea8b965
commit
396c087072
BIN
core/assets-raw/sprites/units/bulwark-armor.png
Normal file
BIN
core/assets-raw/sprites/units/bulwark-armor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -495,3 +495,4 @@
|
||||
63209=ship-assembler|block-ship-assembler-ui
|
||||
63208=quell-missile|unit-quell-missile-ui
|
||||
63207=bulwark|unit-bulwark-ui
|
||||
63206=mech-assembler|block-mech-assembler-ui
|
||||
|
Binary file not shown.
30
core/assets/shaders/unitarmor.frag
Normal file
30
core/assets/shaders/unitarmor.frag
Normal file
@ -0,0 +1,30 @@
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform float u_time;
|
||||
uniform float u_progress;
|
||||
uniform vec4 u_color;
|
||||
uniform vec2 u_uv;
|
||||
uniform vec2 u_uv2;
|
||||
uniform vec2 u_texsize;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main(){
|
||||
vec2 coords = (v_texCoords - u_uv) / (u_uv2 - u_uv);
|
||||
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
||||
|
||||
vec4 c = texture2D(u_texture, v_texCoords);
|
||||
|
||||
c.a *= u_progress;
|
||||
|
||||
if(c.a > 0.01){
|
||||
float f = step(abs(sin(coords.y*3.0 + u_time)), 0.9);
|
||||
c.a *= f;
|
||||
//c.rgb = mix(c.rgb, u_color.rgb, f * u_color.a);
|
||||
}
|
||||
|
||||
// c.a *= (1.0-coords.y);
|
||||
|
||||
gl_FragColor = c * v_color;
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
#define step 3.0
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform float u_time;
|
||||
@ -12,40 +10,17 @@ uniform vec2 u_texsize;
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
bool id(vec4 v){
|
||||
return v.a > 0.1;
|
||||
}
|
||||
|
||||
bool id(vec2 coords, vec4 base){
|
||||
vec4 target = texture2D(u_texture, coords);
|
||||
return target.a < 0.1 || (coords.x < u_uv.x || coords.y < u_uv.y || coords.x > u_uv2.x || coords.y > u_uv2.y);
|
||||
}
|
||||
|
||||
bool cont(vec2 T, vec2 v){
|
||||
vec4 base = texture2D(u_texture, T);
|
||||
return base.a > 0.1 &&
|
||||
(id(T + vec2(0, step) * v, base) || id(T + vec2(0, -step) * v, base) ||
|
||||
id(T + vec2(step, 0) * v, base) || id(T + vec2(-step, 0) * v, base) ||
|
||||
id(T + vec2(step, step) * v, base) || id(T + vec2(-step, -step) * v, base) ||
|
||||
id(T + vec2(step, -step) * v, base) || id(T + vec2(-step, step) * v, base));
|
||||
}
|
||||
|
||||
void main(){
|
||||
vec2 coords = (v_texCoords.xy - u_uv) / (u_uv2 - u_uv);
|
||||
vec2 t = v_texCoords.xy;
|
||||
vec2 coords = (v_texCoords - u_uv) / (u_uv2 - u_uv);
|
||||
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
||||
|
||||
vec4 c = texture2D(u_texture, v_texCoords.xy);
|
||||
vec4 c = texture2D(u_texture, v_texCoords);
|
||||
float alpha = c.a;
|
||||
|
||||
c.a *= u_progress;
|
||||
|
||||
if(c.a > 0.01){
|
||||
float f = abs(sin(coords.x*2.0 + u_time));
|
||||
if(f > 0.9)
|
||||
f = 1.0;
|
||||
else
|
||||
f = 0.0;
|
||||
float f = step(abs(sin(coords.x*2.0 + u_time)), 0.9);
|
||||
c = mix(c, u_color, f * u_color.a);
|
||||
}
|
||||
|
||||
|
@ -3295,7 +3295,7 @@ public class Blocks{
|
||||
tankAssembler = new UnitAssembler("tank-assembler"){{
|
||||
requirements(Category.units, with(Items.graphite, 10));
|
||||
size = 5;
|
||||
plans.add(new AssemblerUnitPlan(UnitTypes.vanquish, 60f * 10f, BlockStack.list(Blocks.thoriumWallLarge, 4, Blocks.duct, 2)));
|
||||
plans.add(new AssemblerUnitPlan(UnitTypes.vanquish, 60f * 10f, BlockStack.list(Blocks.tungstenWallLarge, 5, Blocks.duct, 2)));
|
||||
consumes.power(2f);
|
||||
areaSize = 13;
|
||||
|
||||
@ -3307,7 +3307,7 @@ public class Blocks{
|
||||
shipAssembler = new UnitAssembler("ship-assembler"){{
|
||||
requirements(Category.units, with(Items.graphite, 10));
|
||||
size = 5;
|
||||
plans.add(new AssemblerUnitPlan(UnitTypes.quell, 60f * 4f, BlockStack.list(Blocks.thoriumWallLarge, 4, Blocks.duct, 2)));
|
||||
plans.add(new AssemblerUnitPlan(UnitTypes.quell, 60f * 4f, BlockStack.list(Blocks.tungstenWallLarge, 5, Blocks.plasmaBore, 2)));
|
||||
consumes.power(2f);
|
||||
areaSize = 13;
|
||||
|
||||
@ -3316,7 +3316,18 @@ public class Blocks{
|
||||
|
||||
}};
|
||||
|
||||
//TODO mech assembler
|
||||
//TODO requirements
|
||||
mechAssembler = new UnitAssembler("mech-assembler"){{
|
||||
requirements(Category.units, with(Items.graphite, 10));
|
||||
size = 5;
|
||||
plans.add(new AssemblerUnitPlan(UnitTypes.bulwark, 60f * 4f, BlockStack.list(Blocks.tungstenWallLarge, 5, Blocks.duct, 2)));
|
||||
consumes.power(2f);
|
||||
areaSize = 13;
|
||||
|
||||
//TODO unit production is rarely continuous, can be double
|
||||
consumes.liquid(Liquids.gallium, 1f / 60f);
|
||||
|
||||
}};
|
||||
|
||||
basicAssemblerModule = new UnitAssemblerModule("basic-assembler-module"){{
|
||||
requirements(Category.units, with(Items.graphite, 10));
|
||||
|
@ -2455,7 +2455,7 @@ public class UnitTypes{
|
||||
sprite = "missile-large";
|
||||
width = 9.5f;
|
||||
height = 15f;
|
||||
lifetime = 32f;
|
||||
lifetime = 30f;
|
||||
hitSize = 6f;
|
||||
shootEffect = Fx.shootTitan;
|
||||
smokeEffect = Fx.shootSmokeTitan;
|
||||
@ -2509,7 +2509,8 @@ public class UnitTypes{
|
||||
outlineColor = Pal.darkOutline;
|
||||
envDisabled = Env.space;
|
||||
|
||||
//TODO shield ability
|
||||
//TODO shield ability looks bad
|
||||
//abilities.add(new ArmorPlateAbility());
|
||||
|
||||
rotateSpeed = 2.7f;
|
||||
|
||||
@ -2549,7 +2550,7 @@ public class UnitTypes{
|
||||
velocityRnd = 0.33f;
|
||||
heatColor = Color.red;
|
||||
|
||||
bullet = new MissileBulletType(4.2f, 30){{
|
||||
bullet = new MissileBulletType(4.2f, 34){{
|
||||
homingPower = 0.2f;
|
||||
weaveMag = 4;
|
||||
weaveScale = 4;
|
||||
@ -2557,7 +2558,7 @@ public class UnitTypes{
|
||||
//TODO better
|
||||
shootEffect = Fx.shootBig2;
|
||||
smokeEffect = Fx.shootSmokeTitan;
|
||||
splashDamage = 50f;
|
||||
splashDamage = 40f;
|
||||
splashDamageRadius = 30f;
|
||||
frontColor = Color.white;
|
||||
hitSound = Sounds.none;
|
||||
|
49
core/src/mindustry/entities/abilities/ArmorPlateAbility.java
Normal file
49
core/src/mindustry/entities/abilities/ArmorPlateAbility.java
Normal file
@ -0,0 +1,49 @@
|
||||
package mindustry.entities.abilities;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class ArmorPlateAbility extends Ability{
|
||||
public TextureRegion plateRegion;
|
||||
public Color color = Color.valueOf("d1efff");
|
||||
|
||||
public float healthMultiplier = 0.2f;
|
||||
public float z = Layer.effect;
|
||||
|
||||
protected float warmup;
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
super.update(unit);
|
||||
|
||||
warmup = Mathf.lerpDelta(warmup, unit.isShooting() ? 1f : 0f, 0.1f);
|
||||
unit.healthMultiplier += warmup * healthMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Unit unit){
|
||||
if(warmup > 0.001f){
|
||||
if(plateRegion == null){
|
||||
plateRegion = Core.atlas.find(unit.type.name + "-armor", unit.type.region);
|
||||
}
|
||||
|
||||
Draw.draw(z <= 0 ? Draw.z() : z, () -> {
|
||||
Shaders.armor.region = plateRegion;
|
||||
Shaders.armor.progress = warmup;
|
||||
Shaders.armor.time = -Time.time / 20f;
|
||||
|
||||
Draw.color(color);
|
||||
Draw.shader(Shaders.armor);
|
||||
Draw.rect(Shaders.armor.region, unit.x, unit.y, unit.rotation - 90f);
|
||||
Draw.shader();
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ public class Shaders{
|
||||
public static @Nullable ShieldShader shield;
|
||||
public static BuildBeamShader buildBeam;
|
||||
public static UnitBuildShader build;
|
||||
public static UnitArmorShader armor;
|
||||
public static DarknessShader darkness;
|
||||
public static LightShader light;
|
||||
public static SurfaceShader water, mud, tar, slag, cryofluid, space, caustics, arkycite;
|
||||
@ -42,6 +43,7 @@ public class Shaders{
|
||||
}
|
||||
buildBeam = new BuildBeamShader();
|
||||
build = new UnitBuildShader();
|
||||
armor = new UnitArmorShader();
|
||||
darkness = new DarknessShader();
|
||||
light = new LightShader();
|
||||
water = new SurfaceShader("water");
|
||||
@ -200,6 +202,24 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnitArmorShader extends LoadShader{
|
||||
public float progress, time;
|
||||
public TextureRegion region;
|
||||
|
||||
public UnitArmorShader(){
|
||||
super("unitarmor", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
setUniformf("u_time", time);
|
||||
setUniformf("u_progress", progress);
|
||||
setUniformf("u_uv", region.u, region.v);
|
||||
setUniformf("u_uv2", region.u2, region.v2);
|
||||
setUniformf("u_texsize", region.texture.width, region.texture.height);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockBuildShader extends LoadShader{
|
||||
public float progress;
|
||||
public TextureRegion region = new TextureRegion();
|
||||
|
Loading…
Reference in New Issue
Block a user