From aebd3f959fd78bea18bf256568bd709b2e5aa651 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 15 Nov 2020 10:54:09 -0500 Subject: [PATCH] Fixed #3402 / Fixed #3403 / Fixed #3401 / Fixed #3404 / Disabled derelict updates --- core/assets/bundles/bundle.properties | 2 ++ core/src/mindustry/ai/BlockIndexer.java | 7 ++---- core/src/mindustry/entities/Units.java | 2 +- .../mindustry/entities/comp/BuildingComp.java | 4 +++ .../entities/units/AIController.java | 4 +++ core/src/mindustry/input/MobileInput.java | 9 +++---- core/src/mindustry/type/ItemSeq.java | 2 +- .../mindustry/ui/dialogs/ResearchDialog.java | 8 +++--- .../ui/dialogs/SettingsMenuDialog.java | 5 ++++ .../mindustry/ui/fragments/HudFragment.java | 25 ++++++++++++------- .../world/blocks/distribution/Conveyor.java | 1 + .../world/blocks/logic/LogicBlock.java | 6 ++++- gradle.properties | 2 +- 13 files changed, 50 insertions(+), 27 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index f2b57252ed..a09df8e1a6 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -297,6 +297,8 @@ wave.waveInProgress = [lightgray]Wave in progress waiting = [lightgray]Waiting... waiting.players = Waiting for players... wave.enemies = [lightgray]{0} Enemies Remaining +wave.enemycores = [accent]{0}[lightgray] Enemy Cores +wave.enemycore = [accent]{0}[lightgray] Enemy Core wave.enemy = [lightgray]{0} Enemy Remaining wave.guardianwarn = Guardian approaching in [accent]{0}[] waves. wave.guardianwarn.one = Guardian approaching in [accent]{0}[] wave. diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index 3fc012eeaa..8ede0315f1 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -247,7 +247,7 @@ public class BlockIndexer{ for(int i = 0; i < activeTeams.size; i++){ Team enemy = activeTeams.items[i]; - if(enemy == team) continue; + if(enemy == team || team == Team.derelict) continue; Building entity = indexer.findTile(enemy, x, y, range, pred, true); if(entity != null){ @@ -276,10 +276,7 @@ public class BlockIndexer{ for(int ty = ry * quadrantSize; ty < (ry + 1) * quadrantSize && ty < world.height(); ty++){ Building e = world.build(tx, ty); - if(e == null) continue; - - if(e.team != team || !pred.get(e) || !e.block.targetable) - continue; + if(e == null || e.team != team || !pred.get(e) || !e.block.targetable || e.team == Team.derelict) continue; float ndst = e.dst2(x, y); if(ndst < range2 && (closest == null || diff --git a/core/src/mindustry/entities/Units.java b/core/src/mindustry/entities/Units.java index e4591a0ed0..cd602327a6 100644 --- a/core/src/mindustry/entities/Units.java +++ b/core/src/mindustry/entities/Units.java @@ -197,7 +197,7 @@ public class Units{ cdist = 0f; nearbyEnemies(team, x - range, y - range, range*2f, range*2f, e -> { - if(e.dead() || !predicate.get(e)) return; + if(e.dead() || !predicate.get(e) || e.team == Team.derelict) return; float dst2 = e.dst2(x, y); if(dst2 < range*range && (result == null || dst2 < cdist)){ diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index facc17c40b..087216cad2 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -1371,6 +1371,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, } } + if(team == Team.derelict){ + enabled = false; + } + if(!headless){ if(sound != null){ sound.update(x, y, shouldActiveSound()); diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index 78ee1c1d3c..1707df15f5 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -109,6 +109,8 @@ public class AIController implements UnitController{ target = null; } + unit.isShooting = false; + for(int i = 0; i < targets.length; i++){ WeaponMount mount = unit.mounts[i]; Weapon weapon = mount.weapon; @@ -140,6 +142,8 @@ public class AIController implements UnitController{ mount.shoot = shoot; mount.rotate = shoot; + + unit.isShooting |= shoot; } } diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 0f64ce0cf7..973343a754 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -79,16 +79,13 @@ public class MobileInput extends InputHandler implements GestureListener{ Unit unit = Units.closestEnemy(player.team(), x, y, 20f, u -> !u.dead); if(unit != null){ - player.miner().mineTile(null); + player.unit().mineTile = null; target = unit; }else{ Building tile = world.buildWorld(x, y); - if(tile != null && player.team().isEnemy(tile.team)){ - player.miner().mineTile(null); - target = tile; - }else if(tile != null && player.unit().type.canHeal && tile.team == player.team() && tile.damaged()){ - player.miner().mineTile(null); + if((tile != null && player.team().isEnemy(tile.team) && tile.team != Team.derelict) || (tile != null && player.unit().type.canHeal && tile.team == player.team() && tile.damaged())){ + player.unit().mineTile = null; target = tile; } } diff --git a/core/src/mindustry/type/ItemSeq.java b/core/src/mindustry/type/ItemSeq.java index 64603d8a8d..4fb7409796 100644 --- a/core/src/mindustry/type/ItemSeq.java +++ b/core/src/mindustry/type/ItemSeq.java @@ -139,7 +139,7 @@ public class ItemSeq implements Iterable, Serializable{ @Override public String toString(){ - return JsonIO.write(this); + return JsonIO.print(JsonIO.write(this)); } @Override diff --git a/core/src/mindustry/ui/dialogs/ResearchDialog.java b/core/src/mindustry/ui/dialogs/ResearchDialog.java index 7d0f0d7a10..c6d3f8409f 100644 --- a/core/src/mindustry/ui/dialogs/ResearchDialog.java +++ b/core/src/mindustry/ui/dialogs/ResearchDialog.java @@ -59,10 +59,12 @@ public class ResearchDialog extends BaseDialog{ //add global counts of each sector for(Planet planet : content.planets()){ for(Sector sector : planet.sectors){ - if(sector.hasSave()){ + if(sector.hasSave() && sector.hasBase()){ ItemSeq cached = sector.items(); - add(cached); - cache.put(sector, cached); + cached.each((item, amount) -> { + values[item.id] += amount; + total += amount; + }); } } } diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index 378e909922..ffaf137b56 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -486,12 +486,17 @@ public class SettingsMenuDialog extends SettingsDialog{ throw new IllegalArgumentException("Not valid save data."); } + //delete old saves so they don't interfere + saveDirectory.deleteDirectory(); + //purge existing tmp data, keep everything else tmpDirectory.deleteDirectory(); zipped.walk(f -> f.copyTo(base.child(f.path()))); dest.delete(); + //clear old data + settings.clear(); //load data so it's saved on exit settings.load(); } diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index d3ec9647a0..2a6717cde4 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -203,15 +203,13 @@ public class HudFragment extends Fragment{ }else{ logic.skipWave(); } - }).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()) - .visible(() -> state.rules.waves).name("skip"); + }).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).name("skip"); }).width(dsize * 5 + 4f); wavesMain.row(); wavesMain.table(Tex.button, t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.white)) - .grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get() - .name = "boss"; + .grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).name("boss"); wavesMain.row(); @@ -244,7 +242,6 @@ public class HudFragment extends Fragment{ info.name = "fps/ping"; info.touchable = Touchable.disabled; info.top().left().margin(4).visible(() -> Core.settings.getBool("fps") && shown); - info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -Scl.scl(dsize * 4 + 3), 0)); IntFormat fps = new IntFormat("fps"); IntFormat ping = new IntFormat("ping"); IntFormat mem = new IntFormat("memory"); @@ -600,7 +597,7 @@ public class HudFragment extends Fragment{ } private Table makeStatusTable(){ - Button table = new Button(Styles.waveb); + Table table = new Table(Tex.wavepane); StringBuilder ibuild = new StringBuilder(); @@ -608,6 +605,8 @@ public class HudFragment extends Fragment{ IntFormat wavefc = new IntFormat("wave.cap"); IntFormat enemyf = new IntFormat("wave.enemy"); IntFormat enemiesf = new IntFormat("wave.enemies"); + IntFormat enemycf = new IntFormat("wave.enemycore"); + IntFormat enemycsf = new IntFormat("wave.enemycores"); IntFormat waitingf = new IntFormat("wave.waiting", i -> { ibuild.setLength(0); int m = i/60; @@ -623,7 +622,6 @@ public class HudFragment extends Fragment{ return ibuild.toString(); }); - table.clearChildren(); table.touchable = Touchable.enabled; StringBuilder builder = new StringBuilder(); @@ -745,6 +743,13 @@ public class HudFragment extends Fragment{ table.labelWrap(() -> { builder.setLength(0); + + if(!state.rules.waves && state.rules.attackMode){ + int sum = Math.max(state.teams.present.sum(t -> t.team != player.team() ? t.cores.size : 0), 1); + builder.append(sum > 1 ? enemycsf.get(sum) : enemycf.get(sum)); + return builder; + } + if(state.rules.winWave > 1 && state.rules.winWave >= state.wave && state.isCampaign()){ builder.append(wavefc.get(state.wave, state.rules.winWave)); }else{ @@ -770,8 +775,10 @@ public class HudFragment extends Fragment{ return builder; }).growX().pad(8f); - table.setDisabled(true); - table.visible(() -> state.rules.waves); + table.update(() -> { + //table.background(state.rules.waves ? Tex.wavepane : null); + }); + table.touchable(() -> state.rules.waves ? Touchable.enabled : Touchable.disabled); return table; } diff --git a/core/src/mindustry/world/blocks/distribution/Conveyor.java b/core/src/mindustry/world/blocks/distribution/Conveyor.java index 514599ce53..39210efe06 100644 --- a/core/src/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/mindustry/world/blocks/distribution/Conveyor.java @@ -10,6 +10,7 @@ import arc.util.io.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.units.*; +import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; diff --git a/core/src/mindustry/world/blocks/logic/LogicBlock.java b/core/src/mindustry/world/blocks/logic/LogicBlock.java index df469b8f7c..35d76dcc82 100644 --- a/core/src/mindustry/world/blocks/logic/LogicBlock.java +++ b/core/src/mindustry/world/blocks/logic/LogicBlock.java @@ -147,7 +147,11 @@ public class LogicBlock extends Block{ String name = stream.readUTF(); short x = stream.readShort(), y = stream.readShort(); - transformer.get(Tmp.p1.set(x, y)); + Tmp.p2.set((int)(offset / (tilesize/2)), (int)(offset / (tilesize/2))); + transformer.get(Tmp.p1.set(x * 2, y * 2).sub(Tmp.p2)); + Tmp.p1.add(Tmp.p2); + Tmp.p1.x /= 2; + Tmp.p1.y /= 2; links.add(new LogicLink(Tmp.p1.x, Tmp.p1.y, name, true)); } diff --git a/gradle.properties b/gradle.properties index bbcca43ff6..075558d561 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=ebc3ce51dadc2aec4b5e5799d5d4d712b9681422 +archash=c3f584d2d17fe0a91798565b73ea4d72ad312abf