diff --git a/core/src/mindustry/type/ItemSeq.java b/core/src/mindustry/type/ItemSeq.java index 512033af23..64603d8a8d 100644 --- a/core/src/mindustry/type/ItemSeq.java +++ b/core/src/mindustry/type/ItemSeq.java @@ -55,6 +55,12 @@ public class ItemSeq implements Iterable, Serializable{ return out; } + public void min(int number){ + for(Item item : Vars.content.items()){ + set(item, Math.min(get(item), number)); + } + } + public boolean has(Item item){ return values[item.id] > 0; } diff --git a/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java b/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java index 9f03ba3532..3ddd74e588 100644 --- a/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java +++ b/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java @@ -42,6 +42,13 @@ public class LaunchLoadoutDialog extends BaseDialog{ //updates sum requirements Runnable update = () -> { + int cap = selected.findCore().itemCapacity; + + //cap resources based on core type + ItemSeq resources = universe.getLaunchResources(); + resources.min(cap); + universe.updateLaunchResources(resources); + total.clear(); selected.requirements().each(total::add); universe.getLaunchResources().each(total::add); @@ -79,7 +86,7 @@ public class LaunchLoadoutDialog extends BaseDialog{ ItemSeq stacks = universe.getLaunchResources(); Seq out = stacks.toSeq(); - loadout.show(core.itemCapacity, out, UnlockableContent::unlocked, out::clear, () -> {}, () -> { + loadout.show(selected.findCore().itemCapacity, out, UnlockableContent::unlocked, out::clear, () -> {}, () -> { universe.updateLaunchResources(new ItemSeq(out)); update.run(); rebuildItems.run();