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

@@ -4,7 +4,7 @@ import arc.graphics.g2d.*;
import arc.math.*;
import arc.struct.*;
public abstract class WeaponPart{
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()! */
@@ -37,11 +37,14 @@ public abstract class WeaponPart{
}
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);
@@ -74,6 +77,10 @@ public abstract class WeaponPart{
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));
}

View File

@@ -8,10 +8,13 @@ import arc.struct.*;
import arc.util.*;
import mindustry.graphics.*;
public class RegionPart extends WeaponPart{
public class RegionPart extends DrawPart{
protected PartParams childParam = new PartParams();
/** Appended to unit/weapon/block name and drawn. */
public String suffix = "";
/** Overrides suffix if set. */
public @Nullable String name;
public TextureRegion heat;
public TextureRegion[] regions = {};
public TextureRegion[] outlines = {};
@@ -34,12 +37,19 @@ public class RegionPart extends WeaponPart{
public float x, y, moveX, moveY;
public @Nullable Color color, colorTo;
public Color heatColor = Pal.turretHeat.cpy();
public Seq<WeaponPart> children = new Seq<>();
public Seq<DrawPart> children = new Seq<>();
public RegionPart(String region){
this.suffix = region;
}
public RegionPart(String region, Blending blending, Color color){
this.suffix = region;
this.blending = blending;
this.color = color;
outline = false;
}
public RegionPart(){
}
@@ -119,25 +129,27 @@ public class RegionPart extends WeaponPart{
@Override
public void load(String name){
String realName = this.name == null ? name + suffix : this.name;
if(drawRegion){
//TODO l/r
if(mirror && turretShading){
regions = new TextureRegion[]{
Core.atlas.find(name + suffix + "1"),
Core.atlas.find(name + suffix + "2")
Core.atlas.find(realName + "1"),
Core.atlas.find(realName + "2")
};
outlines = new TextureRegion[]{
Core.atlas.find(name + suffix + "1-outline"),
Core.atlas.find(name + suffix + "2-outline")
Core.atlas.find(realName + "1-outline"),
Core.atlas.find(realName + "2-outline")
};
}else{
regions = new TextureRegion[]{Core.atlas.find(name + suffix)};
outlines = new TextureRegion[]{Core.atlas.find(name + suffix + "-outline")};
regions = new TextureRegion[]{Core.atlas.find(realName)};
outlines = new TextureRegion[]{Core.atlas.find(realName + "-outline")};
}
}
heat = Core.atlas.find(name + suffix + "-heat");
heat = Core.atlas.find(realName + "-heat");
for(var child : children){
child.load(name);
}