Per-unit cap (still broken)
This commit is contained in:
@@ -6,6 +6,7 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@@ -29,8 +30,8 @@ public class Units{
|
||||
}
|
||||
|
||||
/** @return whether a new instance of a unit of this team can be created. */
|
||||
public static boolean canCreate(Team team){
|
||||
return teamIndex.count(team) < getCap(team);
|
||||
public static boolean canCreate(Team team, UnitType type){
|
||||
return teamIndex.countType(team, type) < getCap(team);
|
||||
}
|
||||
|
||||
public static int getCap(Team team){
|
||||
|
||||
@@ -147,12 +147,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
@Override
|
||||
public void add(){
|
||||
teamIndex.updateCount(team, 1);
|
||||
teamIndex.updateCount(team, type, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(){
|
||||
teamIndex.updateCount(team, -1);
|
||||
teamIndex.updateCount(team, type, -1);
|
||||
controller.removed(base());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user