From 5f6c71b9d3f0e535815bd32205ebfadf4517c25c Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 1 Jul 2020 11:50:33 -0400 Subject: [PATCH] Replaced concept of "turns" with raw seconds --- core/assets/baseparts/000.msch | Bin 0 -> 97 bytes core/assets/bundles/bundle.properties | 2 + core/src/mindustry/Vars.java | 4 +- core/src/mindustry/core/Logic.java | 38 +++----- core/src/mindustry/editor/EditorTile.java | 2 +- core/src/mindustry/game/EventType.java | 1 - core/src/mindustry/game/SectorInfo.java | 6 +- core/src/mindustry/game/Tutorial.java | 4 +- core/src/mindustry/game/Universe.java | 92 +++--------------- core/src/mindustry/io/SaveVersion.java | 1 + core/src/mindustry/type/Sector.java | 10 +- .../mindustry/ui/dialogs/PlanetDialog.java | 6 +- .../mindustry/ui/fragments/HudFragment.java | 5 - core/src/mindustry/world/Block.java | 5 + core/src/mindustry/world/Build.java | 2 + core/src/mindustry/world/CachedTile.java | 2 +- .../world/blocks/distribution/MassDriver.java | 2 +- .../world/blocks/storage/CoreBlock.java | 61 ++++++++++-- .../world/blocks/storage/Unloader.java | 8 +- .../mindustry/world/modules/ItemModule.java | 12 +++ .../src/mindustry/desktop/steam/SStats.java | 2 +- gradle.properties | 2 +- .../src/mindustry/server/ServerControl.java | 2 +- tools/src/mindustry/tools/Image.java | 19 ++-- 24 files changed, 136 insertions(+), 152 deletions(-) create mode 100644 core/assets/baseparts/000.msch diff --git a/core/assets/baseparts/000.msch b/core/assets/baseparts/000.msch new file mode 100644 index 0000000000000000000000000000000000000000..35d2df8e147a1fd293bdaeeab51c70de85b364a3 GIT binary patch literal 97 zcmV-n0G|JCb7N=$c$^)KK?;B%6a`=XYSSX<9!J)?s@h*I`ZOvHHS6ys2i(00=*Q1`MFF2XmJ`!Yvfr D;OQ$? literal 0 HcmV?d00001 diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index c56c0930b0..e7c440999c 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -587,6 +587,8 @@ blocks.reload = Shots/Second blocks.ammo = Ammo bar.drilltierreq = Better Drill Required +bar.noresources = Missing Resources +bar.corereq = Core Base Required bar.drillspeed = Drill Speed: {0}/s bar.pumpspeed = Pump Speed: {0}/s bar.efficiency = Efficiency: {0}% diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 39691d48d6..17b540914c 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -78,8 +78,8 @@ public class Vars implements Loadable{ public static final float miningRange = 70f; /** range for building */ public static final float buildingRange = 220f; - /** duration of one turn in ticks */ - public static final float turnDuration = 5 * Time.toMinutes; + /** duration of time between events in ticks */ + public static final float eventRate = 5 * Time.toMinutes; /** min armor fraction damage; e.g. 0.05 = at least 5% damage */ public static final float minArmorDamage = 0.05f; /** launch animation duration */ diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 3f7343f8ad..7d507d1886 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -11,7 +11,6 @@ import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.game.Teams.*; import mindustry.gen.*; -import mindustry.maps.*; import mindustry.type.*; import mindustry.type.Weather.*; import mindustry.world.*; @@ -88,13 +87,14 @@ public class Logic implements ApplicationListener{ //when loading a 'damaged' sector, propagate the damage Events.on(WorldLoadEvent.class, e -> { - if(state.isCampaign() && state.rules.sector.getTurnsPassed() > 0){ - int passed = state.rules.sector.getTurnsPassed(); + if(state.isCampaign() && state.rules.sector.getSecondsPassed() > 0){ + long seconds = state.rules.sector.getSecondsPassed(); CoreEntity core = state.rules.defaultTeam.core(); - if(state.rules.sector.hasWaves()){ - SectorDamage.apply(passed); - } + //TODO figure out how to apply damage properly + // if(state.rules.sector.hasWaves()){ + //SectorDamage.apply(seconds); + //} //add resources based on turns passed @@ -103,7 +103,7 @@ public class Logic implements ApplicationListener{ //add produced items //TODO move to recieved items state.rules.sector.save.meta.secinfo.production.each((item, stat) -> { - core.items.add(item, (int)(stat.mean * passed)); + core.items.add(item, (int)(stat.mean * seconds)); }); //add recieved items @@ -121,22 +121,13 @@ public class Logic implements ApplicationListener{ } } - state.rules.sector.setTurnsPassed(0); + state.rules.sector.setLastSecond(universe.seconds()); } //enable infinite ammo for wave team by default state.rules.waveTeam.rules().infiniteAmmo = true; }); - //TODO dying takes up a turn (?) - /* - Events.on(GameOverEvent.class, e -> { - //simulate a turn on a normal non-launch gameover - if(state.isCampaign() && !state.launched){ - universe.runTurn(); - } - });*/ - } /** Adds starting items, resets wave time, and sets state to playing. */ @@ -253,16 +244,11 @@ public class Logic implements ApplicationListener{ ui.hudfrag.showLaunch(); } - //TODO core launch effect + //TODO better core launch effect for(Building tile : state.teams.playerCores()){ Fx.launch.at(tile); } - if(state.isCampaign()){ - //TODO implement? - //state.getSector().setLaunched(); - } - Sector sector = state.rules.sector; //TODO containers must be launched too @@ -290,10 +276,10 @@ public class Logic implements ApplicationListener{ sector.save.save(); //run a turn, since launching takes up a turn - universe.runTurn(); + universe.runEvents(); - //TODO ??? - sector.setTurnsPassed(sector.getTurnsPassed() + 3); + //TODO apply extra damage to sector + //sector.setTurnsPassed(sector.getTurnsPassed() + 3); //TODO load the sector that was launched from Events.fire(new LaunchEvent()); diff --git a/core/src/mindustry/editor/EditorTile.java b/core/src/mindustry/editor/EditorTile.java index 69bfbb21fd..853b141415 100644 --- a/core/src/mindustry/editor/EditorTile.java +++ b/core/src/mindustry/editor/EditorTile.java @@ -125,7 +125,7 @@ public class EditorTile extends Tile{ if(block.hasEntity()){ build = entityprov.get().init(this, team, false); build.cons(new ConsumeModule(build)); - if(block.hasItems) build.items(new ItemModule()); + if(block.hasItems) build.items = new ItemModule(); if(block.hasLiquids) build.liquids(new LiquidModule()); if(block.hasPower) build.power(new PowerModule()); } diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index 98b074f181..ea93772b6d 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -32,7 +32,6 @@ public class EventType{ update } - public static class TurnEvent{} public static class WinEvent{} public static class LoseEvent{} public static class LaunchEvent{} diff --git a/core/src/mindustry/game/SectorInfo.java b/core/src/mindustry/game/SectorInfo.java index 8222cabd9a..3e1713d0ef 100644 --- a/core/src/mindustry/game/SectorInfo.java +++ b/core/src/mindustry/game/SectorInfo.java @@ -131,8 +131,8 @@ public class SectorInfo{ public ObjectIntMap getCurrentItems(Sector sector){ ObjectIntMap map = new ObjectIntMap<>(); map.putAll(coreItems); - int turns = sector.getTurnsPassed(); - production.each((item, stat) -> map.increment(item, (int)(stat.mean * turns))); + long seconds = sector.getSecondsPassed(); + production.each((item, stat) -> map.increment(item, (int)(stat.mean * seconds))); //increment based on recieved items sector.getRecievedItems().each(stack -> map.increment(stack.item, stack.amount)); return map; @@ -155,6 +155,8 @@ public class SectorInfo{ public transient float counter; public transient WindowedMean means = new WindowedMean(valueWindow); public transient boolean loaded; + + /** mean in terms of items produced per refresh rate (currently, per second) */ public float mean; } } diff --git a/core/src/mindustry/game/Tutorial.java b/core/src/mindustry/game/Tutorial.java index 62727a618f..cfaa85a84c 100644 --- a/core/src/mindustry/game/Tutorial.java +++ b/core/src/mindustry/game/Tutorial.java @@ -162,7 +162,7 @@ public class Tutorial{ }, withdraw(() -> event("withdraw")){ void begin(){ - state.teams.playerCores().first().items().add(Items.copper, 10); + state.teams.playerCores().first().items.add(Items.copper, 10); } }, deposit(() -> event("deposit")), @@ -270,7 +270,7 @@ public class Tutorial{ } static int item(Item item){ - return state.rules.defaultTeam.data().noCores() ? 0 : state.rules.defaultTeam.core().items().get(item); + return state.rules.defaultTeam.data().noCores() ? 0 : state.rules.defaultTeam.core().items.get(item); } static boolean toggled(String name){ diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index d0054d68dc..fcd862d9a1 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -4,11 +4,7 @@ import arc.*; import arc.math.*; import arc.struct.*; import arc.util.*; -import mindustry.*; import mindustry.content.*; -import mindustry.game.EventType.*; -import mindustry.game.SectorInfo.*; -import mindustry.io.*; import mindustry.type.*; import mindustry.world.blocks.storage.*; @@ -18,8 +14,8 @@ import static mindustry.Vars.*; public class Universe{ private long seconds; private float secondCounter; - private int turn; - private float turnCounter; + private int event; + private float eventCounter; private Schematic lastLoadout; private Seq lastLaunchResources = new Seq<>(); @@ -59,11 +55,11 @@ public class Universe{ } } - //update turn state - happens only in-game - turnCounter += Time.delta(); + //update event counter - happens only in-game + eventCounter += Time.delta(); - if(turnCounter >= turnDuration){ - runTurn(); + if(eventCounter >= eventRate){ + runEvents(); } if(state.hasSector()){ @@ -113,70 +109,12 @@ public class Universe{ return schem == null ? all.first() : schem; } - public int[] getTotalExports(){ - int[] exports = new int[Vars.content.items().size]; + /** Runs possible events. Resets event counter. */ + public void runEvents(){ + event++; + eventCounter = 0; - for(Planet planet : content.planets()){ - for(Sector sector : planet.sectors){ - - //ignore the current sector if the player is in it right now - if(sector.hasBase() && !sector.isBeingPlayed()){ - SaveMeta meta = sector.save.meta; - - for(ObjectMap.Entry entry : meta.secinfo.export){ - //total is calculated by items/sec (value) * turn duration in seconds - int total = (int)(entry.value.mean * turnDuration / 60f); - - exports[entry.key.id] += total; - } - } - } - } - - return exports; - } - - public void runTurns(int amount){ - for(int i = 0; i < amount; i++){ - runTurn(); - } - } - - /** Runs a turn once. Resets turn counter. */ - public void runTurn(){ - turn ++; - turnCounter = 0; - - //TODO EVENTS + a notification - - //increment turns passed for sectors with waves - //TODO a turn passing may break the core; detect this, send an event and mark the sector as having no base! - for(Planet planet : content.planets()){ - for(Sector sector : planet.sectors){ - //update turns passed for all sectors - if(!sector.isBeingPlayed() && sector.hasSave()){ - sector.setTurnsPassed(sector.getTurnsPassed() + 1); - } - } - } - - //calculate passive item generation - //TODO make exports only update for sector with items - //TODO items should be added directly to cores! - - Events.fire(new TurnEvent()); - } - - public int getTurn(){ - return turn; - } - - public int getSectorsAttacked(){ - int count = 0; - for(Planet planet : content.planets()){ - count += planet.sectors.count(s -> !s.isBeingPlayed() && s.hasSave() && s.hasWaves()); - } - return count; + //TODO events } public float secondsMod(float mod, float scale){ @@ -193,14 +131,14 @@ public class Universe{ private void save(){ Core.settings.put("utime", seconds); - Core.settings.put("turn", turn); - Core.settings.put("turntime", turnCounter); + Core.settings.put("event", event); + Core.settings.put("eventtime", eventCounter); } private void load(){ seconds = Core.settings.getLong("utime"); - turn = Core.settings.getInt("turn"); - turnCounter = Core.settings.getFloat("turntime"); + event = Core.settings.getInt("event"); + eventCounter = Core.settings.getFloat("eventtime"); } } diff --git a/core/src/mindustry/io/SaveVersion.java b/core/src/mindustry/io/SaveVersion.java index b37f1e0dbe..3caee54d27 100644 --- a/core/src/mindustry/io/SaveVersion.java +++ b/core/src/mindustry/io/SaveVersion.java @@ -74,6 +74,7 @@ public abstract class SaveVersion extends SaveFileReader{ //prepare campaign data for writing if(state.isCampaign()){ state.secinfo.prepare(); + state.getSector().setLastSecond(universe.seconds()); } //flush tech node progress diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index c4cb9a84f2..9598496b1f 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -13,7 +13,7 @@ import mindustry.game.Saves.*; import mindustry.graphics.g3d.PlanetGrid.*; import mindustry.world.*; -import static mindustry.Vars.world; +import static mindustry.Vars.*; /** A small section of a planet. */ public class Sector{ @@ -131,12 +131,12 @@ public class Sector{ return Core.settings.getInt(key("spawn-position"), Point2.pack(world.width() / 2, world.height() / 2)); } - public void setTurnsPassed(int number){ - put("turns-passed", number); + public void setLastSecond(long number){ + put("last-second", number); } - public int getTurnsPassed(){ - return Core.settings.getInt(key("turns-passed")); + public long getSecondsPassed(){ + return universe.seconds() - Core.settings.getLong(key("last-second")); } private String key(String key){ diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index b896730c00..73501f0ecf 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -294,7 +294,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ t.left(); sector.save.meta.secinfo.exportRates().each(entry -> { - int total = (int)(entry.value * turnDuration / 60f); + int total = (int)(entry.value * eventRate / 60f); if(total > 1){ t.image(entry.key.icon(Cicon.small)).padRight(3); t.add(ui.formatAmount(total) + " /turn").color(Color.lightGray); @@ -330,11 +330,13 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ } //display how many turns this sector has been attacked + //TODO implement properly + /* if(sector.getTurnsPassed() > 0 && sector.hasBase()){ stable.row(); stable.add("[scarlet]" + Iconc.warning + " " + sector.getTurnsPassed() + "x attacks"); - } + }*/ stable.row(); diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index c731f1dcae..44930e05c5 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -45,11 +45,6 @@ public class HudFragment extends Fragment{ @Override public void build(Group parent){ - Events.on(TurnEvent.class, e -> { - //TODO localize, clean up, etc - int attacked = universe.getSectorsAttacked(); - showToast("New turn: [accent]" + universe.getTurn() + "[]" + (attacked > 0 ? "\n[scarlet]" + Iconc.warning + " " + attacked + " sectors attacked!": "")); - }); //TODO details and stuff Events.on(SectorCaptureEvent.class, e ->{ diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 25e5b5580d..d6a2333578 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -484,6 +484,11 @@ public class Block extends UnlockableContent{ } + /** Called right before building of this block begins. */ + public void beforePlaceBegan(Tile tile, Block previous){ + + } + /** @return a message detailing why this block can't be placed. */ public String unplaceableMessage(){ return state.rules.bannedBlocks.contains(this) ? Core.bundle.get("banned") : buildPlaceability.message(); diff --git a/core/src/mindustry/world/Build.java b/core/src/mindustry/world/Build.java index d2b10c8e50..d9c38c1a7f 100644 --- a/core/src/mindustry/world/Build.java +++ b/core/src/mindustry/world/Build.java @@ -56,6 +56,8 @@ public class Build{ Block previous = tile.block(); Block sub = BuildBlock.get(result.size); + result.beforePlaceBegan(tile, previous); + tile.setBlock(sub, team, rotation); tile.bc().setConstruct(previous, result); diff --git a/core/src/mindustry/world/CachedTile.java b/core/src/mindustry/world/CachedTile.java index 7f436abac0..5a04f6a83e 100644 --- a/core/src/mindustry/world/CachedTile.java +++ b/core/src/mindustry/world/CachedTile.java @@ -31,7 +31,7 @@ public class CachedTile extends Tile{ n.cons(new ConsumeModule(build)); n.tile(this); n.block(block); - if(block.hasItems) n.items(new ItemModule()); + if(block.hasItems) n.items = new ItemModule(); if(block.hasLiquids) n.liquids(new LiquidModule()); if(block.hasPower) n.power(new PowerModule()); build = n; diff --git a/core/src/mindustry/world/blocks/distribution/MassDriver.java b/core/src/mindustry/world/blocks/distribution/MassDriver.java index 081a1ba856..f47f94a1d9 100644 --- a/core/src/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/mindustry/world/blocks/distribution/MassDriver.java @@ -151,7 +151,7 @@ public class MassDriver extends Block{ if( items.total() >= minDistribute && //must shoot minimum amount of items - link.block().itemCapacity - link.items().total() >= minDistribute //must have minimum amount of space + link.block().itemCapacity - link.items.total() >= minDistribute //must have minimum amount of space ){ MassDriverEntity other = (MassDriverEntity)link; other.waitingShooters.add(tile); diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index 0f43741959..2c34fce645 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -10,8 +10,8 @@ import arc.util.ArcAnnotate.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.game.*; import mindustry.game.EventType.*; +import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; @@ -25,6 +25,9 @@ import mindustry.world.modules.*; import static mindustry.Vars.*; public class CoreBlock extends StorageBlock{ + //hacky way to pass item modules between methods + private static ItemModule nextItems; + public UnitType unitType = UnitTypes.alpha; public final int timerResupply = timers++; @@ -76,7 +79,7 @@ public class CoreBlock extends StorageBlock{ new Bar( () -> Core.bundle.format("bar.capacity", ui.formatAmount(e.storageCapacity)), () -> 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 -> @@ -100,6 +103,9 @@ public class CoreBlock extends StorageBlock{ @Override public boolean canPlaceOn(Tile tile, Team team){ + CoreEntity core = team.core(); + //must have all requirements + if(core == null || (!state.rules.infiniteResources && !core.items.has(requirements))) return false; return canReplace(tile.block()); } @@ -110,6 +116,41 @@ public class CoreBlock extends StorageBlock{ tile.setBlock(this, tile.team()); Fx.placeBlock.at(tile, tile.block().size); Fx.upgradeCore.at(tile, tile.block().size); + + //set up the correct items + if(nextItems != null){ + //force-set the total items + if(tile.team().core() != null){ + tile.team().core().items.set(nextItems); + } + + nextItems = null; + } + } + } + + @Override + public void beforePlaceBegan(Tile tile, Block previous){ + if(tile.build instanceof CoreEntity){ + //right before placing, create a "destination" item array which is all the previous items minus core requirements + ItemModule items = tile.build.items.copy(); + if(!state.rules.infiniteResources){ + items.remove(requirements); + } + + nextItems = items; + } + } + + @Override + public void drawPlace(int x, int y, int rotation, boolean valid){ + if(!canPlaceOn(world.tile(x, y),player.team())){ + + drawPlaceText(Core.bundle.get((player.team().core() != null && player.team().core().items.has(requirements) && !state.rules.infiniteResources) ? + "bar.corereq" : + "bar.noresources" + ), x, y, valid); + } } @@ -161,14 +202,14 @@ public class CoreBlock extends StorageBlock{ public void onProximityUpdate(){ for(Building other : state.teams.cores(team)){ if(other.tile() != tile){ - items(other.items()); + this.items = other.items; } } state.teams.registerCore(this); storageCapacity = itemCapacity + proximity().sum(e -> isContainer(e) && owns(e) ? e.block().itemCapacity : 0); proximity.each(e -> isContainer(e) && owns(e), t -> { - t.items(items); + t.items = items; ((StorageBlockEntity)t).linkedCore = this; }); @@ -198,10 +239,10 @@ public class CoreBlock extends StorageBlock{ Draw.rect("block-select", t.x() + offset * p.x, t.y() + offset * p.y, i * 90); } }; - if(proximity.contains(e -> isContainer(e) && e.items() == items)){ + if(proximity.contains(e -> isContainer(e) && e.items == items)){ outline.get(this); } - proximity.each(e -> isContainer(e) && e.items() == items, outline); + proximity.each(e -> isContainer(e) && e.items == items, outline); Draw.reset(); } @@ -228,15 +269,15 @@ public class CoreBlock extends StorageBlock{ @Override public void onRemoved(){ - int total = proximity.count(e -> e.items() != null && e.items() == items); + int total = proximity.count(e -> e.items != null && e.items == items); float fract = 1f / total / state.teams.cores(team).size; - proximity.each(e -> isContainer(e) && e.items() == items && owns(e), t -> { + proximity.each(e -> isContainer(e) && e.items == items && owns(e), t -> { StorageBlockEntity ent = (StorageBlockEntity)t; ent.linkedCore = null; - ent.items(new ItemModule()); + ent.items = new ItemModule(); for(Item item : content.items()){ - ent.items().set(item, (int)(fract * items.get(item))); + ent.items.set(item, (int)(fract * items.get(item))); } }); diff --git a/core/src/mindustry/world/blocks/storage/Unloader.java b/core/src/mindustry/world/blocks/storage/Unloader.java index 080c5d3627..7111283d36 100644 --- a/core/src/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/mindustry/world/blocks/storage/Unloader.java @@ -51,19 +51,19 @@ public class Unloader extends Block{ if(timer(timerUnload, speed / timeScale())){ for(Building other : proximity){ if(other.interactable(team) && other.block().unloadable && other.block().hasItems - && ((sortItem == null && other.items().total() > 0) || (sortItem != null && other.items().has(sortItem)))){ + && ((sortItem == null && other.items.total() > 0) || (sortItem != null && other.items.has(sortItem)))){ //make sure the item can't be dumped back into this block dumpingTo = other; //get item to be taken - Item item = sortItem == null ? other.items().beginTake() : sortItem; + Item item = sortItem == null ? other.items.beginTake() : sortItem; //remove item if it's dumped correctly if(put(item)){ if(sortItem == null){ - other.items().endTake(item); + other.items.endTake(item); }else{ - other.items().remove(item, 1); + other.items.remove(item, 1); } } } diff --git a/core/src/mindustry/world/modules/ItemModule.java b/core/src/mindustry/world/modules/ItemModule.java index 8211477580..71cffee56a 100644 --- a/core/src/mindustry/world/modules/ItemModule.java +++ b/core/src/mindustry/world/modules/ItemModule.java @@ -25,6 +25,18 @@ public class ItemModule extends BlockModule{ private @Nullable WindowedMean[] flow; + public ItemModule copy(){ + ItemModule out = new ItemModule(); + out.set(this); + return out; + } + + public void set(ItemModule other){ + total = other.total; + takeRotation = other.takeRotation; + System.arraycopy(other.items, 0, items, 0, items.length); + } + public void update(boolean showFlow){ if(showFlow){ if(flow == null){ diff --git a/desktop/src/mindustry/desktop/steam/SStats.java b/desktop/src/mindustry/desktop/steam/SStats.java index 28f4cb4d3a..ef4584f15e 100644 --- a/desktop/src/mindustry/desktop/steam/SStats.java +++ b/desktop/src/mindustry/desktop/steam/SStats.java @@ -92,7 +92,7 @@ public class SStats implements SteamUserStatsCallback{ }); Events.on(Trigger.newGame, () -> Core.app.post(() -> { - if(campaign() && player.core() != null && player.core().items().total() >= 10 * 1000){ + if(campaign() && player.core() != null && player.core().items.total() >= 10 * 1000){ drop10kitems.complete(); } })); diff --git a/gradle.properties b/gradle.properties index 8173cd3bc2..166a84da20 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=6a8eb57007ff1b0ae465fbfe9983edb585964823 +archash=0582cfd3b405d534c948383578c7a3f0c0d9dd6b diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 33eccd26dd..3630d1a467 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -418,7 +418,7 @@ public class ServerControl implements ApplicationListener{ } for(Item item : content.items()){ - state.teams.cores(team).first().items().set(item, state.teams.cores(team).first().block().itemCapacity); + state.teams.cores(team).first().items.set(item, state.teams.cores(team).first().block().itemCapacity); } info("Core filled."); diff --git a/tools/src/mindustry/tools/Image.java b/tools/src/mindustry/tools/Image.java index 8fc7c500e5..501598b27f 100644 --- a/tools/src/mindustry/tools/Image.java +++ b/tools/src/mindustry/tools/Image.java @@ -2,19 +2,18 @@ package mindustry.tools; import arc.func.*; import arc.graphics.Color; -import arc.graphics.g2d.TextureRegion; -import arc.util.Structs; -import mindustry.tools.ImagePacker.GenRegion; +import arc.graphics.g2d.*; +import arc.struct.*; +import arc.util.*; +import mindustry.tools.ImagePacker.*; -import javax.imageio.ImageIO; +import javax.imageio.*; import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; +import java.awt.image.*; +import java.io.*; class Image{ - private static ArrayList toDispose = new ArrayList<>(); + private static Seq toDispose = new Seq<>(); private BufferedImage image; private Graphics2D graphics; @@ -135,7 +134,7 @@ class Image{ } static int total(){ - return toDispose.size(); + return toDispose.size; } static void dispose(){