Hard enforcement of unit cap

This commit is contained in:
Anuken
2020-07-22 13:27:54 -04:00
parent a4a3f6f8c5
commit b4594b2274
3 changed files with 19 additions and 0 deletions

View File

@@ -1764,6 +1764,7 @@ public class Blocks implements ContentList{
consumes.liquid(Liquids.cryofluid, 1f);
constructTime = 60f * 60f * 1.5f;
liquidCapacity = 30f;
upgrades = new UnitType[][]{
{UnitTypes.zenith, UnitTypes.antumbra},
@@ -1779,6 +1780,7 @@ public class Blocks implements ContentList{
consumes.liquid(Liquids.cryofluid, 3f);
constructTime = 60f * 60f * 4;
liquidCapacity = 60f;
upgrades = new UnitType[][]{
{UnitTypes.antumbra, UnitTypes.eclipse},

View File

@@ -38,6 +38,14 @@ public class Fx{
}),
unitCapKill = new Effect(80f, e -> {
color(Color.scarlet);
alpha(e.fout(Interp.pow4Out));
float size = 10f + e.fout(Interp.pow10In) * 25f;
Draw.rect(Icon.warning.getRegion(), e.x, e.y, size, size);
}),
unitControl = new Effect(30f, e -> {
if(!(e.data instanceof Unit)) return;

View File

@@ -148,6 +148,14 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override
public void add(){
teamIndex.updateCount(team, type, 1);
//check if over unit cap
if(teamIndex.countType(team, type) > Units.getCap(team)
&& !(team == state.rules.waveTeam && state.rules.waves) //can't be wave team on wave mode
&& !(state.isCampaign() && team == state.rules.waveTeam)){ //can't be campaign wave team
Fx.unitCapKill.at(this);
kill();
}
}
@Override
@@ -167,6 +175,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override
public void update(){
type.update(base());
drag = type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f);