Fixed laser underBullet
This commit is contained in:
@@ -158,7 +158,7 @@ public class Damage{
|
|||||||
//add distance to list so it can be processed
|
//add distance to list so it can be processed
|
||||||
var build = world.build(x, y);
|
var build = world.build(x, y);
|
||||||
|
|
||||||
if(build != null && build.team != b.team){
|
if(build != null && build.team != b.team && b.checkUnderBuild(build, x * tilesize, y * tilesize)){
|
||||||
distances.add(b.dst(build));
|
distances.add(b.dst(build));
|
||||||
|
|
||||||
if(b.type.laserAbsorb && build.absorbLasers()){
|
if(b.type.laserAbsorb && build.absorbLasers()){
|
||||||
@@ -233,7 +233,7 @@ public class Damage{
|
|||||||
|
|
||||||
Intc2 collider = (cx, cy) -> {
|
Intc2 collider = (cx, cy) -> {
|
||||||
Building tile = world.build(cx, cy);
|
Building tile = world.build(cx, cy);
|
||||||
boolean collide = tile != null && collidedBlocks.add(tile.pos());
|
boolean collide = tile != null && hitter.checkUnderBuild(tile, cx * tilesize, cy * tilesize) && collidedBlocks.add(tile.pos());
|
||||||
|
|
||||||
if(hitter.damage > 0){
|
if(hitter.damage > 0){
|
||||||
float health = !collide ? 0 : tile.health;
|
float health = !collide ? 0 : tile.health;
|
||||||
|
|||||||
@@ -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);
|
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.
|
//copy-paste of World#raycastEach, inlined for lambda capture performance.
|
||||||
@Override
|
@Override
|
||||||
public void tileRaycast(int x1, int y1, int x2, int y2){
|
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() &&
|
if(build != null && isAdded()
|
||||||
//should underBullet detection be disabled for piercing bullets?
|
&& checkUnderBuild(build, x, y)
|
||||||
//|| 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))
|
|
||||||
|
|
||||||
&& build.collide(self()) && type.testCollision(self(), build)
|
&& build.collide(self()) && type.testCollision(self(), build)
|
||||||
&& !build.dead() && (type.collidesTeam || build.team != team) && !(type.pierceBuilding && hasCollided(build.id))){
|
&& !build.dead() && (type.collidesTeam || build.team != team) && !(type.pierceBuilding && hasCollided(build.id))){
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user