Weapon animation suffering
This commit is contained in:
@@ -2526,7 +2526,9 @@ public class UnitTypes{
|
||||
y = -2f;
|
||||
shadow = 50f;
|
||||
heatColor = Color.valueOf("f9350f");
|
||||
cooldownTime = 80f;
|
||||
shootWarmupSpeed = 0.06f;
|
||||
cooldownTime = 110f;
|
||||
heatColor = Color.valueOf("f9350f");
|
||||
|
||||
parts.add(
|
||||
new RegionPart("-glow"){{
|
||||
@@ -2534,10 +2536,33 @@ public class UnitTypes{
|
||||
blending = Blending.additive;
|
||||
outline = mirror = false;
|
||||
}},
|
||||
new RegionPart("-sides"){{
|
||||
useReload = false;
|
||||
mirror = true;
|
||||
under = true;
|
||||
moveX = 0.5f;
|
||||
moveY = 0.5f;
|
||||
rotMove = 82f;
|
||||
x = 38 / 4f;
|
||||
y = 9 / 4f;
|
||||
}},
|
||||
new RegionPart("-sinks"){{
|
||||
useReload = false;
|
||||
mirror = true;
|
||||
under = true;
|
||||
heatColor = new Color(1f, 0.1f, 0.1f);
|
||||
moveX = 15f / 4f;
|
||||
moveY = -13f / 4f;
|
||||
x = 34 / 4f;
|
||||
y = -36 / 4f;
|
||||
}},
|
||||
new RegionPart("-sinks-heat"){{
|
||||
blending = Blending.additive;
|
||||
useReload = false;
|
||||
mirror = true;
|
||||
outline = false;
|
||||
colorTo = new Color(1f, 0f, 0f, 0.5f);
|
||||
color = colorTo.cpy().a(0f);
|
||||
moveX = 15f / 4f;
|
||||
moveY = -13f / 4f;
|
||||
x = 34 / 4f;
|
||||
@@ -2545,20 +2570,20 @@ public class UnitTypes{
|
||||
}}
|
||||
);
|
||||
|
||||
bullet = new BasicBulletType(8f, 110){{
|
||||
bullet = new BasicBulletType(8.5f, 250){{
|
||||
sprite = "missile-large";
|
||||
width = 9.5f;
|
||||
height = 15f;
|
||||
width = 12f;
|
||||
height = 20f;
|
||||
lifetime = 30f;
|
||||
hitSize = 6f;
|
||||
shootEffect = Fx.shootTitan;
|
||||
smokeEffect = Fx.shootSmokeTitan;
|
||||
pierceCap = 2;
|
||||
pierceCap = 3;
|
||||
pierce = true;
|
||||
pierceBuilding = true;
|
||||
hitColor = backColor = trailColor = Color.valueOf("feb380");
|
||||
frontColor = Color.white;
|
||||
trailWidth = 3.1f;
|
||||
trailWidth = 4f;
|
||||
trailLength = 8;
|
||||
hitEffect = despawnEffect = Fx.blastExplosion;
|
||||
}};
|
||||
|
||||
@@ -20,8 +20,6 @@ public class RegionPart extends WeaponPart{
|
||||
public boolean mirror = false;
|
||||
/** If true, an outline is drawn under the part. */
|
||||
public boolean outline = true;
|
||||
/** If true, the layer is overridden to be under the weapon/turret itself. */
|
||||
public boolean under = false;
|
||||
/** If true, the base + outline regions are drawn. Set to false for heat-only regions. */
|
||||
public boolean drawRegion = true;
|
||||
/** If true, progress is inverted. */
|
||||
@@ -49,7 +47,8 @@ public class RegionPart extends WeaponPart{
|
||||
public void draw(PartParams params){
|
||||
float z = Draw.z();
|
||||
if(layer > 0) Draw.z(layer);
|
||||
if(under) Draw.z(z - 0.0001f);
|
||||
//TODO 'under' should not be special cased like this...
|
||||
if(under && turretShading) Draw.z(z - 0.0001f);
|
||||
|
||||
float prevZ = Draw.z();
|
||||
float progress = useReload ? 1f - params.reload : params.warmup;
|
||||
|
||||
@@ -8,6 +8,8 @@ public abstract class WeaponPart{
|
||||
|
||||
/** 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);
|
||||
|
||||
@@ -613,7 +613,7 @@ public class UnitType extends UnlockableContent{
|
||||
if(outlines){
|
||||
|
||||
//outlines only created when weapons are drawn under w/ merged outlines
|
||||
makeOutline(packer, region, alwaysCreateOutline || weapons.contains(w -> !w.top));
|
||||
makeOutline(packer, region, alwaysCreateOutline || weapons.contains(w -> !w.top || w.parts.contains(p -> p.under)));
|
||||
|
||||
for(Weapon weapon : weapons){
|
||||
if(!weapon.name.isEmpty()){
|
||||
@@ -981,7 +981,13 @@ public class UnitType extends UnlockableContent{
|
||||
|
||||
for(WeaponMount mount : unit.mounts){
|
||||
if(!mount.weapon.top){
|
||||
//apply layer offset, roll it back at the end
|
||||
float z = Draw.z();
|
||||
Draw.z(z + mount.weapon.layerOffset);
|
||||
|
||||
mount.weapon.drawOutline(unit, mount);
|
||||
|
||||
Draw.z(z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import static mindustry.Vars.*;
|
||||
public class Weapon implements Cloneable{
|
||||
/** temporary weapon sequence number */
|
||||
static int sequenceNum = 0;
|
||||
|
||||
|
||||
/** displayed weapon region */
|
||||
public String name;
|
||||
/** bullet shot */
|
||||
@@ -129,7 +129,7 @@ public class Weapon implements Cloneable{
|
||||
/** whether this weapon should fire when its owner dies */
|
||||
public boolean shootOnDeath = false;
|
||||
/** extra animated parts */
|
||||
public Seq<WeaponPart> parts = new Seq<>();
|
||||
public Seq<WeaponPart> parts = new Seq<>(WeaponPart.class);
|
||||
|
||||
public Weapon(String name){
|
||||
this.name = name;
|
||||
@@ -158,10 +158,6 @@ public class Weapon implements Cloneable{
|
||||
public void drawOutline(Unit unit, WeaponMount mount){
|
||||
if(!outlineRegion.found()) return;
|
||||
|
||||
//apply layer offset, roll it back at the end
|
||||
float z = Draw.z();
|
||||
Draw.z(z + layerOffset);
|
||||
|
||||
float
|
||||
rotation = unit.rotation - 90,
|
||||
weaponRotation = rotation + (rotate ? mount.rotation : 0),
|
||||
@@ -171,10 +167,8 @@ public class Weapon implements Cloneable{
|
||||
Draw.xscl = -Mathf.sign(flipSprite);
|
||||
Draw.rect(outlineRegion, wx, wy, weaponRotation);
|
||||
Draw.xscl = 1f;
|
||||
|
||||
Draw.z(z);
|
||||
}
|
||||
|
||||
|
||||
public void draw(Unit unit, WeaponMount mount){
|
||||
if(!region.found()) return;
|
||||
|
||||
@@ -198,6 +192,17 @@ public class Weapon implements Cloneable{
|
||||
|
||||
Draw.xscl = -Mathf.sign(flipSprite);
|
||||
|
||||
if(parts.size > 0){
|
||||
WeaponPart.params.set(mount.warmup, 1f - Mathf.clamp(mount.reload / reload), mount.heat, wx, wy, weaponRotation + 90);
|
||||
|
||||
for(int i = 0; i < parts.size; i++){
|
||||
var part = parts.items[i];
|
||||
if(part.under){
|
||||
part.draw(WeaponPart.params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Draw.rect(region, wx, wy, weaponRotation);
|
||||
|
||||
if(heatRegion.found() && mount.heat > 0){
|
||||
@@ -218,10 +223,11 @@ public class Weapon implements Cloneable{
|
||||
Draw.z(Layer.turret);
|
||||
}*/
|
||||
|
||||
var params = WeaponPart.params.set(mount.warmup, 1f - Mathf.clamp(mount.reload / reload), mount.heat, wx, wy, weaponRotation + 90);
|
||||
|
||||
for(var part : parts){
|
||||
part.draw(params);
|
||||
for(int i = 0; i < parts.size; i++){
|
||||
var part = parts.items[i];
|
||||
if(!part.under){
|
||||
part.draw(WeaponPart.params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,8 +367,8 @@ public class Weapon implements Cloneable{
|
||||
protected Vec2 getShootPos(Unit unit, WeaponMount mount, Vec2 out){
|
||||
float weaponRot = unit.rotation - 90 + (rotate ? mount.rotation : 0);
|
||||
return out.set(unit.x, unit.y)
|
||||
.add(Angles.trnsx(unit.rotation - 90, x, y), Angles.trnsy(unit.rotation - 90, x, y))
|
||||
.add(Angles.trnsx(weaponRot, this.shootX, this.shootY), Angles.trnsx(weaponRot, this.shootX, this.shootY));
|
||||
.add(Angles.trnsx(unit.rotation - 90, x, y), Angles.trnsy(unit.rotation - 90, x, y))
|
||||
.add(Angles.trnsx(weaponRot, this.shootX, this.shootY), Angles.trnsx(weaponRot, this.shootX, this.shootY));
|
||||
}
|
||||
|
||||
protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float aimX, float aimY, float mountX, float mountY, float rotation, int side){
|
||||
@@ -430,9 +436,9 @@ public class Weapon implements Cloneable{
|
||||
|
||||
protected @Nullable Bullet bullet(Unit unit, float shootX, float shootY, float angle, float lifescl){
|
||||
float
|
||||
xr = Mathf.range(xRand),
|
||||
x = shootX + Angles.trnsx(angle, 0, xr),
|
||||
y = shootY + Angles.trnsy(angle, 0, xr);
|
||||
xr = Mathf.range(xRand),
|
||||
x = shootX + Angles.trnsx(angle, 0, xr),
|
||||
y = shootY + Angles.trnsy(angle, 0, xr);
|
||||
|
||||
if(unitSpawned == null){
|
||||
return bullet.create(unit, unit.team, x, y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifescl);
|
||||
|
||||
Reference in New Issue
Block a user