diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 07819887f1..76b1d49e3d 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -12,6 +12,7 @@ import arc.util.Log.*; import arc.util.io.*; import mindustry.ai.*; import mindustry.async.*; +import mindustry.audio.LoopControl; import mindustry.core.*; import mindustry.entities.*; import mindustry.game.*; @@ -167,7 +168,7 @@ public class Vars implements Loadable{ public static GlobalData data; public static EntityCollisions collisions; public static DefaultWaves defaultWaves; - public static LoopControl loops; + public static mindustry.audio.LoopControl loops; public static Platform platform = new Platform(){}; public static Mods mods; public static Schematics schematics; diff --git a/core/src/mindustry/game/LoopControl.java b/core/src/mindustry/audio/LoopControl.java similarity index 98% rename from core/src/mindustry/game/LoopControl.java rename to core/src/mindustry/audio/LoopControl.java index 8e0a9f1801..021549e463 100644 --- a/core/src/mindustry/game/LoopControl.java +++ b/core/src/mindustry/audio/LoopControl.java @@ -1,4 +1,4 @@ -package mindustry.game; +package mindustry.audio; import arc.*; import arc.audio.*; diff --git a/core/src/mindustry/game/MusicControl.java b/core/src/mindustry/audio/MusicControl.java similarity index 99% rename from core/src/mindustry/game/MusicControl.java rename to core/src/mindustry/audio/MusicControl.java index 16a619c158..cf49975931 100644 --- a/core/src/mindustry/game/MusicControl.java +++ b/core/src/mindustry/audio/MusicControl.java @@ -1,4 +1,4 @@ -package mindustry.game; +package mindustry.audio; import arc.*; import arc.audio.*; diff --git a/core/src/mindustry/game/SoundLoop.java b/core/src/mindustry/audio/SoundLoop.java similarity index 98% rename from core/src/mindustry/game/SoundLoop.java rename to core/src/mindustry/audio/SoundLoop.java index 444ce0c857..cfdf380753 100644 --- a/core/src/mindustry/game/SoundLoop.java +++ b/core/src/mindustry/audio/SoundLoop.java @@ -1,4 +1,4 @@ -package mindustry.game; +package mindustry.audio; import arc.audio.*; import arc.math.*; diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 8cc8138969..4b53e7c8e7 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -9,6 +9,7 @@ import arc.math.*; import arc.scene.ui.*; import arc.struct.*; import arc.util.*; +import mindustry.audio.MusicControl; import mindustry.content.*; import mindustry.core.GameState.*; import mindustry.entities.*; @@ -39,7 +40,7 @@ import static mindustry.Vars.*; */ public class Control implements ApplicationListener, Loadable{ public Saves saves; - public MusicControl music; + public mindustry.audio.MusicControl music; public Tutorial tutorial; public InputHandler input; diff --git a/core/src/mindustry/core/GameState.java b/core/src/mindustry/core/GameState.java index 82c7d5142f..d715ce653d 100644 --- a/core/src/mindustry/core/GameState.java +++ b/core/src/mindustry/core/GameState.java @@ -41,7 +41,7 @@ public class GameState{ /** Note that being in a campaign does not necessarily mean having a sector. */ public boolean isCampaign(){ - return rules.sector != null || rules.region != null; + return rules.sector != null; } public boolean hasSector(){ diff --git a/core/src/mindustry/entities/def/TileComp.java b/core/src/mindustry/entities/def/TileComp.java index 02c5e9de69..86db58b602 100644 --- a/core/src/mindustry/entities/def/TileComp.java +++ b/core/src/mindustry/entities/def/TileComp.java @@ -15,6 +15,7 @@ import arc.util.*; import arc.util.ArcAnnotate.*; import arc.util.io.*; import mindustry.annotations.Annotations.*; +import mindustry.audio.SoundLoop; import mindustry.content.*; import mindustry.ctype.*; import mindustry.entities.*; @@ -59,7 +60,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree private transient float timeScale = 1f, timeScaleDuration; - private transient @Nullable SoundLoop sound; + private transient @Nullable mindustry.audio.SoundLoop sound; private transient boolean sleeping; private transient float sleepTime; diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index 03a40e9c13..64dfaca18d 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -90,9 +90,9 @@ public class EventType{ /** Called when a zone's requirements are met. */ public static class ZoneRequireCompleteEvent{ public final SectorPreset zoneMet, zoneForMet; - public final Objective objective; + public final Objectives.Objective objective; - public ZoneRequireCompleteEvent(SectorPreset zoneMet, SectorPreset zoneForMet, Objective objective){ + public ZoneRequireCompleteEvent(SectorPreset zoneMet, SectorPreset zoneForMet, Objectives.Objective objective){ this.zoneMet = zoneMet; this.zoneForMet = zoneForMet; this.objective = objective; diff --git a/core/src/mindustry/game/GlobalData.java b/core/src/mindustry/game/GlobalData.java index eebccf8e65..15b6228ae2 100644 --- a/core/src/mindustry/game/GlobalData.java +++ b/core/src/mindustry/game/GlobalData.java @@ -1,10 +1,9 @@ package mindustry.game; import arc.*; +import arc.files.*; import arc.math.*; import arc.struct.*; -import arc.files.*; -import arc.util.ArcAnnotate.*; import arc.util.io.*; import mindustry.*; import mindustry.content.*; @@ -22,7 +21,6 @@ public class GlobalData{ private ObjectMap> unlocked = new ObjectMap<>(); private ObjectIntMap items = new ObjectIntMap<>(); private Array satellites = new Array<>(); - private ObjectMap regions = new ObjectMap<>(); private boolean modified; public GlobalData(){ @@ -39,10 +37,6 @@ public class GlobalData{ }); } - public @Nullable MapRegion getRegion(String name){ - return regions.get(name); - } - public void exportData(Fi file) throws IOException{ Array files = new Array<>(); files.add(Core.settings.getSettingsFile()); diff --git a/core/src/mindustry/game/MapRegion.java b/core/src/mindustry/game/MapRegion.java deleted file mode 100644 index 8a6908b216..0000000000 --- a/core/src/mindustry/game/MapRegion.java +++ /dev/null @@ -1,12 +0,0 @@ -package mindustry.game; - -/** Defines a special map that can be visited, loaded, and saved. */ -public abstract class MapRegion{ - - /** Name of the region. Used for lookup and save names. */ - public abstract String name(); - - public void load(){ - - } -} diff --git a/core/src/mindustry/game/Objective.java b/core/src/mindustry/game/Objective.java deleted file mode 100644 index 14436e4171..0000000000 --- a/core/src/mindustry/game/Objective.java +++ /dev/null @@ -1,27 +0,0 @@ -package mindustry.game; - -import arc.scene.ui.layout.*; -import arc.util.ArcAnnotate.*; -import mindustry.game.Objectives.*; -import mindustry.type.*; - -/** Defines a specific objective for a game. */ -public interface Objective{ - - /** @return whether this objective is met. */ - boolean complete(); - - /** @return the string displayed when this objective is completed, in imperative form. - * e.g. when the objective is 'complete 10 waves', this would display "complete 10 waves". - * If this objective should not be displayed, should return null.*/ - @Nullable String display(); - - /** Build a display for this zone requirement.*/ - default void build(Table table){ - - } - - default SectorPreset zone(){ - return this instanceof ZoneObjective ? ((ZoneObjective)this).zone : null; - } -} diff --git a/core/src/mindustry/game/Objectives.java b/core/src/mindustry/game/Objectives.java index 590a277c5c..aba23a8c21 100644 --- a/core/src/mindustry/game/Objectives.java +++ b/core/src/mindustry/game/Objectives.java @@ -1,6 +1,7 @@ package mindustry.game; import arc.*; +import arc.scene.ui.layout.*; import arc.util.ArcAnnotate.*; import mindustry.type.*; import mindustry.world.*; @@ -93,4 +94,25 @@ public class Objectives{ public abstract static class ZoneObjective implements Objective{ public @NonNull SectorPreset zone; } + + /** Defines a specific objective for a game. */ + public static interface Objective{ + + /** @return whether this objective is met. */ + boolean complete(); + + /** @return the string displayed when this objective is completed, in imperative form. + * e.g. when the objective is 'complete 10 waves', this would display "complete 10 waves". + * If this objective should not be displayed, should return null.*/ + @Nullable String display(); + + /** Build a display for this zone requirement.*/ + default void build(Table table){ + + } + + default SectorPreset zone(){ + return this instanceof ZoneObjective ? ((ZoneObjective)this).zone : null; + } + } } diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index 9f175203f3..19fb57e631 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -62,8 +62,6 @@ public class Rules{ public int unitCap = 0; /** Sector for saves that have them.*/ public @Nullable Sector sector; - /** Region that save is on. Indicates campaign. TODO not implemented. */ - public @Nullable MapRegion region; /** Spawn layout. */ public Array spawns = new Array<>(); /** Determines if there should be limited respawns. */ diff --git a/core/src/mindustry/game/Schematic.java b/core/src/mindustry/game/Schematic.java index 9e798af72b..eeeda0fbd7 100644 --- a/core/src/mindustry/game/Schematic.java +++ b/core/src/mindustry/game/Schematic.java @@ -16,8 +16,7 @@ public class Schematic implements Publishable, Comparable{ public final Array tiles; public StringMap tags; public int width, height; - public @Nullable - Fi file; + public @Nullable Fi file; /** Associated mod. If null, no mod is associated with this schematic. */ public @Nullable LoadedMod mod; diff --git a/core/src/mindustry/game/Turns.java b/core/src/mindustry/game/Turns.java new file mode 100644 index 0000000000..1e252bb2df --- /dev/null +++ b/core/src/mindustry/game/Turns.java @@ -0,0 +1,4 @@ +package mindustry.game; + +public class Turns{ +} diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index 0cdec7b616..430493087d 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -69,8 +69,7 @@ public class Universe{ } private void save(){ - Core.settings.put("utime", seconds); - Core.settings.save(); + Core.settings.putSave("utime", seconds); } private void load(){ diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index 9c91f0fb24..79695a181e 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -86,10 +86,10 @@ public class ContentParser{ desc.errored = Throwable::printStackTrace; return sound; }); - put(Objective.class, (type, data) -> { - Class oc = data.has("type") ? resolve(data.getString("type"), "mindustry.game.Objectives") : ZoneWave.class; + put(Objectives.Objective.class, (type, data) -> { + Class oc = data.has("type") ? resolve(data.getString("type"), "mindustry.game.Objectives") : ZoneWave.class; data.remove("type"); - Objective obj = make(oc); + Objectives.Objective obj = make(oc); readFields(obj, data); return obj; }); diff --git a/core/src/mindustry/type/SectorPreset.java b/core/src/mindustry/type/SectorPreset.java index e21b5da566..80675a4aaa 100644 --- a/core/src/mindustry/type/SectorPreset.java +++ b/core/src/mindustry/type/SectorPreset.java @@ -17,9 +17,9 @@ import static mindustry.Vars.*; //TODO ? remove ? public class SectorPreset extends UnlockableContent{ public @NonNull WorldGenerator generator; - public @NonNull Objective configureObjective = new ZoneWave(this, 15); + public @NonNull Objectives.Objective configureObjective = new ZoneWave(this, 15); public @NonNull Planet planet; - public Array requirements = new Array<>(); + public Array requirements = new Array<>(); //TODO autogenerate public Array resources = new Array<>(); diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 961140b235..afaa4f8295 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -273,7 +273,11 @@ public class PlanetDialog extends FloatingDialog{ } if(sec.hostility >= 0.02f){ - drawSelection(sec, Color.scarlet, 0.11f * sec.hostility); + drawSelection(sec, Color.scarlet, 0.11f * sec.hostility, 0.0001f); + } + + if(sec.save != null){ + drawSelection(sec, Color.lime, 0.03f, 0.0009f); } } @@ -402,11 +406,11 @@ public class PlanetDialog extends FloatingDialog{ } private void drawSelection(Sector sector){ - drawSelection(sector, Pal.accent, 0.04f); + drawSelection(sector, Pal.accent, 0.04f, 0.001f); } - private void drawSelection(Sector sector, Color color, float length){ - float arad = outlineRad + 0.0001f; + private void drawSelection(Sector sector, Color color, float stroke, float length){ + float arad = outlineRad + length; for(int i = 0; i < sector.tile.corners.length; i++){ Corner next = sector.tile.corners[(i + 1) % sector.tile.corners.length]; @@ -416,8 +420,8 @@ public class PlanetDialog extends FloatingDialog{ curr.v.scl(arad); sector.tile.v.scl(arad); - Tmp.v31.set(curr.v).sub(sector.tile.v).setLength(curr.v.dst(sector.tile.v) - length).add(sector.tile.v); - Tmp.v32.set(next.v).sub(sector.tile.v).setLength(next.v.dst(sector.tile.v) - length).add(sector.tile.v); + Tmp.v31.set(curr.v).sub(sector.tile.v).setLength(curr.v.dst(sector.tile.v) - stroke).add(sector.tile.v); + Tmp.v32.set(next.v).sub(sector.tile.v).setLength(next.v.dst(sector.tile.v) - stroke).add(sector.tile.v); batch.tri(curr.v, next.v, Tmp.v31, color); batch.tri(Tmp.v31, next.v, Tmp.v32, color); diff --git a/core/src/mindustry/ui/dialogs/ZoneInfoDialog.java b/core/src/mindustry/ui/dialogs/ZoneInfoDialog.java index b5f0f1e79c..5483db1d67 100644 --- a/core/src/mindustry/ui/dialogs/ZoneInfoDialog.java +++ b/core/src/mindustry/ui/dialogs/ZoneInfoDialog.java @@ -63,13 +63,13 @@ public class ZoneInfoDialog extends FloatingDialog{ cont.table(req -> { req.defaults().left(); - Array zones = zone.requirements.select(o -> !(o instanceof Unlock)); + Array zones = zone.requirements.select(o -> !(o instanceof Unlock)); if(!zones.isEmpty()){ req.table(r -> { r.add("$complete").colspan(2).left(); r.row(); - for(Objective o : zones){ + for(Objectives.Objective o : zones){ r.image(Icon.terrain).padRight(4); r.add(o.display()).color(Color.lightGray); r.image(o.complete() ? Icon.ok : Icon.cancel, o.complete() ? Color.lightGray : Color.scarlet).padLeft(3); diff --git a/core/src/mindustry/world/blocks/experimental/LogicExecutor.java b/core/src/mindustry/world/blocks/experimental/LogicExecutor.java index e7e7add43b..eada670acf 100644 --- a/core/src/mindustry/world/blocks/experimental/LogicExecutor.java +++ b/core/src/mindustry/world/blocks/experimental/LogicExecutor.java @@ -1,11 +1,12 @@ package mindustry.world.blocks.experimental; -import arc.math.*; import mindustry.gen.*; +import java.nio.*; + public class LogicExecutor{ Instruction[] instructions; - int[] registers = new int[256]; + ByteBuffer memory = ByteBuffer.allocate(1024 * 512); int counter; void step(){ @@ -29,16 +30,16 @@ public class LogicExecutor{ class RegisterI implements Instruction{ /** operation to perform */ Op op; - /** destination register */ - short dest; - /** registers to take data from. -1 for no register. */ - short left, right; + /** destination memory */ + int dest; + /** memory to take data from. -1 for immediate values. */ + int left, right; /** left/right immediate values, only used if no registers are present. */ - int ileft, iright; + double ileft, iright; @Override public void exec(){ - registers[dest] = op.function.get(left == -1 ? ileft : registers[left], right == -1 ? iright : registers[right]); + //memory.putDouble(dest, op.function.get(left == -1 ? ileft : registers[left], right == -1 ? iright : registers[right])); } } @@ -54,7 +55,7 @@ public class LogicExecutor{ @Override public void exec(){ - registers[dest] = op.function.get(device(device), parameter); + //registers[dest] = op.function.get(device(device), parameter); } } @@ -89,12 +90,12 @@ public class LogicExecutor{ mul("*", (a, b) -> a * b), div("/", (a, b) -> a / b), mod("%", (a, b) -> a % b), - pow("^", Mathf::pow), - shl(">>", (a, b) -> a >> b), - shr("<<", (a, b) -> a << b), - or("or", (a, b) -> a | b), - and("and", (a, b) -> a & b), - xor("xor", (a, b) -> a ^ b); + pow("^", Math::pow), + shl(">>", (a, b) -> (int)a >> (int)b), + shr("<<", (a, b) -> (int)a << (int)b), + or("or", (a, b) -> (int)a | (int)b), + and("and", (a, b) -> (int)a & (int)b), + xor("xor", (a, b) -> (int)a ^ (int)b); final OpLambda function; final String symbol; @@ -105,7 +106,7 @@ public class LogicExecutor{ } interface OpLambda{ - int get(int a, int b); + double get(double a, double b); } } diff --git a/gradle.properties b/gradle.properties index 0e711b44d8..92ac814bbd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=6164484526b4e0a9dce4c59b11bef3448e363cee +archash=1ccdb62216c9e6e0d85a85aa120f4dfc59b76e63