recoil as part progress

This commit is contained in:
Anuken
2022-05-20 19:46:18 -04:00
parent 39f32af500
commit b010e9d720
7 changed files with 15 additions and 12 deletions

View File

@@ -3787,7 +3787,7 @@ public class Blocks{
progress = PartProgress.warmup; progress = PartProgress.warmup;
moveRot = -10f; moveRot = -10f;
mirror = true; mirror = true;
moves.add(new PartMove(PartProgress.reload, 0f, -3f, -5f)); moves.add(new PartMove(PartProgress.recoil, 0f, -3f, -5f));
heatColor = Color.red; heatColor = Color.red;
}}); }});
}}; }};
@@ -3937,7 +3937,7 @@ public class Blocks{
drawer = new DrawTurret("reinforced-"){{ drawer = new DrawTurret("reinforced-"){{
parts.addAll( parts.addAll(
new RegionPart("-barrel"){{ new RegionPart("-barrel"){{
progress = PartProgress.reload.curve(Interp.pow2In); progress = PartProgress.recoil.curve(Interp.pow2In);
moveY = -5f * 4f / 3f; moveY = -5f * 4f / 3f;
heatColor = Color.valueOf("f03b0e"); heatColor = Color.valueOf("f03b0e");
mirror = false; mirror = false;
@@ -4011,8 +4011,8 @@ public class Blocks{
parts.add(new RegionPart("-mid"){{ parts.add(new RegionPart("-mid"){{
under = true; under = true;
moveY = -1.5f; moveY = -1.5f;
progress = PartProgress.reload; progress = PartProgress.recoil;
heatProgress = PartProgress.reload.add(0.25f).min(PartProgress.warmup); heatProgress = PartProgress.recoil.add(0.25f).min(PartProgress.warmup);
heatColor = Color.sky.cpy().a(0.9f); heatColor = Color.sky.cpy().a(0.9f);
}}); }});
parts.add(new RegionPart("-blade"){{ parts.add(new RegionPart("-blade"){{

View File

@@ -22,14 +22,15 @@ public abstract class DrawPart{
/** Parameters for drawing a part in draw(). */ /** Parameters for drawing a part in draw(). */
public static class PartParams{ public static class PartParams{
//TODO document //TODO document
public float warmup, reload, smoothReload, heat, life; public float warmup, reload, smoothReload, heat, recoil, life;
public float x, y, rotation; public float x, y, rotation;
public int sideOverride = -1, sideMultiplier = 1; public int sideOverride = -1, sideMultiplier = 1;
public PartParams set(float warmup, float reload, float smoothReload, float heat, float x, float y, float rotation){ public PartParams set(float warmup, float reload, float smoothReload, float heat, float recoil, float x, float y, float rotation){
this.warmup = warmup; this.warmup = warmup;
this.reload = reload; this.reload = reload;
this.heat = heat; this.heat = heat;
this.recoil = recoil;
this.smoothReload = smoothReload; this.smoothReload = smoothReload;
this.x = x; this.x = x;
this.y = y; this.y = y;
@@ -64,6 +65,8 @@ public abstract class DrawPart{
smoothReload = p -> p.smoothReload, smoothReload = p -> p.smoothReload,
/** Weapon warmup, 0 when not firing, 1 when actively shooting. Not equivalent to heat. */ /** Weapon warmup, 0 when not firing, 1 when actively shooting. Not equivalent to heat. */
warmup = p -> p.warmup, warmup = p -> p.warmup,
/** Weapon recoil with no curve applied. */
recoil = p -> p.recoil,
/** Weapon heat, 1 when just fired, 0, when it has cooled down (duration depends on weapon) */ /** 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. */ /** Lifetime fraction, 0 to 1. Only for missiles. */

View File

@@ -127,7 +127,7 @@ public class RegionPart extends DrawPart{
float sign = (i == 1 ? -1 : 1) * params.sideMultiplier; float sign = (i == 1 ? -1 : 1) * params.sideMultiplier;
Tmp.v1.set((x + mx) * sign, y + my).rotate(params.rotation - 90); Tmp.v1.set((x + mx) * sign, y + my).rotate(params.rotation - 90);
childParam.set(params.warmup, params.reload, params.smoothReload, params.heat, params.x + Tmp.v1.x, params.y + Tmp.v1.y, i * sign + mr * sign + params.rotation); childParam.set(params.warmup, params.reload, params.smoothReload, params.heat, params.recoil, params.x + Tmp.v1.x, params.y + Tmp.v1.y, i * sign + mr * sign + params.rotation);
childParam.sideMultiplier = params.sideMultiplier; childParam.sideMultiplier = params.sideMultiplier;
childParam.life = params.life; childParam.life = params.life;
childParam.sideOverride = i; childParam.sideOverride = i;

View File

@@ -1106,9 +1106,9 @@ public class UnitType extends UnlockableContent{
WeaponMount first = unit.mounts.length > part.weaponIndex ? unit.mounts[part.weaponIndex] : null; WeaponMount first = unit.mounts.length > part.weaponIndex ? unit.mounts[part.weaponIndex] : null;
if(first != null){ if(first != null){
DrawPart.params.set(first.warmup, first.reload / weapons.first().reload, first.smoothReload, first.heat, unit.x, unit.y, unit.rotation); DrawPart.params.set(first.warmup, first.reload / weapons.first().reload, first.smoothReload, first.heat, first.recoil, unit.x, unit.y, unit.rotation);
}else{ }else{
DrawPart.params.set(0f, 0f, 0f, 0f, unit.x, unit.y, unit.rotation); DrawPart.params.set(0f, 0f, 0f, 0f, 0f, unit.x, unit.y, unit.rotation);
} }
if(unit instanceof Scaled s){ if(unit instanceof Scaled s){

View File

@@ -200,7 +200,7 @@ public class Weapon implements Cloneable{
} }
if(parts.size > 0){ if(parts.size > 0){
DrawPart.params.set(mount.warmup, mount.reload / reload, mount.smoothReload, mount.heat, wx, wy, weaponRotation + 90); DrawPart.params.set(mount.warmup, mount.reload / reload, mount.smoothReload, mount.heat, mount.recoil, wx, wy, weaponRotation + 90);
DrawPart.params.sideMultiplier = flipSprite ? -1 : 1; DrawPart.params.sideMultiplier = flipSprite ? -1 : 1;
for(int i = 0; i < parts.size; i++){ for(int i = 0; i < parts.size; i++){

View File

@@ -70,7 +70,7 @@ public class DrawTurret extends DrawBlock{
float progress = tb.visualReloadValid ? tb.progress() : 1f; float progress = tb.visualReloadValid ? tb.progress() : 1f;
//TODO no smooth reload //TODO no smooth reload
var params = DrawPart.params.set(build.warmup(), 1f - progress, 1f - progress, tb.heat, tb.x + tb.recoilOffset.x, tb.y + tb.recoilOffset.y, tb.rotation); var params = DrawPart.params.set(build.warmup(), 1f - progress, 1f - progress, tb.heat, tb.curRecoil, tb.x + tb.recoilOffset.x, tb.y + tb.recoilOffset.y, tb.rotation);
for(var part : parts){ for(var part : parts){
part.draw(params); part.draw(params);

View File

@@ -25,4 +25,4 @@ org.gradle.caching=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=ef9d6ac655 archash=e7c161da88