Laser pierce fixes. (#8526)
* Flip pierce check order Allow pierce cap + laser to function together * Apply to continuous bullets + Make visually accurately show length. * laser parameter for findPierceLength consistency with collideLine
This commit is contained in:
@@ -137,6 +137,16 @@ public class Damage{
|
|||||||
return found ? tmpBuilding : null;
|
return found ? tmpBuilding : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float findLength(Bullet b, float length, boolean laser, int pierceCap){
|
||||||
|
if(pierceCap > 0){
|
||||||
|
length = findPierceLength(b, pierceCap, laser, length);
|
||||||
|
}else if(laser){
|
||||||
|
length = findLaserLength(b, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
public static float findLaserLength(Bullet b, float length){
|
public static float findLaserLength(Bullet b, float length){
|
||||||
vec.trnsExact(b.rotation(), length);
|
vec.trnsExact(b.rotation(), length);
|
||||||
|
|
||||||
@@ -149,6 +159,10 @@ public class Damage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static float findPierceLength(Bullet b, int pierceCap, float length){
|
public static float findPierceLength(Bullet b, int pierceCap, float length){
|
||||||
|
return findPierceLength(b, pierceCap, b.type.laserAbsorb, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float findPierceLength(Bullet b, int pierceCap, boolean laser, float length){
|
||||||
vec.trnsExact(b.rotation(), length);
|
vec.trnsExact(b.rotation(), length);
|
||||||
rect.setPosition(b.x, b.y).setSize(vec.x, vec.y).normalize().grow(3f);
|
rect.setPosition(b.x, b.y).setSize(vec.x, vec.y).normalize().grow(3f);
|
||||||
|
|
||||||
@@ -163,7 +177,7 @@ public class Damage{
|
|||||||
if(build != null && build.team != b.team && build.collide(b) && b.checkUnderBuild(build, x * tilesize, y * tilesize)){
|
if(build != null && build.team != b.team && build.collide(b) && b.checkUnderBuild(build, x * tilesize, y * tilesize)){
|
||||||
distances.add(b.dst(build));
|
distances.add(b.dst(build));
|
||||||
|
|
||||||
if(b.type.laserAbsorb && build.absorbLasers()){
|
if(laser && build.absorbLasers()){
|
||||||
maxDst = Math.min(maxDst, b.dst(build));
|
maxDst = Math.min(maxDst, b.dst(build));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -189,7 +203,7 @@ public class Damage{
|
|||||||
|
|
||||||
/** Collides a bullet with blocks in a laser, taking into account absorption blocks. Resulting length is stored in the bullet's fdata. */
|
/** Collides a bullet with blocks in a laser, taking into account absorption blocks. Resulting length is stored in the bullet's fdata. */
|
||||||
public static float collideLaser(Bullet b, float length, boolean large, boolean laser, int pierceCap){
|
public static float collideLaser(Bullet b, float length, boolean large, boolean laser, int pierceCap){
|
||||||
float resultLength = findPierceLength(b, pierceCap, length);
|
float resultLength = findPierceLength(b, pierceCap, laser, length);
|
||||||
|
|
||||||
collideLine(b, b.team, b.type.hitEffect, b.x, b.y, b.rotation(), resultLength, large, laser, pierceCap);
|
collideLine(b, b.team, b.type.hitEffect, b.x, b.y, b.rotation(), resultLength, large, laser, pierceCap);
|
||||||
|
|
||||||
@@ -223,11 +237,7 @@ public class Damage{
|
|||||||
* Only enemies of the specified team are damaged.
|
* Only enemies of the specified team are damaged.
|
||||||
*/
|
*/
|
||||||
public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length, boolean large, boolean laser, int pierceCap){
|
public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length, boolean large, boolean laser, int pierceCap){
|
||||||
if(laser){
|
length = findLength(hitter, length, laser, pierceCap);
|
||||||
length = findLaserLength(hitter, length);
|
|
||||||
}else if(pierceCap > 0){
|
|
||||||
length = findPierceLength(hitter, pierceCap, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
collidedBlocks.clear();
|
collidedBlocks.clear();
|
||||||
vec.trnsExact(angle, length);
|
vec.trnsExact(angle, length);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class ContinuousFlameBulletType extends ContinuousBulletType{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Bullet b){
|
public void draw(Bullet b){
|
||||||
float mult = b.fin(lengthInterp);
|
float mult = b.fin(lengthInterp);
|
||||||
float realLength = (pierceCap <= 0 ? length : Damage.findPierceLength(b, pierceCap, length)) * mult;
|
float realLength = Damage.findLength(b, length * mult, laserAbsorb, pierceCap);
|
||||||
|
|
||||||
float sin = Mathf.sin(Time.time, oscScl, oscMag);
|
float sin = Mathf.sin(Time.time, oscScl, oscMag);
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,8 @@ public class ContinuousLaserBulletType extends ContinuousBulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Bullet b){
|
public void draw(Bullet b){
|
||||||
float realLength = Damage.findLaserLength(b, length);
|
|
||||||
float fout = Mathf.clamp(b.time > b.lifetime - fadeTime ? 1f - (b.time - (lifetime - fadeTime)) / fadeTime : 1f);
|
float fout = Mathf.clamp(b.time > b.lifetime - fadeTime ? 1f - (b.time - (lifetime - fadeTime)) / fadeTime : 1f);
|
||||||
float baseLen = realLength * fout;
|
float realLength = Damage.findLength(b, length * fout, laserAbsorb, pierceCap);
|
||||||
float rot = b.rotation();
|
float rot = b.rotation();
|
||||||
|
|
||||||
for(int i = 0; i < colors.length; i++){
|
for(int i = 0; i < colors.length; i++){
|
||||||
@@ -55,17 +54,17 @@ public class ContinuousLaserBulletType extends ContinuousBulletType{
|
|||||||
float ellipseLenScl = Mathf.lerp(1 - i / (float)(colors.length), 1f, pointyScaling);
|
float ellipseLenScl = Mathf.lerp(1 - i / (float)(colors.length), 1f, pointyScaling);
|
||||||
|
|
||||||
Lines.stroke(stroke);
|
Lines.stroke(stroke);
|
||||||
Lines.lineAngle(b.x, b.y, rot, baseLen - frontLength, false);
|
Lines.lineAngle(b.x, b.y, rot, realLength - frontLength, false);
|
||||||
|
|
||||||
//back ellipse
|
//back ellipse
|
||||||
Drawf.flameFront(b.x, b.y, divisions, rot + 180f, backLength, stroke / 2f);
|
Drawf.flameFront(b.x, b.y, divisions, rot + 180f, backLength, stroke / 2f);
|
||||||
|
|
||||||
//front ellipse
|
//front ellipse
|
||||||
Tmp.v1.trnsExact(rot, baseLen - frontLength);
|
Tmp.v1.trnsExact(rot, realLength - frontLength);
|
||||||
Drawf.flameFront(b.x + Tmp.v1.x, b.y + Tmp.v1.y, divisions, rot, frontLength * ellipseLenScl, stroke / 2f);
|
Drawf.flameFront(b.x + Tmp.v1.x, b.y + Tmp.v1.y, divisions, rot, frontLength * ellipseLenScl, stroke / 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tmp.v1.trns(b.rotation(), baseLen * 1.1f);
|
Tmp.v1.trns(b.rotation(), realLength * 1.1f);
|
||||||
|
|
||||||
Drawf.light(b.x, b.y, b.x + Tmp.v1.x, b.y + Tmp.v1.y, lightStroke, lightColor, 0.7f);
|
Drawf.light(b.x, b.y, b.x + Tmp.v1.x, b.y + Tmp.v1.y, lightStroke, lightColor, 0.7f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
@@ -76,4 +75,9 @@ public class ContinuousLaserBulletType extends ContinuousBulletType{
|
|||||||
//no light drawn here
|
//no light drawn here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float currentLength(Bullet b){
|
||||||
|
float fout = Mathf.clamp(b.time > b.lifetime - fadeTime ? 1f - (b.time - (lifetime - fadeTime)) / fadeTime : 1f);
|
||||||
|
return length * fout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user