Per-unit cap (still broken)
@@ -599,7 +599,7 @@ bar.poweramount = Power: {0}
|
|||||||
bar.poweroutput = Power Output: {0}
|
bar.poweroutput = Power Output: {0}
|
||||||
bar.items = Items: {0}
|
bar.items = Items: {0}
|
||||||
bar.capacity = Capacity: {0}
|
bar.capacity = Capacity: {0}
|
||||||
bar.units = Units: {0}/{1}
|
bar.unitcap = {0} {1}/{2}
|
||||||
bar.liquid = Liquid
|
bar.liquid = Liquid
|
||||||
bar.heat = Heat
|
bar.heat = Heat
|
||||||
bar.power = Power
|
bar.power = Power
|
||||||
|
|||||||
@@ -253,3 +253,28 @@
|
|||||||
63491=tetrative-reconstructor|block-tetrative-reconstructor-medium
|
63491=tetrative-reconstructor|block-tetrative-reconstructor-medium
|
||||||
63490=resupply-point|block-resupply-point-medium
|
63490=resupply-point|block-resupply-point-medium
|
||||||
63489=parallax|block-parallax-medium
|
63489=parallax|block-parallax-medium
|
||||||
|
63488=dagger|unit-dagger-medium
|
||||||
|
63487=mace|unit-mace-medium
|
||||||
|
63486=fortress|unit-fortress-medium
|
||||||
|
63485=nova|unit-nova-medium
|
||||||
|
63484=pulsar|unit-pulsar-medium
|
||||||
|
63483=quasar|unit-quasar-medium
|
||||||
|
63482=crawler|unit-crawler-medium
|
||||||
|
63481=atrax|unit-atrax-medium
|
||||||
|
63480=spiroct|unit-spiroct-medium
|
||||||
|
63479=arkyid|unit-arkyid-medium
|
||||||
|
63478=flare|unit-flare-medium
|
||||||
|
63477=horizon|unit-horizon-medium
|
||||||
|
63476=zenith|unit-zenith-medium
|
||||||
|
63475=antumbra|unit-antumbra-medium
|
||||||
|
63474=eclipse|unit-eclipse-medium
|
||||||
|
63473=mono|unit-mono-medium
|
||||||
|
63472=poly|unit-poly-medium
|
||||||
|
63471=mega|unit-mega-medium
|
||||||
|
63470=risse|unit-risse-medium
|
||||||
|
63469=minke|unit-minke-medium
|
||||||
|
63468=bryde|unit-bryde-medium
|
||||||
|
63467=alpha|unit-alpha-medium
|
||||||
|
63466=beta|unit-beta-medium
|
||||||
|
63465=gamma|unit-gamma-medium
|
||||||
|
63464=block|unit-block-medium
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1023 KiB After Width: | Height: | Size: 1023 KiB |
|
Before Width: | Height: | Size: 181 KiB After Width: | Height: | Size: 191 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.2 MiB |
@@ -4,6 +4,7 @@ import arc.math.geom.*;
|
|||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ import java.util.*;
|
|||||||
public class TeamIndexProcess implements AsyncProcess{
|
public class TeamIndexProcess implements AsyncProcess{
|
||||||
private QuadTree<Unit>[] trees = new QuadTree[Team.all.length];
|
private QuadTree<Unit>[] trees = new QuadTree[Team.all.length];
|
||||||
private int[] counts = new int[Team.all.length];
|
private int[] counts = new int[Team.all.length];
|
||||||
|
private int[][] typeCounts = new int[Team.all.length][0];
|
||||||
|
|
||||||
public QuadTree<Unit> tree(Team team){
|
public QuadTree<Unit> tree(Team team){
|
||||||
if(trees[team.id] == null) trees[team.id] = new QuadTree<>(Vars.world.getQuadBounds(new Rect()));
|
if(trees[team.id] == null) trees[team.id] = new QuadTree<>(Vars.world.getQuadBounds(new Rect()));
|
||||||
@@ -22,8 +24,18 @@ public class TeamIndexProcess implements AsyncProcess{
|
|||||||
return counts[team.id];
|
return counts[team.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCount(Team team, int amount){
|
public int countType(Team team, UnitType type){
|
||||||
|
return typeCounts[team.id].length < type.id ? 0 : typeCounts[team.id][type.id];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateCount(Team team, UnitType type, int amount){
|
||||||
|
int tid = type.id;
|
||||||
|
|
||||||
counts[team.id] += amount;
|
counts[team.id] += amount;
|
||||||
|
if(typeCounts[team.id].length < tid){
|
||||||
|
typeCounts[team.id] = new int[Vars.content.units().size];
|
||||||
|
}
|
||||||
|
typeCounts[team.id][tid] += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,13 +51,16 @@ public class TeamIndexProcess implements AsyncProcess{
|
|||||||
if(trees[team.id] != null){
|
if(trees[team.id] != null){
|
||||||
trees[team.id].clear();
|
trees[team.id].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Arrays.fill(typeCounts[team.id], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Arrays.fill(counts, 0);
|
Arrays.fill(counts, 0);
|
||||||
|
|
||||||
for(Unit unit : Groups.unit){
|
for(Unit unit : Groups.unit){
|
||||||
tree(unit.team).insert(unit);
|
tree(unit.team).insert(unit);
|
||||||
counts[unit.team.id] ++;
|
|
||||||
|
updateCount(unit.team, unit.type(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1284,6 +1284,8 @@ public class Blocks implements ContentList{
|
|||||||
health = 1100;
|
health = 1100;
|
||||||
itemCapacity = 4000;
|
itemCapacity = 4000;
|
||||||
size = 3;
|
size = 3;
|
||||||
|
|
||||||
|
unitCapModifier = 8;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
coreFoundation = new CoreBlock("core-foundation"){{
|
coreFoundation = new CoreBlock("core-foundation"){{
|
||||||
@@ -1293,6 +1295,8 @@ public class Blocks implements ContentList{
|
|||||||
health = 2000;
|
health = 2000;
|
||||||
itemCapacity = 9000;
|
itemCapacity = 9000;
|
||||||
size = 4;
|
size = 4;
|
||||||
|
|
||||||
|
unitCapModifier = 16;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
coreNucleus = new CoreBlock("core-nucleus"){{
|
coreNucleus = new CoreBlock("core-nucleus"){{
|
||||||
@@ -1302,6 +1306,8 @@ public class Blocks implements ContentList{
|
|||||||
health = 4000;
|
health = 4000;
|
||||||
itemCapacity = 13000;
|
itemCapacity = 13000;
|
||||||
size = 5;
|
size = 5;
|
||||||
|
|
||||||
|
unitCapModifier = 24;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
vault = new StorageBlock("vault"){{
|
vault = new StorageBlock("vault"){{
|
||||||
@@ -1411,7 +1417,6 @@ public class Blocks implements ContentList{
|
|||||||
Liquids.cryofluid, Bullets.cryoShot,
|
Liquids.cryofluid, Bullets.cryoShot,
|
||||||
Liquids.oil, Bullets.oilShot
|
Liquids.oil, Bullets.oilShot
|
||||||
);
|
);
|
||||||
targetAir = false;
|
|
||||||
size = 2;
|
size = 2;
|
||||||
recoilAmount = 0f;
|
recoilAmount = 0f;
|
||||||
reloadTime = 2f;
|
reloadTime = 2f;
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ public class UnitTypes implements ContentList{
|
|||||||
despawnEffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
width = 0.54f;
|
width = 0.54f;
|
||||||
lifetime = 35f;
|
lifetime = 35f;
|
||||||
knockback = -1f;
|
knockback = -1.2f;
|
||||||
}};
|
}};
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ public class UnitTypes implements ContentList{
|
|||||||
despawnEffect = Fx.none;
|
despawnEffect = Fx.none;
|
||||||
width = 0.4f;
|
width = 0.4f;
|
||||||
lifetime = 25f;
|
lifetime = 25f;
|
||||||
knockback = -0.5f;
|
knockback = -0.6f;
|
||||||
}};
|
}};
|
||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
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. */
|
/** @return whether a new instance of a unit of this team can be created. */
|
||||||
public static boolean canCreate(Team team){
|
public static boolean canCreate(Team team, UnitType type){
|
||||||
return teamIndex.count(team) < getCap(team);
|
return teamIndex.countType(team, type) < getCap(team);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCap(Team team){
|
public static int getCap(Team team){
|
||||||
|
|||||||
@@ -147,12 +147,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(){
|
public void add(){
|
||||||
teamIndex.updateCount(team, 1);
|
teamIndex.updateCount(team, type, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(){
|
public void remove(){
|
||||||
teamIndex.updateCount(team, -1);
|
teamIndex.updateCount(team, type, -1);
|
||||||
controller.removed(base());
|
controller.removed(base());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import java.util.*;
|
|||||||
|
|
||||||
public class Fonts{
|
public class Fonts{
|
||||||
private static ObjectIntMap<String> unicodeIcons = new ObjectIntMap<>();
|
private static ObjectIntMap<String> unicodeIcons = new ObjectIntMap<>();
|
||||||
|
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
|
||||||
|
|
||||||
public static BitmapFont def;
|
public static BitmapFont def;
|
||||||
public static BitmapFont outline;
|
public static BitmapFont outline;
|
||||||
@@ -39,6 +40,10 @@ public class Fonts{
|
|||||||
return unicodeIcons.get(content, 0);
|
return unicodeIcons.get(content, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUnicodeStr(String content){
|
||||||
|
return stringIcons.get(content, "");
|
||||||
|
}
|
||||||
|
|
||||||
/** Called from a static context to make the cursor appear immediately upon startup.*/
|
/** Called from a static context to make the cursor appear immediately upon startup.*/
|
||||||
public static void loadSystemCursors(){
|
public static void loadSystemCursors(){
|
||||||
SystemCursor.arrow.set(Core.graphics.newCursor("cursor", cursorScale()));
|
SystemCursor.arrow.set(Core.graphics.newCursor("cursor", cursorScale()));
|
||||||
@@ -86,6 +91,7 @@ public class Fonts{
|
|||||||
}
|
}
|
||||||
|
|
||||||
unicodeIcons.put(nametex[0], ch);
|
unicodeIcons.put(nametex[0], ch);
|
||||||
|
stringIcons.put(nametex[0], ((char)ch) + "");
|
||||||
|
|
||||||
Glyph glyph = new Glyph();
|
Glyph glyph = new Glyph();
|
||||||
glyph.id = ch;
|
glyph.id = ch;
|
||||||
|
|||||||
@@ -81,13 +81,6 @@ public class CoreBlock extends StorageBlock{
|
|||||||
() -> Pal.items,
|
() -> Pal.items,
|
||||||
() -> e.items.total() / ((float)e.storageCapacity * content.items().count(i -> i.unlockedNow()))
|
() -> e.items.total() / ((float)e.storageCapacity * content.items().count(i -> i.unlockedNow()))
|
||||||
));
|
));
|
||||||
|
|
||||||
bars.add("units", e ->
|
|
||||||
new Bar(
|
|
||||||
() -> Core.bundle.format("bar.units", teamIndex.count(e.team()), Units.getCap(e.team())),
|
|
||||||
() -> Pal.power,
|
|
||||||
() -> (float)teamIndex.count(e.team()) / Units.getCap(e.team())
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.world.blocks.units;
|
package mindustry.world.blocks.units;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
@@ -7,6 +8,7 @@ import arc.scene.style.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
@@ -20,6 +22,8 @@ import mindustry.world.blocks.payloads.*;
|
|||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class UnitFactory extends UnitBlock{
|
public class UnitFactory extends UnitBlock{
|
||||||
public int[] capacities;
|
public int[] capacities;
|
||||||
|
|
||||||
@@ -61,7 +65,19 @@ public class UnitFactory extends UnitBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void setBars(){
|
public void setBars(){
|
||||||
super.setBars();
|
super.setBars();
|
||||||
bars.add("progress", (UnitFactoryEntity entity) -> new Bar("bar.progress", Pal.ammo, entity::fraction));
|
bars.add("progress", (UnitFactoryEntity e) -> new Bar("bar.progress", Pal.ammo, e::fraction));
|
||||||
|
|
||||||
|
bars.add("units", (UnitFactoryEntity e) ->
|
||||||
|
new Bar(
|
||||||
|
() -> e.unit() == null ? "[lightgray]" + Iconc.cancel :
|
||||||
|
Core.bundle.format("bar.unitcap",
|
||||||
|
Fonts.getUnicodeStr(e.unit().name),
|
||||||
|
teamIndex.countType(e.team, e.unit()),
|
||||||
|
Units.getCap(e.team)
|
||||||
|
),
|
||||||
|
() -> Pal.power,
|
||||||
|
() -> e.unit() == null ? 0f : (float)teamIndex.countType(e.team, e.unit()) / Units.getCap(e.team)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,13 +145,14 @@ public class UnitFactory extends UnitBlock{
|
|||||||
|
|
||||||
table.row();
|
table.row();
|
||||||
table.table(t -> {
|
table.table(t -> {
|
||||||
|
t.left();
|
||||||
t.image().update(i -> {
|
t.image().update(i -> {
|
||||||
i.setDrawable(currentPlan == -1 ? Icon.cancel : reg.set(plans[currentPlan].unit.icon(Cicon.medium)));
|
i.setDrawable(currentPlan == -1 ? Icon.cancel : reg.set(plans[currentPlan].unit.icon(Cicon.medium)));
|
||||||
i.setScaling(Scaling.fit);
|
i.setScaling(Scaling.fit);
|
||||||
i.setColor(currentPlan == -1 ? Color.lightGray : Color.white);
|
i.setColor(currentPlan == -1 ? Color.lightGray : Color.white);
|
||||||
}).size(32).padBottom(-4).padRight(2);
|
}).size(32).padBottom(-4).padRight(2);
|
||||||
t.label(() -> currentPlan == -1 ? "$none" : plans[currentPlan].unit.localizedName).color(Color.lightGray);
|
t.label(() -> currentPlan == -1 ? "$none" : plans[currentPlan].unit.localizedName).color(Color.lightGray);
|
||||||
});
|
}).left();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -182,7 +199,7 @@ public class UnitFactory extends UnitBlock{
|
|||||||
if(currentPlan != -1 && payload == null){
|
if(currentPlan != -1 && payload == null){
|
||||||
UnitPlan plan = plans[currentPlan];
|
UnitPlan plan = plans[currentPlan];
|
||||||
|
|
||||||
if(progress >= plan.time && Units.canCreate(team)){
|
if(progress >= plan.time && consValid()){
|
||||||
progress = 0f;
|
progress = 0f;
|
||||||
|
|
||||||
payload = new UnitPayload(plan.unit.create(team));
|
payload = new UnitPayload(plan.unit.create(team));
|
||||||
@@ -196,6 +213,15 @@ public class UnitFactory extends UnitBlock{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldConsume(){
|
||||||
|
//do not consume when cap reached
|
||||||
|
if(currentPlan != -1 && !Units.canCreate(team, plans[currentPlan].unit)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.shouldConsume();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaximumAccepted(Item item){
|
public int getMaximumAccepted(Item item){
|
||||||
return capacities[item.id];
|
return capacities[item.id];
|
||||||
@@ -207,6 +233,10 @@ public class UnitFactory extends UnitBlock{
|
|||||||
Structs.contains(plans[currentPlan].requirements, stack -> stack.item == item);
|
Structs.contains(plans[currentPlan].requirements, stack -> stack.item == item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable UnitType unit(){
|
||||||
|
return currentPlan == - 1 ? null : plans[currentPlan].unit;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte version(){
|
public byte version(){
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -381,7 +381,12 @@ public class Generators{
|
|||||||
wrecks[i].save(type.name + "-wreck" + i);
|
wrecks[i].save(type.name + "-wreck" + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO GENERATE WRECKS
|
for(Cicon icon : Cicon.scaled){
|
||||||
|
Image scaled = new Image(icon.size, icon.size);
|
||||||
|
scaled.drawScaled(image);
|
||||||
|
scaled.save("../ui/unit-" + type.name + "-" + icon.name());
|
||||||
|
}
|
||||||
|
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
Log.err("WARNING: Skipping unit @: @", type.name, e.getMessage());
|
Log.err("WARNING: Skipping unit @: @", type.name, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import mindustry.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ public class ImagePacker{
|
|||||||
ObjectMap<String, String> content2id = new ObjectMap<>();
|
ObjectMap<String, String> content2id = new ObjectMap<>();
|
||||||
map.each((key, val) -> content2id.put(val.split("\\|")[0], key));
|
map.each((key, val) -> content2id.put(val.split("\\|")[0], key));
|
||||||
|
|
||||||
Seq<UnlockableContent> cont = Seq.withArrays(Vars.content.blocks(), Vars.content.items(), Vars.content.liquids());
|
Seq<UnlockableContent> cont = Seq.withArrays(Vars.content.blocks(), Vars.content.items(), Vars.content.liquids(), Vars.content.units());
|
||||||
cont.removeAll(u -> u instanceof BuildBlock || u == Blocks.air);
|
cont.removeAll(u -> u instanceof BuildBlock || u == Blocks.air);
|
||||||
|
|
||||||
int minid = 0xF8FF;
|
int minid = 0xF8FF;
|
||||||
@@ -146,6 +147,7 @@ public class ImagePacker{
|
|||||||
|
|
||||||
static String texname(UnlockableContent c){
|
static String texname(UnlockableContent c){
|
||||||
if(c instanceof Block) return "block-" + c.name + "-medium";
|
if(c instanceof Block) return "block-" + c.name + "-medium";
|
||||||
|
if(c instanceof UnitType) return "unit-" + c.name + "-medium";
|
||||||
return c.getContentType() + "-" + c.name + "-icon";
|
return c.getContentType() + "-" + c.name + "-icon";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||