Possible building raycast damage fix

This commit is contained in:
Anuken 2024-04-21 10:46:50 -04:00
parent a7a9a99780
commit 430114d931

View File

@ -175,21 +175,23 @@ public class Damage{
distances.clear(); distances.clear();
World.raycast(b.tileX(), b.tileY(), World.toTile(b.x + vec.x), World.toTile(b.y + vec.y), (x, y) -> { if(b.type.collidesGround && b.type.collidesTiles){
//add distance to list so it can be processed World.raycast(b.tileX(), b.tileY(), World.toTile(b.x + vec.x), World.toTile(b.y + vec.y), (x, y) -> {
var build = world.build(x, y); //add distance to list so it can be processed
var build = world.build(x, y);
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(laser && build.absorbLasers()){ if(laser && build.absorbLasers()){
maxDst = Math.min(maxDst, b.dst(build)); maxDst = Math.min(maxDst, b.dst(build));
return true; return true;
}
} }
}
return false; return false;
}); });
}
Units.nearbyEnemies(b.team, rect, u -> { Units.nearbyEnemies(b.team, rect, u -> {
u.hitbox(hitrect); u.hitbox(hitrect);
@ -247,7 +249,7 @@ public class Damage{
collidedBlocks.clear(); collidedBlocks.clear();
vec.trnsExact(angle, length); vec.trnsExact(angle, length);
if(hitter.type.collidesGround){ if(hitter.type.collidesGround && hitter.type.collidesTiles){
seg1.set(x, y); seg1.set(x, y);
seg2.set(seg1).add(vec); seg2.set(seg1).add(vec);
World.raycastEachWorld(x, y, seg2.x, seg2.y, (cx, cy) -> { World.raycastEachWorld(x, y, seg2.x, seg2.y, (cx, cy) -> {