Regen suppression unit + system
This commit is contained in:
@@ -65,6 +65,19 @@ public class MendProjector extends Block{
|
||||
indexer.eachBlock(player.team(), x * tilesize + offset, y * tilesize + offset, range, other -> true, other -> Drawf.selected(other, Tmp.c1.set(baseColor).a(Mathf.absin(4f, 1f))));
|
||||
}
|
||||
|
||||
/** @return whether a building has regen/healing suppressed; if so, spawns particles on it. */
|
||||
public static boolean checkSuppression(Building build){
|
||||
if(build.isHealSuppressed()){
|
||||
if(Mathf.chanceDelta(0.04)){
|
||||
Fx.regenSuppressParticle.at(build.x + Mathf.range(build.block.size * tilesize/2f - 1f), build.y + Mathf.range(build.block.size * tilesize/2f - 1f));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public class MendBuild extends Building implements Ranged{
|
||||
public float heat, charge = Mathf.random(reload), phaseHeat, smoothEfficiency;
|
||||
|
||||
@@ -75,21 +88,23 @@ public class MendProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
boolean canHeal = !checkSuppression(this);
|
||||
|
||||
smoothEfficiency = Mathf.lerpDelta(smoothEfficiency, efficiency(), 0.08f);
|
||||
heat = Mathf.lerpDelta(heat, consValid() || cheating() ? 1f : 0f, 0.08f);
|
||||
heat = Mathf.lerpDelta(heat, consValid() && canHeal ? 1f : 0f, 0.08f);
|
||||
charge += heat * delta();
|
||||
|
||||
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons.optionalValid()), 0.1f);
|
||||
|
||||
if(cons.optionalValid() && timer(timerUse, useTime) && efficiency() > 0){
|
||||
if(cons.optionalValid() && timer(timerUse, useTime) && efficiency() > 0 && canHeal){
|
||||
consume();
|
||||
}
|
||||
|
||||
if(charge >= reload){
|
||||
if(charge >= reload && canHeal){
|
||||
float realRange = range + phaseHeat * phaseRangeBoost;
|
||||
charge = 0f;
|
||||
|
||||
indexer.eachBlock(this, realRange, Building::damaged, other -> {
|
||||
indexer.eachBlock(this, realRange, b -> b.damaged() && !b.isHealSuppressed(), other -> {
|
||||
other.heal(other.maxHealth() * (healPercent + phaseHeat * phaseBoost) / 100f * efficiency());
|
||||
Fx.healBlockFull.at(other.x, other.y, other.block.size, baseColor);
|
||||
});
|
||||
|
||||
@@ -85,6 +85,8 @@ public class RegenProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
//TODO particles when heal suppressed
|
||||
|
||||
if(lastChange != world.tileChanges){
|
||||
lastChange = world.tileChanges;
|
||||
updateTargets();
|
||||
@@ -95,10 +97,15 @@ public class RegenProjector extends Block{
|
||||
totalTime += warmup * Time.delta;
|
||||
didRegen = false;
|
||||
|
||||
//no healing when suppressed
|
||||
if(MendProjector.checkSuppression(this)){
|
||||
return;
|
||||
}
|
||||
|
||||
if(consValid()){
|
||||
//use Math.max to prevent stacking
|
||||
for(Building build : targets){
|
||||
if(!build.damaged()) continue;
|
||||
if(!build.damaged() || build.isHealSuppressed()) continue;
|
||||
|
||||
didRegen = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user