Fixed shields not blocking blast compound explosions

This commit is contained in:
Anuken
2024-09-15 19:21:24 -04:00
parent 9911e602a0
commit 8ede0fa6f4
7 changed files with 27 additions and 22 deletions

View File

@@ -0,0 +1,7 @@
package mindustry.world.blocks;
//TODO: horrible API design, but I'm not sure of a better way to do this right now. please don't use this class
public interface ExplosionShield{
/** @return whether the shield was able to absorb the explosion; this should apply damage to the shield if true is returned. */
boolean absorbExplosion(float x, float y, float damage);
}

View File

@@ -1,9 +0,0 @@
package mindustry.world.blocks;
import mindustry.gen.*;
//TODO: horrible API design, but I'm not sure of a better way to do this right now. please don't use this class
public interface UnitWreckShield{
/** @return whether the shield was able to absorb the unit wreck; this should apply damage to the shield if true is returned. */
boolean absorbWreck(Unit unit, float damage);
}

View File

@@ -40,7 +40,7 @@ public class ForceProjector extends Block{
public float cooldownBrokenBase = 0.35f;
public float coolantConsumption = 0.1f;
public boolean consumeCoolant = true;
public float crashDamageMultiplier = 2.5f;
public float crashDamageMultiplier = 2f;
public Effect absorbEffect = Fx.absorb;
public Effect shieldBreakEffect = Fx.shieldBreak;
public @Load("@-top") TextureRegion topRegion;
@@ -123,7 +123,7 @@ public class ForceProjector extends Block{
Draw.color();
}
public class ForceBuild extends Building implements Ranged, UnitWreckShield{
public class ForceBuild extends Building implements Ranged, ExplosionShield{
public boolean broken = true;
public float buildup, radscl, hit, warmup, phaseHeat;
@@ -218,10 +218,10 @@ public class ForceProjector extends Block{
}
@Override
public boolean absorbWreck(Unit unit, float damage){
boolean absorb = !broken && Intersector.isInRegularPolygon(sides, x, y, realRadius(), shieldRotation, unit.x, unit.y);
public boolean absorbExplosion(float ex, float ey, float damage){
boolean absorb = !broken && Intersector.isInRegularPolygon(sides, x, y, realRadius(), shieldRotation, ex, ey);
if(absorb){
absorbEffect.at(unit);
absorbEffect.at(ex, ey);
hit = 1f;
buildup += damage * crashDamageMultiplier;
}