WIP Disrupt missiles

This commit is contained in:
Anuken
2022-02-04 15:37:51 -05:00
parent 4c9761eae5
commit 60621520ee
22 changed files with 188 additions and 143 deletions

View File

@@ -0,0 +1,108 @@
package mindustry.entities.part;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.struct.*;
public abstract class DrawPart{
public static final PartParams params = new PartParams();
/** If true, turret shading is used. Don't touch this, it is set up in unit/block init()! */
public boolean turretShading;
/** If true, the layer is overridden to be under the weapon/turret itself. */
public boolean under = false;
public abstract void draw(PartParams params);
public abstract void load(String name);
public void getOutlines(Seq<TextureRegion> out){}
/** Parameters for drawing a part in draw(). */
public static class PartParams{
//TODO document
public float warmup, reload, smoothReload, heat;
public float x, y, rotation;
public int sideOverride = -1;
public PartParams set(float warmup, float reload, float smoothReload, float heat, float x, float y, float rotation){
this.warmup = warmup;
this.reload = reload;
this.heat = heat;
this.smoothReload = smoothReload;
this.x = x;
this.y = y;
this.rotation = rotation;
this.sideOverride = -1;
return this;
}
}
public interface PartProgress{
/** Reload of the weapon - 1 right after shooting, 0 when ready to fire*/
PartProgress
reload = p -> p.reload,
/** Reload, but smoothed out, so there is no sudden jump between 0-1. */
smoothReload = p -> p.smoothReload,
/** 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;
float get(PartParams p);
static PartProgress constant(float value){
return p -> value;
}
default PartProgress inv(){
return p -> 1f - get(p);
}
default PartProgress add(float amount){
return p -> Mathf.clamp(get(p) + amount);
}
default PartProgress delay(float amount){
return p -> Mathf.clamp((get(p) - amount) / (1f - amount));
}
default PartProgress shorten(float amount){
return p -> Mathf.clamp(get(p) / (1f - amount));
}
default PartProgress blend(PartProgress other, float amount){
return p -> Mathf.lerp(get(p), other.get(p), amount);
}
default PartProgress mul(PartProgress other){
return p -> get(p) * other.get(p);
}
default PartProgress mul(float amount){
return p -> get(p) * amount;
}
default PartProgress min(PartProgress other){
return p -> Math.min(get(p), other.get(p));
}
default PartProgress sin(float scl, float mag){
return p -> Mathf.clamp(get(p) + Mathf.sin(scl, mag));
}
default PartProgress absin(float scl, float mag){
return p -> Mathf.clamp(get(p) + Mathf.absin(scl, mag));
}
default PartProgress apply(PartProgress other, PartFunc func){
return p -> func.get(get(p), other.get(p));
}
default PartProgress curve(Interp interp){
return p -> interp.apply(get(p));
}
}
public interface PartFunc{
float get(float a, float b);
}
}