Disrupt weapons complete

This commit is contained in:
Anuken
2022-02-04 17:34:13 -05:00
parent 60621520ee
commit c8da241825
13 changed files with 171 additions and 69 deletions

View 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){
}
}