Files
Mindustry/core/src/mindustry/entities/abilities/SpawnDeathAbility.java
MEEPofFaith 2fb5bc56c6 Better Ability Stats (#9654)
* Fix armor plate multiplier + change Math.round to Strings.autoFixed

* Missing ability name bundles

* Center ability name

* SuppressionFieldAbility stats

* Is two per row is acceptable?

I can revert this commit if not.

* LiquidExplodeAbility stat display

* MoveLightningAbility stat display

* Better SpawnDeathAbility display

* Fix multiplier coloring inconsistencies

Some had [lightgray] before %/x, some had it after

* Consistent content name display

Match with bullet status effects

* Consistent stat formatting

Convert from some being "stat: #" and some being "# stat" to all being "# stat"

* Re-order stats

* Optimize Imports

* Add ability descriptions

* Apparently I forgot LiquidRegenAbility

* Mention healing allies if displayHeal = true
2024-03-30 00:11:39 -04:00

47 lines
1.4 KiB
Java

package mindustry.entities.abilities;
import arc.math.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.*;
import mindustry.gen.*;
import mindustry.type.*;
/** Spawns a certain amount of units upon death. */
public class SpawnDeathAbility extends Ability{
public UnitType unit;
public int amount = 1, randAmount = 0;
/** Random spread of units away from the spawned. */
public float spread = 8f;
/** If true, units spawned face outwards from the middle. */
public boolean faceOutwards = true;
public SpawnDeathAbility(UnitType unit, int amount, float spread){
this.unit = unit;
this.amount = amount;
this.spread = spread;
}
public SpawnDeathAbility(){
}
@Override
public void addStats(Table t){
super.addStats(t);
t.add("[stat]" + (randAmount > 0 ? amount + "x-" + (amount + randAmount) : amount) + "x[] " + (unit.hasEmoji() ? unit.emoji() : "") + "[stat]" + unit.localizedName);
}
@Override
public void death(Unit unit){
if(!Vars.net.client()){
int spawned = amount + Mathf.random(randAmount);
for(int i = 0; i < spawned; i++){
Tmp.v1.rnd(Mathf.random(spread));
var u = this.unit.spawn(unit.team, unit.x + Tmp.v1.x, unit.y + Tmp.v1.y);
u.rotation = faceOutwards ? Tmp.v1.angle() : unit.rotation + Mathf.range(5f);
}
}
}
}