Halo draw part + Ravage halo

This commit is contained in:
Anuken 2022-07-05 12:34:18 -04:00
parent b33f19b048
commit 4d8bcfebf2
4 changed files with 192 additions and 10 deletions

View File

@ -4490,6 +4490,9 @@ public class Blocks{
minWarmup = 0.99f;
coolantMultiplier = 6f;
var haloProgress = PartProgress.warmup.delay(0.5f);
float haloY = -15f, haloRotSpeed = 1f;
shake = 2f;
ammoPerShot = 2;
drawer = new DrawTurret("reinforced-"){{
@ -4523,16 +4526,103 @@ public class Blocks{
moveX = 5.5f;
}},
new ShapePart(){{
progress = PartProgress.warmup.delay(0.5f);
progress = PartProgress.warmup.delay(0.2f);
color = Pal.accent;
sides = 6;
circle = true;
hollow = true;
stroke = 0f;
strokeTo = 3f;
strokeTo = 2f;
radius = 10f;
layer = Layer.effect;
y = -15f;
rotateSpeed = 2f;
y = haloY;
rotateSpeed = haloRotSpeed;
}},
new ShapePart(){{
progress = PartProgress.warmup.delay(0.2f);
color = Pal.accent;
circle = true;
hollow = true;
stroke = 0f;
strokeTo = 1.6f;
radius = 4f;
layer = Layer.effect;
y = haloY;
rotateSpeed = haloRotSpeed;
}},
new HaloPart(){{
progress = haloProgress;
color = Pal.accent;
layer = Layer.effect;
y = haloY;
haloRotation = 90f;
shapes = 2;
triLength = 0f;
triLengthTo = 20f;
haloRadius = 16f;
tri = true;
radius = 4f;
}},
new HaloPart(){{
progress = haloProgress;
color = Pal.accent;
layer = Layer.effect;
y = haloY;
haloRotation = 90f;
shapes = 2;
triLength = 0f;
triLengthTo = 5f;
haloRadius = 16f;
tri = true;
radius = 4f;
shapeRotation = 180f;
}},
new HaloPart(){{
progress = haloProgress;
color = Pal.accent;
layer = Layer.effect;
y = haloY;
haloRotateSpeed = -haloRotSpeed;
shapes = 4;
triLength = 0f;
triLengthTo = 5f;
haloRotation = 45f;
haloRadius = 16f;
tri = true;
radius = 8f;
}},
new HaloPart(){{
progress = haloProgress;
color = Pal.accent;
layer = Layer.effect;
y = haloY;
haloRotateSpeed = -haloRotSpeed;
shapes = 4;
shapeRotation = 180f;
triLength = 0f;
triLengthTo = 2f;
haloRotation = 45f;
haloRadius = 16f;
tri = true;
radius = 8f;
}},
new HaloPart(){{
progress = haloProgress;
color = Pal.accent;
layer = Layer.effect;
y = haloY;
haloRotateSpeed = haloRotSpeed;
shapes = 4;
triLength = 0f;
triLengthTo = 3f;
haloRotation = 45f;
haloRadius = 10f;
tri = true;
radius = 6f;
}}
);

View File

@ -0,0 +1,89 @@
package mindustry.entities.part;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.graphics.*;
public class HaloPart extends DrawPart{
public boolean hollow = false, tri = false;
public int shapes = 3;
public int sides = 3;
public float radius = 3f, radiusTo = -1f, stroke = 1f, strokeTo = -1f;
public float triLength = 1f, triLengthTo = -1f;
public float haloRadius = 10f, haloRadiusTo = -1f;
public float x, y, shapeRotation;
public float moveX, moveY, shapeMoveRot;
public float haloRotateSpeed = 0f, haloRotation = 0f;
public float rotateSpeed = 0f;
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.getClamp(params),
baseRot = Time.time * rotateSpeed,
rad = radiusTo < 0 ? radius : Mathf.lerp(radius, radiusTo, prog),
triLen = triLengthTo < 0 ? triLength : Mathf.lerp(triLength, triLengthTo, prog),
str = strokeTo < 0 ? stroke : Mathf.lerp(stroke, strokeTo, prog),
haloRad = haloRadiusTo < 0 ? haloRadius : Mathf.lerp(haloRadius, haloRadiusTo, prog);
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 == 0 ? 1 : -1) * params.sideMultiplier;
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;
if(color != null && colorTo != null){
Draw.color(color, colorTo, prog);
}else if(color != null){
Draw.color(color);
}
float haloRot = (haloRotation + haloRotateSpeed * Time.time) * sign;
for(int v = 0; v < shapes; v++){
float rot = haloRot + v * 360f / shapes + params.rotation;
float shapeX = Angles.trnsx(rot, haloRad) + rx, shapeY = Angles.trnsy(rot, haloRad) + ry;
float pointRot = rot + shapeMoveRot * prog * sign + shapeRotation * sign + baseRot * sign;
if(tri){
Drawf.tri(shapeX, shapeY, rad, triLen, pointRot);
}else if(!hollow){
Fill.poly(shapeX, shapeY, sides, rad, pointRot);
}else{
Lines.stroke(str);
Lines.poly(shapeX, shapeY, sides, rad, pointRot);
Lines.stroke(1f);
}
}
if(color != null) Draw.color();
}
Draw.z(z);
}
@Override
public void load(String name){
}
}

View File

@ -26,8 +26,11 @@ public class ShapePart extends DrawPart{
Draw.z(Draw.z() + layerOffset);
float prog = progress.getClamp(params);
float baseRot = Time.time * rotateSpeed;
float prog = progress.getClamp(params),
baseRot = Time.time * rotateSpeed,
rad = radiusTo < 0 ? radius : Mathf.lerp(radius, radiusTo, prog),
str = strokeTo < 0 ? stroke : Mathf.lerp(stroke, strokeTo, prog);
int len = mirror && params.sideOverride == -1 ? 2 : 1;
for(int s = 0; s < len; s++){
@ -39,9 +42,7 @@ public class ShapePart extends DrawPart{
float
rx = params.x + Tmp.v1.x,
ry = params.y + Tmp.v1.y,
rad = radiusTo < 0 ? radius : Mathf.lerp(radius, radiusTo, prog),
str = strokeTo < 0 ? stroke : Mathf.lerp(stroke, strokeTo, prog);
ry = params.y + Tmp.v1.y;
if(color != null && colorTo != null){
Draw.color(color, colorTo, prog);

View File

@ -333,6 +333,8 @@ public class Weapon implements Cloneable{
if(alwaysContinuous && mount.shoot){
mount.bullet.time = mount.bullet.lifetime * mount.bullet.type.optimalLifeFract * mount.warmup;
mount.bullet.keepAlive = true;
unit.apply(shootStatus, shootStatusDuration);
}
}
}else{