Disrupt weapons complete
This commit is contained in:
@@ -19,7 +19,7 @@ public abstract class DrawPart{
|
||||
/** Parameters for drawing a part in draw(). */
|
||||
public static class PartParams{
|
||||
//TODO document
|
||||
public float warmup, reload, smoothReload, heat;
|
||||
public float warmup, reload, smoothReload, heat, life;
|
||||
public float x, y, rotation;
|
||||
public int sideOverride = -1;
|
||||
|
||||
@@ -32,6 +32,7 @@ public abstract class DrawPart{
|
||||
this.y = y;
|
||||
this.rotation = rotation;
|
||||
this.sideOverride = -1;
|
||||
this.life = 0f;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +46,9 @@ public abstract class DrawPart{
|
||||
/** Weapon warmup, 0 when not firing, 1 when actively shooting. Not equivalent to heat. */
|
||||
warmup = p -> p.warmup,
|
||||
/** Weapon heat, 1 when just fired, 0, when it has cooled down (duration depends on weapon) */
|
||||
heat = p -> p.heat;
|
||||
heat = p -> p.heat,
|
||||
/** Lifetime fraction, 0 to 1. Only for missiles. */
|
||||
life = p -> p.life;
|
||||
|
||||
float get(PartParams p);
|
||||
|
||||
@@ -78,7 +81,7 @@ public abstract class DrawPart{
|
||||
}
|
||||
|
||||
default PartProgress mul(float amount){
|
||||
return p -> get(p) * amount;
|
||||
return p -> Mathf.clamp(get(p) * amount);
|
||||
}
|
||||
|
||||
default PartProgress min(PartProgress other){
|
||||
|
||||
@@ -3,7 +3,6 @@ package mindustry.entities.part;
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -30,7 +29,6 @@ public class RegionPart extends DrawPart{
|
||||
/** Progress function for heat alpha. */
|
||||
public PartProgress heatProgress = PartProgress.heat;
|
||||
public Blending blending = Blending.normal;
|
||||
public Interp interp = Interp.linear;
|
||||
public float layer = -1, layerOffset = 0f;
|
||||
public float outlineLayerOffset = -0.001f;
|
||||
public float rotation, rotMove;
|
||||
@@ -64,7 +62,6 @@ public class RegionPart extends DrawPart{
|
||||
float prevZ = Draw.z();
|
||||
float prog = progress.get(params);
|
||||
|
||||
prog = interp.apply(prog);
|
||||
int len = mirror && params.sideOverride == -1 ? 2 : 1;
|
||||
|
||||
for(int s = 0; s < len; s++){
|
||||
|
||||
64
core/src/mindustry/entities/part/ShapePart.java
Normal file
64
core/src/mindustry/entities/part/ShapePart.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package mindustry.entities.part;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
|
||||
public class ShapePart extends DrawPart{
|
||||
public boolean circle = false;
|
||||
public int sides = 3;
|
||||
public float radius = 3f, radiusTo = -1f;
|
||||
public float x, y, rotation;
|
||||
public float moveX, moveY, rotMove;
|
||||
public Color color = Color.white;
|
||||
public @Nullable Color colorTo;
|
||||
public boolean mirror = false;
|
||||
public PartProgress progress = PartProgress.warmup;
|
||||
public float layer = -1f, layerOffset = 0f;
|
||||
|
||||
@Override
|
||||
public void draw(PartParams params){
|
||||
float z = Draw.z();
|
||||
if(layer > 0) Draw.z(layer);
|
||||
if(under && turretShading) Draw.z(z - 0.0001f);
|
||||
|
||||
Draw.z(Draw.z() + layerOffset);
|
||||
|
||||
float prog = progress.get(params);
|
||||
int len = mirror && params.sideOverride == -1 ? 2 : 1;
|
||||
|
||||
for(int s = 0; s < len; s++){
|
||||
//use specific side if necessary
|
||||
int i = params.sideOverride == -1 ? s : params.sideOverride;
|
||||
|
||||
float sign = i == 1 ? -1 : 1;
|
||||
Tmp.v1.set((x + moveX * prog) * sign, y + moveY * prog).rotate(params.rotation - 90);
|
||||
|
||||
float
|
||||
rx = params.x + Tmp.v1.x,
|
||||
ry = params.y + Tmp.v1.y,
|
||||
rad = radiusTo < 0 ? radius : Mathf.lerp(radius, radiusTo, prog);
|
||||
|
||||
if(color != null && colorTo != null){
|
||||
Draw.color(color, colorTo, prog);
|
||||
}else if(color != null){
|
||||
Draw.color(color);
|
||||
}
|
||||
|
||||
if(!circle){
|
||||
Fill.poly(rx, ry, sides, rad, rotMove * prog * sign + params.rotation - 90);
|
||||
}else{
|
||||
Fill.circle(rx, ry, rad);
|
||||
}
|
||||
if(color != null) Draw.color();
|
||||
}
|
||||
|
||||
Draw.z(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(String name){
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user