From d67316747751056a7681e1cf896f61f8c84d5c3c Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 21 Mar 2020 10:49:38 -0400 Subject: [PATCH] Added basic ground AI --- core/src/mindustry/ai/types/FlyingAI.java | 7 ++ core/src/mindustry/ai/types/GroundAI.java | 100 ++++++++++++++++++ core/src/mindustry/content/Zones.java | 28 ++--- core/src/mindustry/core/ContentLoader.java | 2 +- .../mindustry/entities/def/FlyingComp.java | 4 - core/src/mindustry/entities/def/TeamComp.java | 7 +- core/src/mindustry/entities/def/UnitComp.java | 9 ++ .../mindustry/entities/def/WeaponsComp.java | 3 + .../entities/units/AIController.java | 48 ++++++--- core/src/mindustry/game/EventType.java | 8 +- core/src/mindustry/game/Objective.java | 2 +- core/src/mindustry/game/Objectives.java | 6 +- core/src/mindustry/input/DesktopInput.java | 5 +- core/src/mindustry/io/JsonIO.java | 6 +- core/src/mindustry/mod/ContentParser.java | 2 +- core/src/mindustry/type/LiquidStack.java | 4 +- core/src/mindustry/type/Sector.java | 3 + .../type/{Zone.java => SectorPreset.java} | 8 +- core/src/mindustry/type/UnitType.java | 5 +- .../mindustry/ui/dialogs/ZoneInfoDialog.java | 4 +- core/src/mindustry/world/meta/Producers.java | 17 ++- .../src/mindustry/desktop/steam/SStats.java | 2 +- tests/src/test/java/ZoneTests.java | 2 +- 23 files changed, 211 insertions(+), 71 deletions(-) create mode 100644 core/src/mindustry/ai/types/FlyingAI.java create mode 100644 core/src/mindustry/ai/types/GroundAI.java rename core/src/mindustry/type/{Zone.java => SectorPreset.java} (96%) diff --git a/core/src/mindustry/ai/types/FlyingAI.java b/core/src/mindustry/ai/types/FlyingAI.java new file mode 100644 index 0000000000..538ab2fe2b --- /dev/null +++ b/core/src/mindustry/ai/types/FlyingAI.java @@ -0,0 +1,7 @@ +package mindustry.ai.types; + +import mindustry.entities.units.*; + +public class FlyingAI extends AIController{ + +} diff --git a/core/src/mindustry/ai/types/GroundAI.java b/core/src/mindustry/ai/types/GroundAI.java new file mode 100644 index 0000000000..a045620292 --- /dev/null +++ b/core/src/mindustry/ai/types/GroundAI.java @@ -0,0 +1,100 @@ +package mindustry.ai.types; + +import arc.util.*; +import mindustry.ai.Pathfinder.*; +import mindustry.entities.*; +import mindustry.entities.units.*; +import mindustry.game.*; +import mindustry.gen.*; +import mindustry.world.*; + +import static mindustry.Vars.pathfinder; + +public class GroundAI extends AIController{ + + @Override + public void behavior(){ + //attack + Tilec core = unit.closestEnemyCore(); + + if(core == null) return; + + float dst = unit.dst(core); + + if(dst < unit.range() / 1.1f){ + target = core; + } + + if(dst > unit.range() * 0.5f){ + moveToCore(PathTarget.enemyCores); + } + + boolean rotate = false, shoot = false; + + if(!Units.invalidateTarget(target, unit, unit.range())){ + rotate = true; + shoot = unit.within(target, unit.range()); + + if(unit.type().hasWeapons()){ + unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed)); + } + } + + unit.controlWeapons(rotate, shoot); + } + + @Override + public void targeting(){ + + if(Units.invalidateTarget(target, unit.team(), unit.x(), unit.y(), Float.MAX_VALUE)){ + target = null; + + //TODO this is hacky, cleanup + if(unit instanceof Legsc){ + unit.lookAt(((Legsc)unit).baseRotation()); + } + } + + if(retarget()){ + targetClosest(); + } + } + + protected void moveToCore(PathTarget path){ + Tile tile = unit.tileOn(); + if(tile == null) return; + Tile targetTile = pathfinder.getTargetTile(tile, unit.team(), path); + + if(tile == targetTile) return; + + unit.moveAt(vec.trns(unit.angleTo(targetTile), unit.type().speed * Time.delta())); + } + + protected void moveAwayFromCore(){ + Team enemy = null; + for(Team team : unit.team().enemies()){ + if(team.active()){ + enemy = team; + break; + } + } + + if(enemy == null){ + for(Team team : unit.team().enemies()){ + enemy = team; + break; + } + } + + if(enemy == null) return; + + Tile tile = unit.tileOn(); + if(tile == null) return; + Tile targetTile = pathfinder.getTargetTile(tile, enemy, PathTarget.enemyCores); + Tilec core = unit.closestCore(); + + if(tile == targetTile || core == null || unit.within(core, 120f)) return; + + unit.moveAt(vec.trns(unit.angleTo(targetTile), unit.type().speed * Time.delta())); + } +} diff --git a/core/src/mindustry/content/Zones.java b/core/src/mindustry/content/Zones.java index 796a5e6a4a..c216da3c65 100644 --- a/core/src/mindustry/content/Zones.java +++ b/core/src/mindustry/content/Zones.java @@ -2,7 +2,6 @@ package mindustry.content; import mindustry.ctype.*; import mindustry.game.Objectives.*; -import mindustry.game.*; import mindustry.maps.generators.*; import mindustry.type.*; @@ -12,7 +11,7 @@ import static mindustry.content.Planets.starter; import static mindustry.type.ItemStack.list; public class Zones implements ContentList{ - public static Zone + public static SectorPreset groundZero, desertWastes, craters, frozenForest, ruinousShores, stainedMountains, tarFields, fungalPass, saltFlats, overgrowth, impact0078, crags, @@ -21,7 +20,7 @@ public class Zones implements ContentList{ @Override public void load(){ - groundZero = new Zone("groundZero", starter, new FileMapGenerator("groundZero")){{ + groundZero = new SectorPreset("groundZero", starter, new FileMapGenerator("groundZero")){{ baseLaunchCost = list(copper, -60); startingItems = list(copper, 60); alwaysUnlocked = true; @@ -31,6 +30,7 @@ public class Zones implements ContentList{ }}; //TODO remove + /* desertWastes = new Zone("desertWastes", starter, new FileMapGenerator("groundZero")){{ startingItems = list(copper, 120); conditionWave = 20; @@ -80,9 +80,9 @@ public class Zones implements ContentList{ new ZoneWave(groundZero, 20), new Unlock(Blocks.combustionGenerator) ); - }}; + }};*/ - saltFlats = new Zone("saltFlats", starter, new FileMapGenerator("saltFlats")){{ + saltFlats = new SectorPreset("saltFlats", starter, new FileMapGenerator("saltFlats")){{ startingItems = list(copper, 200, Items.silicon, 200, lead, 200); loadout = Loadouts.basicFoundation; conditionWave = 10; @@ -98,7 +98,7 @@ public class Zones implements ContentList{ ); }}; - frozenForest = new Zone("frozenForest", starter, new FileMapGenerator("frozenForest")){{ + frozenForest = new SectorPreset("frozenForest", starter, new FileMapGenerator("frozenForest")){{ loadout = Loadouts.basicFoundation; startingItems = list(copper, 250); conditionWave = 10; @@ -110,7 +110,7 @@ public class Zones implements ContentList{ ); }}; - craters = new Zone("craters", starter, new FileMapGenerator("craters")){{ + craters = new SectorPreset("craters", starter, new FileMapGenerator("craters")){{ startingItems = list(copper, 100); conditionWave = 10; resources = with(copper, lead, coal, sand, scrap); @@ -121,7 +121,7 @@ public class Zones implements ContentList{ ); }}; - ruinousShores = new Zone("ruinousShores", starter, new FileMapGenerator("ruinousShores")){{ + ruinousShores = new SectorPreset("ruinousShores", starter, new FileMapGenerator("ruinousShores")){{ loadout = Loadouts.basicFoundation; startingItems = list(copper, 140, lead, 50); conditionWave = 20; @@ -137,7 +137,7 @@ public class Zones implements ContentList{ ); }}; - stainedMountains = new Zone("stainedMountains", starter, new FileMapGenerator("stainedMountains")){{ + stainedMountains = new SectorPreset("stainedMountains", starter, new FileMapGenerator("stainedMountains")){{ loadout = Loadouts.basicFoundation; startingItems = list(copper, 200, lead, 50); conditionWave = 10; @@ -151,7 +151,7 @@ public class Zones implements ContentList{ ); }}; - fungalPass = new Zone("fungalPass", starter, new FileMapGenerator("fungalPass")){{ + fungalPass = new SectorPreset("fungalPass", starter, new FileMapGenerator("fungalPass")){{ startingItems = list(copper, 250, lead, 250, Items.metaglass, 100, Items.graphite, 100); resources = with(copper, lead, coal, titanium, sand); configureObjective = new Launched(this); @@ -164,7 +164,7 @@ public class Zones implements ContentList{ ); }}; - overgrowth = new Zone("overgrowth", starter, new FileMapGenerator("overgrowth")){{ + overgrowth = new SectorPreset("overgrowth", starter, new FileMapGenerator("overgrowth")){{ startingItems = list(copper, 1500, lead, 1000, Items.silicon, 500, Items.metaglass, 250); conditionWave = 12; launchPeriod = 4; @@ -181,7 +181,7 @@ public class Zones implements ContentList{ ); }}; - tarFields = new Zone("tarFields", starter, new FileMapGenerator("tarFields")){{ + tarFields = new SectorPreset("tarFields", starter, new FileMapGenerator("tarFields")){{ loadout = Loadouts.basicFoundation; startingItems = list(copper, 250, lead, 100); conditionWave = 15; @@ -195,7 +195,7 @@ public class Zones implements ContentList{ ); }}; - desolateRift = new Zone("desolateRift", starter, new FileMapGenerator("desolateRift")){{ + desolateRift = new SectorPreset("desolateRift", starter, new FileMapGenerator("desolateRift")){{ loadout = Loadouts.basicNucleus; startingItems = list(copper, 1000, lead, 1000, Items.graphite, 250, titanium, 250, Items.silicon, 250); conditionWave = 3; @@ -220,7 +220,7 @@ public class Zones implements ContentList{ resources = Array.with(Items.copper, Items.scrap, Items.lead, Items.coal, Items.sand}; }};*/ - nuclearComplex = new Zone("nuclearComplex", starter, new FileMapGenerator("nuclearProductionComplex")){{ + nuclearComplex = new SectorPreset("nuclearComplex", starter, new FileMapGenerator("nuclearProductionComplex")){{ loadout = Loadouts.basicNucleus; startingItems = list(copper, 1250, lead, 1500, Items.silicon, 400, Items.metaglass, 250); conditionWave = 30; diff --git a/core/src/mindustry/core/ContentLoader.java b/core/src/mindustry/core/ContentLoader.java index 007abc2a68..7b6c1069ca 100644 --- a/core/src/mindustry/core/ContentLoader.java +++ b/core/src/mindustry/core/ContentLoader.java @@ -265,7 +265,7 @@ public class ContentLoader{ return (BulletType)getByID(ContentType.bullet, id); } - public Array zones(){ + public Array zones(){ return getBy(ContentType.zone); } diff --git a/core/src/mindustry/entities/def/FlyingComp.java b/core/src/mindustry/entities/def/FlyingComp.java index bd230cc194..022caf513d 100644 --- a/core/src/mindustry/entities/def/FlyingComp.java +++ b/core/src/mindustry/entities/def/FlyingComp.java @@ -36,10 +36,6 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{ y += Mathf.cos(Time.time() + id() * 99, 25f, 0.05f) * Time.delta() * elevation; } - void moveAt(Vec2 vector){ - moveAt(vector, 1f); - } - void moveAt(Vec2 vector, float acceleration){ Vec2 t = Tmp.v3.set(vector).scl(floorSpeedMultiplier()); //target vector Tmp.v1.set(t).sub(vel).limit(acceleration * vector.len()); //delta vector diff --git a/core/src/mindustry/entities/def/TeamComp.java b/core/src/mindustry/entities/def/TeamComp.java index d60109c52b..3ad28ff669 100644 --- a/core/src/mindustry/entities/def/TeamComp.java +++ b/core/src/mindustry/entities/def/TeamComp.java @@ -13,8 +13,11 @@ abstract class TeamComp implements Posc{ Team team = Team.derelict; - public @Nullable - Tilec closestCore(){ + public @Nullable Tilec closestCore(){ return state.teams.closestCore(x, y, team); } + + public @Nullable Tilec closestEnemyCore(){ + return state.teams.closestEnemyCore(x, y, team); + } } diff --git a/core/src/mindustry/entities/def/UnitComp.java b/core/src/mindustry/entities/def/UnitComp.java index 9610790017..39e96c4369 100644 --- a/core/src/mindustry/entities/def/UnitComp.java +++ b/core/src/mindustry/entities/def/UnitComp.java @@ -25,6 +25,15 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox private UnitController controller; private UnitType type; + public void moveAt(Vec2 vector){ + moveAt(vector, type.accel); + } + + public void aimLook(Position pos){ + aim(pos); + lookAt(pos); + } + @Override public float clipSize(){ return type.region.getWidth() * 2f; diff --git a/core/src/mindustry/entities/def/WeaponsComp.java b/core/src/mindustry/entities/def/WeaponsComp.java index 9b9c5a7cd4..8bf7dc6916 100644 --- a/core/src/mindustry/entities/def/WeaponsComp.java +++ b/core/src/mindustry/entities/def/WeaponsComp.java @@ -21,11 +21,14 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{ /** weapon mount array, never null */ @ReadOnly WeaponMount[] mounts = {}; + @ReadOnly float range; void setupWeapons(UnitType def){ mounts = new WeaponMount[def.weapons.size]; + range = 0f; for(int i = 0; i < mounts.length; i++){ mounts[i] = new WeaponMount(def.weapons.get(i)); + range = Math.max(range, def.weapons.get(i).bullet.range()); } } diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index 00a8acfd4d..7ef4805e4c 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -1,12 +1,43 @@ package mindustry.entities.units; -import arc.math.*; +import arc.math.geom.*; +import arc.util.*; +import mindustry.entities.*; import mindustry.gen.*; public class AIController implements UnitController{ - protected Unitc unit; + protected static final Vec2 vec = new Vec2(); + protected static final int timerTarget = 0; - float rot = Mathf.random(360f); + protected Unitc unit; + protected Teamc target; + protected Interval timer = new Interval(4); + + @Override + public void update(){ + targeting(); + behavior(); + } + + protected boolean retarget(){ + return timer.get(timerTarget, 20); + } + + protected void targetClosest(){ + Teamc newTarget = Units.closestTarget(unit.team(), unit.x(), unit.y(), Math.max(unit.range(), unit.type().range), u -> unit.type().targetAir || !u.isFlying()); + if(newTarget != null){ + target = newTarget; + } + } + + + public void targeting(){ + + } + + public void behavior(){ + + } @Override public void unit(Unitc unit){ @@ -17,15 +48,4 @@ public class AIController implements UnitController{ public Unitc unit(){ return unit; } - - @Override - public void update(){ - //TODO implement - //rot += Mathf.range(3f) * Time.delta(); - - //unit.moveAt(Tmp.v1.trns(rot, unit.type().speed)); - //if(!unit.vel().isZero()){ - // unit.lookAt(unit.vel().angle()); - //} - } } diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index d5365649bf..590b9e6f1c 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -72,10 +72,10 @@ public class EventType{ /** Called when a zone's requirements are met. */ public static class ZoneRequireCompleteEvent{ - public final Zone zoneMet, zoneForMet; + public final SectorPreset zoneMet, zoneForMet; public final Objective objective; - public ZoneRequireCompleteEvent(Zone zoneMet, Zone zoneForMet, Objective objective){ + public ZoneRequireCompleteEvent(SectorPreset zoneMet, SectorPreset zoneForMet, Objective objective){ this.zoneMet = zoneMet; this.zoneForMet = zoneForMet; this.objective = objective; @@ -84,9 +84,9 @@ public class EventType{ /** Called when a zone's requirements are met. */ public static class ZoneConfigureCompleteEvent{ - public final Zone zone; + public final SectorPreset zone; - public ZoneConfigureCompleteEvent(Zone zone){ + public ZoneConfigureCompleteEvent(SectorPreset zone){ this.zone = zone; } } diff --git a/core/src/mindustry/game/Objective.java b/core/src/mindustry/game/Objective.java index 344fd728de..14436e4171 100644 --- a/core/src/mindustry/game/Objective.java +++ b/core/src/mindustry/game/Objective.java @@ -21,7 +21,7 @@ public interface Objective{ } - default Zone zone(){ + 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 82561fe4a2..590a277c5c 100644 --- a/core/src/mindustry/game/Objectives.java +++ b/core/src/mindustry/game/Objectives.java @@ -53,7 +53,7 @@ public class Objectives{ public static class ZoneWave extends ZoneObjective{ public int wave; - public ZoneWave(Zone zone, int wave){ + public ZoneWave(SectorPreset zone, int wave){ this.zone = zone; this.wave = wave; } @@ -73,7 +73,7 @@ public class Objectives{ public static class Launched extends ZoneObjective{ - public Launched(Zone zone){ + public Launched(SectorPreset zone){ this.zone = zone; } @@ -91,6 +91,6 @@ public class Objectives{ } public abstract static class ZoneObjective implements Objective{ - public @NonNull Zone zone; + public @NonNull SectorPreset zone; } } diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 175186e835..02d40f84ea 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -13,7 +13,6 @@ import arc.scene.ui.layout.*; import arc.util.ArcAnnotate.*; import arc.util.*; import mindustry.*; -import mindustry.core.GameState.*; import mindustry.entities.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; @@ -517,9 +516,9 @@ public class DesktopInput extends InputHandler{ } if(omni){ - unit.moveAt(movement, unit.type().accel); + unit.moveAt(movement); }else{ - unit.moveAt(Tmp.v2.trns(unit.rotation(), movement.len()), unit.type().accel); + unit.moveAt(Tmp.v2.trns(unit.rotation(), movement.len())); if(!movement.isZero()){ unit.vel().rotateTo(movement.angle(), unit.type().rotateSpeed * Time.delta()); } diff --git a/core/src/mindustry/io/JsonIO.java b/core/src/mindustry/io/JsonIO.java index a4dab2f78d..056d182812 100644 --- a/core/src/mindustry/io/JsonIO.java +++ b/core/src/mindustry/io/JsonIO.java @@ -81,14 +81,14 @@ public class JsonIO{ } }); - json.setSerializer(Zone.class, new Serializer(){ + json.setSerializer(SectorPreset.class, new Serializer(){ @Override - public void write(Json json, Zone object, Class knownType){ + public void write(Json json, SectorPreset object, Class knownType){ json.writeValue(object.name); } @Override - public Zone read(Json json, JsonValue jsonData, Class type){ + public SectorPreset read(Json json, JsonValue jsonData, Class type){ return Vars.content.getByName(ContentType.zone, jsonData.asString()); } }); diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index fd456df806..445ff64828 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -303,7 +303,7 @@ public class ContentParser{ }, ContentType.item, parser(ContentType.item, Item::new), ContentType.liquid, parser(ContentType.liquid, Liquid::new), - ContentType.zone, parser(ContentType.zone, Zone::new) + ContentType.zone, parser(ContentType.zone, SectorPreset::new) ); private String getString(JsonValue value, String key){ diff --git a/core/src/mindustry/type/LiquidStack.java b/core/src/mindustry/type/LiquidStack.java index 76df881fdf..4afdd9c034 100644 --- a/core/src/mindustry/type/LiquidStack.java +++ b/core/src/mindustry/type/LiquidStack.java @@ -1,5 +1,7 @@ package mindustry.type; +import mindustry.content.*; + public class LiquidStack{ public Liquid liquid; public float amount; @@ -11,7 +13,7 @@ public class LiquidStack{ /** serialization only*/ protected LiquidStack(){ - + liquid = Liquids.water; } @Override diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 988e579f51..3c3c4d2f28 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -23,6 +23,9 @@ public class Sector{ public @Nullable SaveSlot save; public boolean unlocked; + /** */ + public float hostility; + //TODO implement a dynamic (?) launch period public int launchPeriod = 10; diff --git a/core/src/mindustry/type/Zone.java b/core/src/mindustry/type/SectorPreset.java similarity index 96% rename from core/src/mindustry/type/Zone.java rename to core/src/mindustry/type/SectorPreset.java index 0ccc80b213..e21b5da566 100644 --- a/core/src/mindustry/type/Zone.java +++ b/core/src/mindustry/type/SectorPreset.java @@ -15,7 +15,7 @@ import mindustry.maps.generators.*; import static mindustry.Vars.*; //TODO ? remove ? -public class Zone extends UnlockableContent{ +public class SectorPreset extends UnlockableContent{ public @NonNull WorldGenerator generator; public @NonNull Objective configureObjective = new ZoneWave(this, 15); public @NonNull Planet planet; @@ -35,13 +35,13 @@ public class Zone extends UnlockableContent{ private Array defaultStartingItems = new Array<>(); - public Zone(String name, Planet planet, WorldGenerator generator){ + public SectorPreset(String name, Planet planet, WorldGenerator generator){ super(name); this.generator = generator; this.planet = planet; } - public Zone(String name){ + public SectorPreset(String name){ this(name, Planets.starter, new FileMapGenerator(name)); } @@ -103,7 +103,7 @@ public class Zone extends UnlockableContent{ public void updateObjectives(Runnable closure){ Array incomplete = content.zones() - .map(z -> z.requirements).flatten() + .flatMap(z -> z.requirements) .select(o -> o.zone() == this && !o.complete()) .as(ZoneObjective.class); diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 0aa3f3f68c..7a41c1d4c0 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -10,6 +10,7 @@ import arc.scene.ui.layout.*; import arc.struct.*; import arc.util.ArcAnnotate.*; import arc.util.*; +import mindustry.ai.types.*; import mindustry.annotations.Annotations.*; import mindustry.ctype.*; import mindustry.entities.units.*; @@ -24,9 +25,9 @@ import static mindustry.Vars.*; public class UnitType extends UnlockableContent{ static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f); - public @NonNull Prov defaultController = AIController::new; - public @NonNull Prov constructor; public boolean flying; + public @NonNull Prov constructor; + public @NonNull Prov defaultController = () -> !flying ? new GroundAI() : new FlyingAI(); public float speed = 1.1f, boostSpeed = 0.75f, rotateSpeed = 6f, baseRotateSpeed = 10f; public float drag = 0.3f, mass = 1f, accel = 0.9f; public float health = 200f, range = -1; diff --git a/core/src/mindustry/ui/dialogs/ZoneInfoDialog.java b/core/src/mindustry/ui/dialogs/ZoneInfoDialog.java index 914db8c7db..9b2902f033 100644 --- a/core/src/mindustry/ui/dialogs/ZoneInfoDialog.java +++ b/core/src/mindustry/ui/dialogs/ZoneInfoDialog.java @@ -25,12 +25,12 @@ public class ZoneInfoDialog extends FloatingDialog{ addCloseButton(); } - public void show(Zone zone){ + public void show(SectorPreset zone){ setup(zone); show(); } - private void setup(Zone zone){ + private void setup(SectorPreset zone){ cont.clear(); Table iteminfo = new Table(); diff --git a/core/src/mindustry/world/meta/Producers.java b/core/src/mindustry/world/meta/Producers.java index 576341b4ad..eaa52f76cf 100644 --- a/core/src/mindustry/world/meta/Producers.java +++ b/core/src/mindustry/world/meta/Producers.java @@ -1,19 +1,16 @@ package mindustry.world.meta; -import mindustry.ctype.Content; +import arc.struct.*; +import mindustry.gen.*; public class Producers{ - private Content output; + private Array producers = new Array<>(); - public void set(Content content){ - this.output = content; + public void add(Produce prod){ + producers.add(prod); } - public Content get(){ - return output; - } - - public boolean is(Content content){ - return content == output; + interface Produce{ + void add(Tilec entity); } } diff --git a/desktop/src/mindustry/desktop/steam/SStats.java b/desktop/src/mindustry/desktop/steam/SStats.java index a2ddfa675a..570fba6d09 100644 --- a/desktop/src/mindustry/desktop/steam/SStats.java +++ b/desktop/src/mindustry/desktop/steam/SStats.java @@ -146,7 +146,7 @@ public class SStats implements SteamUserStatsCallback{ if(e.content == Items.thorium) obtainThorium.complete(); if(e.content == Items.titanium) obtainTitanium.complete(); - if(!content.zones().contains(Zone::locked)){ + if(!content.zones().contains(SectorPreset::locked)){ unlockAllZones.complete(); } }); diff --git a/tests/src/test/java/ZoneTests.java b/tests/src/test/java/ZoneTests.java index 2d35858f03..d208fb5d81 100644 --- a/tests/src/test/java/ZoneTests.java +++ b/tests/src/test/java/ZoneTests.java @@ -36,7 +36,7 @@ public class ZoneTests{ if(true) return new DynamicTest[0]; //fail("Zone validity tests need to be refactored!"); - for(Zone zone : content.zones()){ + for(SectorPreset zone : content.zones()){ out.add(dynamicTest(zone.name, () -> { logic.reset(); try{