Fixed laser underBullet

This commit is contained in:
Anuken
2022-04-11 16:32:37 -04:00
parent 0abed6f635
commit 5e65e250c3
2 changed files with 13 additions and 11 deletions

View File

@@ -151,6 +151,15 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
vel.add(Angles.trnsx(ang, x * Time.delta, y * Time.delta), Angles.trnsy(ang, x * Time.delta, y * Time.delta)).limit(type.speed);
}
public boolean checkUnderBuild(Building build, float x, float y){
return
(!build.block.underBullets ||
//direct hit on correct tile
(aimTile != null && aimTile.build == build) ||
//a piercing bullet overshot the aim tile, it's fine to hit things now
(type.pierce && aimTile != null && Mathf.dst(x, y, originX, originY) > aimTile.dst(originX, originY) + 2f));
}
//copy-paste of World#raycastEach, inlined for lambda capture performance.
@Override
public void tileRaycast(int x1, int y1, int x2, int y2){
@@ -175,15 +184,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
}
}
if(build != null && isAdded() &&
//should underBullet detection be disabled for piercing bullets?
//|| type.pierceBuilding
(!build.block.underBullets ||
//direct hit on correct tile
(aimTile != null && aimTile.build == build) ||
//a piercing bullet overshot the aim tile, it's fine to hit things now
(type.pierce && aimTile != null && dst(originX, originY) > aimTile.dst(originX, originY) + 2f))
if(build != null && isAdded()
&& checkUnderBuild(build, x, y)
&& build.collide(self()) && type.testCollision(self(), build)
&& !build.dead() && (type.collidesTeam || build.team != team) && !(type.pierceBuilding && hasCollided(build.id))){