Polar Aerodrome sector submission / Shields absorb unit wrecks
This commit is contained in:
9
core/src/mindustry/world/blocks/UnitWreckShield.java
Normal file
9
core/src/mindustry/world/blocks/UnitWreckShield.java
Normal file
@@ -0,0 +1,9 @@
|
||||
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);
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
@@ -68,6 +69,7 @@ public class ForceProjector extends Block{
|
||||
envEnabled |= Env.space;
|
||||
ambientSound = Sounds.shield;
|
||||
ambientSoundVolume = 0.08f;
|
||||
flags = EnumSet.of(BlockFlag.shield);
|
||||
|
||||
if(consumeCoolant){
|
||||
consume(coolantConsumer = new ConsumeCoolant(coolantConsumption)).boost().update(false);
|
||||
@@ -120,7 +122,7 @@ public class ForceProjector extends Block{
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
public class ForceBuild extends Building implements Ranged{
|
||||
public class ForceBuild extends Building implements Ranged, UnitWreckShield{
|
||||
public boolean broken = true;
|
||||
public float buildup, radscl, hit, warmup, phaseHeat;
|
||||
|
||||
@@ -214,6 +216,17 @@ 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);
|
||||
if(absorb){
|
||||
absorbEffect.at(unit);
|
||||
hit = 1f;
|
||||
buildup += damage;
|
||||
}
|
||||
return absorb;
|
||||
}
|
||||
|
||||
public float realRadius(){
|
||||
return (radius + phaseHeat * phaseRadiusBoost) * radscl;
|
||||
}
|
||||
@@ -238,7 +251,7 @@ public class ForceProjector extends Block{
|
||||
Draw.z(Layer.block);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
|
||||
drawShield();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ public enum BlockFlag{
|
||||
extinguisher,
|
||||
/** Is a drill. */
|
||||
drill,
|
||||
/** Force projector block. */
|
||||
shield,
|
||||
|
||||
//special, internal identifiers
|
||||
launchPad,
|
||||
@@ -32,5 +34,5 @@ public enum BlockFlag{
|
||||
public final static BlockFlag[] all = values();
|
||||
|
||||
/** Values for logic only. Filters out some internal flags. */
|
||||
public final static BlockFlag[] allLogic = {core, storage, generator, turret, factory, repair, battery, reactor, drill};
|
||||
public final static BlockFlag[] allLogic = {core, storage, generator, turret, factory, repair, battery, reactor, drill, shield};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user