diff --git a/core/src/mindustry/content/TechTree.java b/core/src/mindustry/content/TechTree.java index 01a317b317..34af38b1f2 100644 --- a/core/src/mindustry/content/TechTree.java +++ b/core/src/mindustry/content/TechTree.java @@ -263,7 +263,7 @@ public class TechTree implements ContentList{ node(steamGenerator, () -> { node(thermalGenerator, () -> { node(differentialGenerator, () -> { - node(thoriumReactor, () -> { + node(thoriumReactor, Seq.with(new Research(Liquids.cryofluid)), () -> { node(impactReactor, () -> { }); diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 63ed6b5e20..bc02d7720d 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -265,7 +265,7 @@ public class UnitTypes implements ContentList{ itemCapacity = 60; canBoost = true; boostMultiplier = 1.5f; - speed = 0.52f; + speed = 0.55f; hitsize = 8f; health = 110f; buildSpeed = 0.8f; @@ -291,7 +291,7 @@ public class UnitTypes implements ContentList{ itemCapacity = 60; canBoost = true; boostMultiplier = 1.5f; - speed = 0.62f; + speed = 0.65f; hitsize = 10f; health = 320f; buildSpeed = 0.9f; diff --git a/core/src/mindustry/entities/comp/WeaponsComp.java b/core/src/mindustry/entities/comp/WeaponsComp.java index f6e794132a..a2e59c3ba6 100644 --- a/core/src/mindustry/entities/comp/WeaponsComp.java +++ b/core/src/mindustry/entities/comp/WeaponsComp.java @@ -106,7 +106,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc, Statusc{ if(!mount.bullet.isAdded() || mount.bullet.time >= mount.bullet.lifetime){ mount.bullet = null; }else{ - mount.bullet.rotation(shootAngle); + mount.bullet.rotation(weaponRotation + 90); mount.bullet.set(shootX, shootY); vel.add(Tmp.v1.trns(rotation + 180f, mount.bullet.type.recoil)); } diff --git a/core/src/mindustry/game/Schematic.java b/core/src/mindustry/game/Schematic.java index 334d96cc08..5ad51382f2 100644 --- a/core/src/mindustry/game/Schematic.java +++ b/core/src/mindustry/game/Schematic.java @@ -2,9 +2,7 @@ package mindustry.game; import arc.files.*; import arc.struct.*; -import arc.struct.IntIntMap.*; import arc.util.ArcAnnotate.*; -import mindustry.*; import mindustry.content.*; import mindustry.mod.Mods.*; import mindustry.type.*; @@ -38,20 +36,16 @@ public class Schematic implements Publishable, Comparable{ return tiles.sumf(s -> s.block.consumes.has(ConsumeType.power) ? s.block.consumes.getPower().usage : 0f); } - public Seq requirements(){ - IntIntMap amounts = new IntIntMap(); + public ItemSeq requirements(){ + ItemSeq requirements = new ItemSeq(); tiles.each(t -> { for(ItemStack stack : t.block.requirements){ - amounts.increment(stack.item.id, stack.amount); + requirements.add(stack.item, stack.amount); } }); - Seq stacks = new Seq<>(); - for(Entry ent : amounts.entries()){ - stacks.add(new ItemStack(Vars.content.item(ent.key), ent.value)); - } - stacks.sort(); - return stacks; + + return requirements; } public boolean hasCore(){ diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index cb3cf1de19..7a9cc395a6 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -20,7 +20,7 @@ public class Universe{ private int turn; private Schematic lastLoadout; - private Seq lastLaunchResources = new Seq<>(); + private ItemSeq lastLaunchResources = new ItemSeq(); public Universe(){ load(); @@ -104,14 +104,14 @@ public class Universe{ } } - public Seq getLaunchResources(){ - lastLaunchResources = Core.settings.getJson("launch-resources", Seq.class, ItemStack.class, Seq::new); + public ItemSeq getLaunchResources(){ + lastLaunchResources = Core.settings.getJson("launch-resources-seq", ItemSeq.class, ItemSeq::new); return lastLaunchResources; } - public void updateLaunchResources(Seq stacks){ + public void updateLaunchResources(ItemSeq stacks){ this.lastLaunchResources = stacks; - Core.settings.putJson("launch-resources", ItemStack.class, lastLaunchResources); + Core.settings.putJson("launch-resources-seq", lastLaunchResources); } /** Updates selected loadout for future deployment. */ diff --git a/core/src/mindustry/type/ItemSeq.java b/core/src/mindustry/type/ItemSeq.java index 018d77a10f..9926e1d3b9 100644 --- a/core/src/mindustry/type/ItemSeq.java +++ b/core/src/mindustry/type/ItemSeq.java @@ -11,11 +11,14 @@ import mindustry.world.modules.ItemModule.*; import java.util.*; public class ItemSeq implements Iterable, Serializable{ - protected final int[] values; + protected final int[] values = new int[Vars.content.items().size]; public int total; public ItemSeq(){ - values = new int[Vars.content.items().size]; + } + + public ItemSeq(Seq stacks){ + stacks.each(this::add); } public void each(ItemConsumer cons){ @@ -26,6 +29,11 @@ public class ItemSeq implements Iterable, Serializable{ } } + public void clear(){ + total = 0; + Arrays.fill(values, 0); + } + public Seq toSeq(){ Seq out = new Seq<>(); for(int i = 0; i < values.length; i++){ diff --git a/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java b/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java index 9634777ab9..acb240d7c9 100644 --- a/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java +++ b/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java @@ -18,10 +18,8 @@ import static mindustry.Vars.*; /** Dialog for selecting loadout at sector launch. */ public class LaunchLoadoutDialog extends BaseDialog{ LoadoutDialog loadout = new LoadoutDialog(); - //total as a map - ObjectIntMap totalMap = new ObjectIntMap<>(); //total required items - Seq total = new Seq<>(); + ItemSeq total = new ItemSeq(); //currently selected schematic Schematic selected; //validity of loadout items @@ -34,21 +32,14 @@ public class LaunchLoadoutDialog extends BaseDialog{ public void show(CoreBlock core, Building build, Runnable confirm){ cont.clear(); buttons.clear(); - totalMap.clear(); - - Seq stacks = universe.getLaunchResources(); addCloseButton(); //updates sum requirements Runnable update = () -> { - totalMap.clear(); total.clear(); - selected.requirements().each(i -> totalMap.increment(i.item, i.amount)); - universe.getLaunchResources().each(i -> totalMap.increment(i.item, i.amount)); - for(Item item : content.items()){ - if(totalMap.containsKey(item)) total.add(new ItemStack(item, totalMap.get(item))); - } + selected.requirements().each(total::add); + universe.getLaunchResources().each(total::add); valid = build.items.has(total); }; @@ -56,10 +47,18 @@ public class LaunchLoadoutDialog extends BaseDialog{ table.clearChildren(); int i = 0; + ItemSeq schems = selected.requirements(); + ItemSeq launches = universe.getLaunchResources(); + for(ItemStack s : total){ table.image(s.item.icon(Cicon.small)).left(); - table.add((build.items.has(s.item, s.amount)) ? "[lightgray]" + s.amount + "" : - "[scarlet]" + (Math.min(build.items.get(s.item), s.amount) + "[lightgray]/" + s.amount)).padLeft(2).left().padRight(4); + int as = schems.get(s.item), al = launches.get(s.item); + + String amountStr = "[lightgray]" + (al + " + [accent]" + as + "[lightgray]"); + + table.add( + build.items.has(s.item, s.amount) ? amountStr : + "[scarlet]" + (Math.min(build.items.get(s.item), s.amount) + "[lightgray]/" + amountStr)).padLeft(2).left().padRight(4); if(++i % 4 == 0){ table.row(); @@ -72,8 +71,11 @@ public class LaunchLoadoutDialog extends BaseDialog{ Runnable rebuildItems = () -> rebuild.get(items); buttons.button("@resources", Icon.terrain, () -> { - loadout.show(core.itemCapacity, stacks, UnlockableContent::unlocked, stacks::clear, () -> {}, () -> { - universe.updateLaunchResources(stacks); + ItemSeq stacks = universe.getLaunchResources(); + Seq out = stacks.toSeq(); + + loadout.show(core.itemCapacity, out, UnlockableContent::unlocked, out::clear, () -> {}, () -> { + universe.updateLaunchResources(new ItemSeq(out)); update.run(); rebuildItems.run(); }); diff --git a/core/src/mindustry/ui/dialogs/LoadoutDialog.java b/core/src/mindustry/ui/dialogs/LoadoutDialog.java index eb0182ee2a..d818f5ecda 100644 --- a/core/src/mindustry/ui/dialogs/LoadoutDialog.java +++ b/core/src/mindustry/ui/dialogs/LoadoutDialog.java @@ -16,6 +16,7 @@ public class LoadoutDialog extends BaseDialog{ private Runnable hider; private Runnable resetter; private Runnable updater; + //TODO use itemseqs private Seq stacks = new Seq<>(); private Seq originalStacks = new Seq<>(); private Boolf validator = i -> true; diff --git a/core/src/mindustry/ui/dialogs/SchematicsDialog.java b/core/src/mindustry/ui/dialogs/SchematicsDialog.java index 3d920d1f14..2aa5ef3595 100644 --- a/core/src/mindustry/ui/dialogs/SchematicsDialog.java +++ b/core/src/mindustry/ui/dialogs/SchematicsDialog.java @@ -10,7 +10,6 @@ import arc.scene.ui.*; import arc.scene.ui.ImageButton.*; import arc.scene.ui.TextButton.*; import arc.scene.ui.layout.*; -import arc.struct.*; import arc.util.*; import mindustry.game.*; import mindustry.gen.*; @@ -333,7 +332,7 @@ public class SchematicsDialog extends BaseDialog{ cont.add(new SchematicImage(schem)).maxSize(800f); cont.row(); - Seq arr = schem.requirements(); + ItemSeq arr = schem.requirements(); cont.table(r -> { int i = 0; for(ItemStack s : arr){ diff --git a/core/src/mindustry/world/blocks/campaign/LaunchPad.java b/core/src/mindustry/world/blocks/campaign/LaunchPad.java index efbd2485a2..4b1719c7cf 100644 --- a/core/src/mindustry/world/blocks/campaign/LaunchPad.java +++ b/core/src/mindustry/world/blocks/campaign/LaunchPad.java @@ -180,18 +180,26 @@ public class LaunchPad extends Block{ Sector destsec = !net.client() ? state.secinfo.origin : state.rules.sector.planet.sectors.find(Sector::hasBase); //actually launch the items upon removal - if(team() == state.rules.defaultTeam && destsec != null){ - ItemSeq dest = destsec.getExtraItems(); + if(team() == state.rules.defaultTeam){ + if(destsec != null && (destsec != state.rules.sector || net.client())){ + ItemSeq dest = destsec.getExtraItems(); - for(ItemStack stack : stacks){ - dest.add(stack); + for(ItemStack stack : stacks){ + dest.add(stack); - //update export - state.secinfo.handleItemExport(stack); - Events.fire(new LaunchItemEvent(stack)); + //update export + state.secinfo.handleItemExport(stack); + Events.fire(new LaunchItemEvent(stack)); + } + + destsec.setExtraItems(dest); + }else if(team().core() != null){ + //dump launched stuff into the core + for(ItemStack stack : stacks){ + int min = Math.min(team().core().block.itemCapacity - team().core().items.get(stack.item), stack.amount); + team().core().items.add(stack.item, min); + } } - - destsec.setExtraItems(dest); } } } diff --git a/core/src/mindustry/world/modules/ItemModule.java b/core/src/mindustry/world/modules/ItemModule.java index 52fdd63dfd..7878a5e62c 100644 --- a/core/src/mindustry/world/modules/ItemModule.java +++ b/core/src/mindustry/world/modules/ItemModule.java @@ -135,6 +135,15 @@ public class ItemModule extends BlockModule{ return true; } + public boolean has(ItemSeq items){ + for(Item item : content.items()){ + if(!has(item, items.get(item))){ + return false; + } + } + return true; + } + public boolean has(Iterable stacks){ for(ItemStack stack : stacks){ if(!has(stack.item, stack.amount)) return false; @@ -261,6 +270,10 @@ public class ItemModule extends BlockModule{ for(ItemStack stack : stacks) remove(stack.item, stack.amount); } + public void remove(ItemSeq stacks){ + stacks.each(this::remove); + } + public void remove(Iterable stacks){ for(ItemStack stack : stacks) remove(stack.item, stack.amount); } diff --git a/gradle.properties b/gradle.properties index 225bb91cfd..585b79d2df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=35f5d68f9cd8538208bc06f77a573386f2ecd477 +archash=11d4fb913d97951063390425e8aeeeac7f3c968f