diff --git a/annotations/src/main/java/mindustry/annotations/entity/EntityIO.java b/annotations/src/main/java/mindustry/annotations/entity/EntityIO.java index 4513695621..2ec0185aef 100644 --- a/annotations/src/main/java/mindustry/annotations/entity/EntityIO.java +++ b/annotations/src/main/java/mindustry/annotations/entity/EntityIO.java @@ -19,6 +19,8 @@ public class EntityIO{ final static Json json = new Json(); //suffixes for sync fields final static String targetSuf = "_TARGET_", lastSuf = "_LAST_"; + //replacements after refactoring + final static StringMap replacements = StringMap.of("mindustry.entities.units.BuildRequest", "mindustry.entities.units.BuildPlan"); final ClassSerializer serializer; final String name; @@ -198,6 +200,7 @@ public class EntityIO{ private void io(String type, String field) throws Exception{ type = type.replace("mindustry.gen.", ""); + type = replacements.get(type, type); if(BaseProcessor.isPrimitive(type)){ s(type.equals("boolean") ? "bool" : type.charAt(0) + "", field); diff --git a/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnitEntity/1.json b/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnitEntity/1.json new file mode 100644 index 0000000000..127433266b --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnitEntity/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMechUnitEntity/1.json b/annotations/src/main/resources/revisions/BuilderMechUnitEntity/1.json new file mode 100644 index 0000000000..61c5d89424 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMechUnitEntity/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMinerPayloadUnitEntity/1.json b/annotations/src/main/resources/revisions/BuilderMinerPayloadUnitEntity/1.json new file mode 100644 index 0000000000..eb4c072449 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMinerPayloadUnitEntity/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:payloads,type:arc.struct.Seq,size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMinerUnitEntity/1.json b/annotations/src/main/resources/revisions/BuilderMinerUnitEntity/1.json new file mode 100644 index 0000000000..ebaf0c0c21 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMinerUnitEntity/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderUnitEntity/1.json b/annotations/src/main/resources/revisions/BuilderUnitEntity/1.json new file mode 100644 index 0000000000..170f6b7766 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderUnitEntity/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/core/src/mindustry/ai/BaseAI.java b/core/src/mindustry/ai/BaseAI.java index 0700bd7d73..b99610ba76 100644 --- a/core/src/mindustry/ai/BaseAI.java +++ b/core/src/mindustry/ai/BaseAI.java @@ -14,7 +14,6 @@ import mindustry.type.*; import mindustry.world.*; import mindustry.world.blocks.defense.*; import mindustry.world.blocks.production.*; -import mindustry.world.blocks.storage.CoreBlock.*; import static mindustry.Vars.*; @@ -48,10 +47,13 @@ public class BaseAI{ for(int i = 0; i < attempts; i++){ int range = 150; - CoreEntity core = data.cores.random(); + + Position pos = randomPosition(); + //when there are no random positions, do nothing. + if(pos == null) return; Tmp.v1.rnd(Mathf.random(range)); - int wx = (int)(core.tileX() + Tmp.v1.x), wy = (int)(core.tileY() + Tmp.v1.y); + int wx = (int)(world.toTile(pos.getX()) + Tmp.v1.x), wy = (int)(world.toTile(pos.getY()) + Tmp.v1.y); Tile tile = world.tiles.getc(wx, wy); Seq parts = null; @@ -74,7 +76,17 @@ public class BaseAI{ } } - boolean tryPlace(BasePart part, int x, int y){ + /** @return a random position from which to seed building. */ + private Position randomPosition(){ + if(data.hasCore()){ + return data.cores.random(); + }else if(data.team == state.rules.waveTeam){ + return spawner.getSpawns().random(); + } + return null; + } + + private boolean tryPlace(BasePart part, int x, int y){ int rotation = Mathf.range(2); axis.set((int)(part.schematic.width / 2f), (int)(part.schematic.height / 2f)); Schematic result = Schematics.rotate(part.schematic, rotation); @@ -131,7 +143,7 @@ public class BaseAI{ return true; } - void tryWalls(){ + private void tryWalls(){ Block wall = Blocks.copperWall; Tile spawn = state.rules.defaultTeam.core() != null ? state.rules.defaultTeam.core().tile : data.team.core().tile; diff --git a/core/src/mindustry/ai/types/BuilderAI.java b/core/src/mindustry/ai/types/BuilderAI.java index 4fd4667c58..31486988f9 100644 --- a/core/src/mindustry/ai/types/BuilderAI.java +++ b/core/src/mindustry/ai/types/BuilderAI.java @@ -23,8 +23,8 @@ public class BuilderAI extends AIController{ } //approach request if building - if(builder.buildRequest() != null){ - BuildRequest req = builder.buildRequest(); + if(builder.buildPlan() != null){ + BuildPlan req = builder.buildPlan(); boolean valid = (req.tile().entity instanceof BuildEntity && req.tile().ent().cblock == req.block) || @@ -37,7 +37,7 @@ public class BuilderAI extends AIController{ moveTo(req.tile(), buildingRange - 20f); }else{ //discard invalid request - builder.requests().removeFirst(); + builder.plans().removeFirst(); } }else{ //find new request @@ -50,7 +50,7 @@ public class BuilderAI extends AIController{ blocks.removeFirst(); }else if(Build.validPlace(content.block(block.block), unit.team(), block.x, block.y, block.rotation)){ //it's valid. //add build request. - BuildRequest req = new BuildRequest(block.x, block.y, block.rotation, content.block(block.block)); + BuildPlan req = new BuildPlan(block.x, block.y, block.rotation, content.block(block.block)); if(block.config != null){ req.configure(block.config); } diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 871979bcaf..e1096d726f 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -311,17 +311,9 @@ public class Logic implements ApplicationListener{ updateWeather(); for(TeamData data : state.teams.getActive()){ - if(data.hasAI() && data.hasCore()){ + if(data.hasAI()){ data.ai.update(); } - - //TODO this is terrible - //fills enemy core with resources - if(state.rules.enemyInfiniteResources && state.rules.waves && data.team == state.rules.waveTeam && data.hasCore()){ - for(Item item : content.items()){ - data.core().items.set(item, data.core().block.itemCapacity); - } - } } } diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 4b1ffb2452..2cb3719ecf 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -552,14 +552,14 @@ public class NetClient implements ApplicationListener{ void sync(){ if(timer.get(0, playerSyncTime)){ - BuildRequest[] requests = null; + BuildPlan[] requests = null; if(player.isBuilder() && control.input.isBuilding){ //limit to 10 to prevent buffer overflows - int usedRequests = Math.min(player.builder().requests().size, 10); + int usedRequests = Math.min(player.builder().plans().size, 10); - requests = new BuildRequest[usedRequests]; + requests = new BuildPlan[usedRequests]; for(int i = 0; i < usedRequests; i++){ - requests[i] = player.builder().requests().get(i); + requests[i] = player.builder().plans().get(i); } } diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index 0c475b459f..5eb1d6f9c0 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -533,7 +533,7 @@ public class NetServer implements ApplicationListener{ float xVelocity, float yVelocity, Tile mining, boolean boosting, boolean shooting, boolean chatting, - @Nullable BuildRequest[] requests, + @Nullable BuildPlan[] requests, float viewX, float viewY, float viewWidth, float viewHeight ){ NetConnection connection = player.con(); @@ -571,7 +571,7 @@ public class NetServer implements ApplicationListener{ } if(requests != null){ - for(BuildRequest req : requests){ + for(BuildPlan req : requests){ if(req == null) continue; Tile tile = world.tile(req.x, req.y); if(tile == null || (!req.breaking && req.block == null)) continue; @@ -592,7 +592,7 @@ public class NetServer implements ApplicationListener{ connection.rejectedRequests.add(req); continue; } - player.builder().requests().addLast(req); + player.builder().plans().addLast(req); } } diff --git a/core/src/mindustry/entities/comp/BuilderComp.java b/core/src/mindustry/entities/comp/BuilderComp.java index 003536df39..b90fb18472 100644 --- a/core/src/mindustry/entities/comp/BuilderComp.java +++ b/core/src/mindustry/entities/comp/BuilderComp.java @@ -28,7 +28,7 @@ abstract class BuilderComp implements Unitc{ @Import float x, y, rotation; - Queue requests = new Queue<>(); + Queue plans = new Queue<>(); transient float buildSpeed = 1f; transient boolean building = true; @@ -44,32 +44,32 @@ abstract class BuilderComp implements Unitc{ float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : buildingRange; - Iterator it = requests.iterator(); + Iterator it = plans.iterator(); while(it.hasNext()){ - BuildRequest req = it.next(); + BuildPlan req = it.next(); Tile tile = world.tile(req.x, req.y); if(tile == null || (req.breaking && tile.block() == Blocks.air) || (!req.breaking && (tile.rotation() == req.rotation || !req.block.rotate) && tile.block() == req.block)){ it.remove(); } } - Tilec core = closestCore(); + Tilec core = core(); //nothing to build. - if(buildRequest() == null) return; + if(buildPlan() == null) return; //find the next build request - if(requests.size > 1){ + if(plans.size > 1){ int total = 0; - BuildRequest req; - while((dst((req = buildRequest()).tile()) > finalPlaceDst || shouldSkip(req, core)) && total < requests.size){ - requests.removeFirst(); - requests.addLast(req); + BuildPlan req; + while((dst((req = buildPlan()).tile()) > finalPlaceDst || shouldSkip(req, core)) && total < plans.size){ + plans.removeFirst(); + plans.addLast(req); total++; } } - BuildRequest current = buildRequest(); + BuildPlan current = buildPlan(); if(dst(current.tile()) > finalPlaceDst) return; @@ -91,11 +91,11 @@ abstract class BuilderComp implements Unitc{ }else if(!current.initialized && current.breaking && Build.validBreak(team(), current.x, current.y)){ Build.beginBreak(team(), current.x, current.y); }else{ - requests.removeFirst(); + plans.removeFirst(); return; } }else if(tile.team() != team()){ - requests.removeFirst(); + plans.removeFirst(); return; } @@ -130,8 +130,8 @@ abstract class BuilderComp implements Unitc{ /** Draw all current build requests. Does not draw the beam effect, only the positions. */ void drawBuildRequests(){ - for(BuildRequest request : requests){ - if(request.progress > 0.01f || (buildRequest() == request && request.initialized && (dst(request.x * tilesize, request.y * tilesize) <= buildingRange || state.isEditor()))) continue; + for(BuildPlan request : plans){ + if(request.progress > 0.01f || (buildPlan() == request && request.initialized && (dst(request.x * tilesize, request.y * tilesize) <= buildingRange || state.isEditor()))) continue; request.animScale = 1f; if(request.breaking){ @@ -146,7 +146,7 @@ abstract class BuilderComp implements Unitc{ } /** @return whether this request should be skipped, in favor of the next one. */ - boolean shouldSkip(BuildRequest request, @Nullable Tilec core){ + boolean shouldSkip(BuildPlan request, @Nullable Tilec core){ //requests that you have at least *started* are considered if(state.rules.infiniteResources || request.breaking || core == null) return false; //TODO these are bad criteria @@ -155,53 +155,54 @@ abstract class BuilderComp implements Unitc{ void removeBuild(int x, int y, boolean breaking){ //remove matching request - int idx = requests.indexOf(req -> req.breaking == breaking && req.x == x && req.y == y); + int idx = plans.indexOf(req -> req.breaking == breaking && req.x == x && req.y == y); if(idx != -1){ - requests.removeIndex(idx); + plans.removeIndex(idx); } } /** Return whether this builder's place queue contains items. */ boolean isBuilding(){ - return requests.size != 0; + return plans.size != 0; } /** Clears the placement queue. */ void clearBuilding(){ - requests.clear(); + plans.clear(); } /** Add another build requests to the tail of the queue, if it doesn't exist there yet. */ - void addBuild(BuildRequest place){ + void addBuild(BuildPlan place){ addBuild(place, true); } /** Add another build requests to the queue, if it doesn't exist there yet. */ - void addBuild(BuildRequest place, boolean tail){ - BuildRequest replace = null; - for(BuildRequest request : requests){ + void addBuild(BuildPlan place, boolean tail){ + BuildPlan replace = null; + for(BuildPlan request : plans){ if(request.x == place.x && request.y == place.y){ replace = request; break; } } if(replace != null){ - requests.remove(replace); + plans.remove(replace); } Tile tile = world.tile(place.x, place.y); if(tile != null && tile.entity instanceof BuildEntity){ place.progress = tile.ent().progress; } if(tail){ - requests.addLast(place); + plans.addLast(place); }else{ - requests.addFirst(place); + plans.addFirst(place); } } - /** Return the build requests currently active, or the one at the top of the queue.*/ - @Nullable BuildRequest buildRequest(){ - return requests.size == 0 ? null : requests.first(); + /** Return the build request currently active, or the one at the top of the queue.*/ + @Nullable + BuildPlan buildPlan(){ + return plans.size == 0 ? null : plans.first(); } @Override @@ -211,15 +212,15 @@ abstract class BuilderComp implements Unitc{ //TODO check correctness Draw.z(Layer.flyingUnit); - BuildRequest request = buildRequest(); - Tile tile = world.tile(request.x, request.y); + BuildPlan plan = buildPlan(); + Tile tile = world.tile(plan.x, plan.y); if(dst(tile) > buildingRange && !state.isEditor()){ return; } - int size = request.breaking ? tile.block().size : request.block.size; - float tx = request.drawx(), ty = request.drawy(); + int size = plan.breaking ? tile.block().size : plan.block.size; + float tx = plan.drawx(), ty = plan.drawy(); Lines.stroke(1f, Pal.accent); float focusLen = 3.8f + Mathf.absin(Time.time(), 1.1f, 0.6f); diff --git a/core/src/mindustry/entities/comp/BulletComp.java b/core/src/mindustry/entities/comp/BulletComp.java index 345dd99192..70415cb415 100644 --- a/core/src/mindustry/entities/comp/BulletComp.java +++ b/core/src/mindustry/entities/comp/BulletComp.java @@ -58,7 +58,6 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw @Override public void absorb(){ - //TODO remove(); } diff --git a/core/src/mindustry/entities/comp/PlayerComp.java b/core/src/mindustry/entities/comp/PlayerComp.java index 99248a0d14..63d27a8e95 100644 --- a/core/src/mindustry/entities/comp/PlayerComp.java +++ b/core/src/mindustry/entities/comp/PlayerComp.java @@ -54,6 +54,10 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra return state.teams.closestCore(x(), y(), team); } + public @Nullable CoreEntity core(){ + return team.core(); + } + public void reset(){ team = state.rules.defaultTeam; admin = typing = false; @@ -87,8 +91,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra CoreEntity core = closestCore(); if(!dead()){ - x(unit.x()); - y(unit.y()); + set(unit); unit.team(team); deathTimer = 0; diff --git a/core/src/mindustry/entities/comp/TeamComp.java b/core/src/mindustry/entities/comp/TeamComp.java index 393b6158da..9f6791002d 100644 --- a/core/src/mindustry/entities/comp/TeamComp.java +++ b/core/src/mindustry/entities/comp/TeamComp.java @@ -13,6 +13,14 @@ abstract class TeamComp implements Posc{ Team team = Team.derelict; + public boolean cheating(){ + return team.rules().cheat; + } + + public @Nullable Tilec core(){ + return team.core(); + } + public @Nullable Tilec closestCore(){ return state.teams.closestCore(x, y, team); } diff --git a/core/src/mindustry/entities/units/BuildRequest.java b/core/src/mindustry/entities/units/BuildPlan.java similarity index 89% rename from core/src/mindustry/entities/units/BuildRequest.java rename to core/src/mindustry/entities/units/BuildPlan.java index 621871efb7..af7d760219 100644 --- a/core/src/mindustry/entities/units/BuildRequest.java +++ b/core/src/mindustry/entities/units/BuildPlan.java @@ -8,7 +8,7 @@ import mindustry.world.*; import static mindustry.Vars.*; /** Class for storing build requests. Can be either a place or remove request. */ -public class BuildRequest{ +public class BuildPlan{ /** Position and rotation of this request. */ public int x, y, rotation; /** Block being placed. If null, this is a breaking request.*/ @@ -31,7 +31,7 @@ public class BuildRequest{ public float animScale = 0f; /** This creates a build request. */ - public BuildRequest(int x, int y, int rotation, Block block){ + public BuildPlan(int x, int y, int rotation, Block block){ this.x = x; this.y = y; this.rotation = rotation; @@ -40,7 +40,7 @@ public class BuildRequest{ } /** This creates a remove request. */ - public BuildRequest(int x, int y){ + public BuildPlan(int x, int y){ this.x = x; this.y = y; this.rotation = -1; @@ -48,7 +48,7 @@ public class BuildRequest{ this.breaking = true; } - public BuildRequest(){ + public BuildPlan(){ } @@ -74,8 +74,8 @@ public class BuildRequest{ this.config = pointConfig(this.config, cons); } - public BuildRequest copy(){ - BuildRequest copy = new BuildRequest(); + public BuildPlan copy(){ + BuildPlan copy = new BuildPlan(); copy.x = x; copy.y = y; copy.rotation = rotation; @@ -91,7 +91,7 @@ public class BuildRequest{ return copy; } - public BuildRequest original(int x, int y, int originalWidth, int originalHeight){ + public BuildPlan original(int x, int y, int originalWidth, int originalHeight){ originalX = x; originalY = y; this.originalWidth = originalWidth; @@ -107,7 +107,7 @@ public class BuildRequest{ } } - public BuildRequest set(int x, int y, int rotation, Block block){ + public BuildPlan set(int x, int y, int rotation, Block block){ this.x = x; this.y = y; this.rotation = rotation; @@ -124,7 +124,7 @@ public class BuildRequest{ return y*tilesize + block.offset(); } - public BuildRequest configure(Object config){ + public BuildPlan configure(Object config){ this.config = config; this.hasConfig = true; return this; diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index 335d7b58b9..bb9e42b278 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -3,6 +3,8 @@ package mindustry.game; import arc.graphics.*; import arc.struct.*; import arc.util.ArcAnnotate.*; +import arc.util.serialization.*; +import arc.util.serialization.Json.*; import mindustry.content.*; import mindustry.io.*; import mindustry.type.*; @@ -14,18 +16,26 @@ import mindustry.world.*; * Does not store game state, just configuration. */ public class Rules{ - /** Whether the player team has infinite resources. */ + /** Whether ever team has infinite resources and instant build speed. */ public boolean infiniteResources; + /** Team-specific rules. */ + public TeamRules teams = new TeamRules(); /** Whether the waves come automatically on a timer. If not, waves come when the play button is pressed. */ public boolean waveTimer = true; /** Whether waves are spawnable at all. */ public boolean waves; - /** Whether the enemy AI has infinite resources in most of their buildings and turrets. */ - public boolean enemyCheat; - /** Whether the enemy AI has infinite resources in their core only. TODO remove */ - public boolean enemyInfiniteResources = true; /** Whether the game objective is PvP. Note that this enables automatic hosting. */ public boolean pvp; + /** Whether to pause the wave timer until all enemies are destroyed. */ + public boolean waitEnemies = false; + /** Determinates if gamemode is attack mode */ + public boolean attackMode = false; + /** Whether this is the editor gamemode. */ + public boolean editor = false; + /** Whether the tutorial is enabled. False by default. */ + public boolean tutorial = false; + /** Whether a gameover can happen at all. Set this to false to implement custom gameover conditions. */ + public boolean canGameOver = true; /** Whether reactors can explode and damage other blocks. */ public boolean reactorExplosions = true; /** How fast unit pads build units. */ @@ -60,18 +70,6 @@ public class Rules{ public @Nullable Sector sector; /** Spawn layout. */ public Seq spawns = new Seq<>(); - /** Whether to pause the wave timer until all enemies are destroyed. */ - public boolean waitEnemies = false; - /** Determinates if gamemode is attack mode */ - public boolean attackMode = false; - /** Whether this is the editor gamemode. */ - public boolean editor = false; - /** Whether the tutorial is enabled. False by default. */ - public boolean tutorial = false; - /** Whether a gameover can happen at all. Set this to false to implement custom gameover conditions. */ - public boolean canGameOver = true; - /** EXPERIMENTAL building AI. TODO remove */ - public boolean buildAI = true; /** Starting items put in cores */ public Seq loadout = Seq.with(ItemStack.with(Items.copper, 100)); /** Weather events that occur here. */ @@ -92,6 +90,16 @@ public class Rules{ /** special tags for additional info */ public StringMap tags = new StringMap(); + /** A team-specific ruleset. */ + public static class TeamRule{ + /** Whether to use building AI. */ + public boolean ai; + /** If true, blocks don't require power or resources. */ + public boolean cheat; + /** If true, resources are not consumed when building. */ + public boolean infiniteResources; + } + /** Copies this ruleset exactly. Not efficient at all, do not use often. */ public Rules copy(){ return JsonIO.copy(this); @@ -111,4 +119,31 @@ public class Rules{ return Gamemode.survival; } } + + /** A simple map for storing TeamRules in an efficient way without hashing. */ + public static class TeamRules implements Serializable{ + final TeamRule[] values = new TeamRule[Team.all.length]; + + public TeamRule get(Team team){ + TeamRule out = values[team.uid]; + if(out == null) values[team.uid] = (out = new TeamRule()); + return out; + } + + @Override + public void write(Json json){ + for(Team team : Team.all){ + if(values[team.uid] != null){ + json.writeValue(team.uid + "", values[team.uid], TeamRule.class); + } + } + } + + @Override + public void read(Json json, JsonValue jsonData){ + for(JsonValue value : jsonData){ + values[Integer.parseInt(value.name)] = json.readValue(TeamRule.class, value); + } + } + } } diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index 5e087a4aba..f05b189c9c 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -246,7 +246,7 @@ public class Schematics implements Loadable{ Draw.rect(Tmp.tr1, buffer.getWidth()/2f, buffer.getHeight()/2f, buffer.getWidth(), -buffer.getHeight()); Draw.color(); - Seq requests = schematic.tiles.map(t -> new BuildRequest(t.x, t.y, t.rotation, t.block).configure(t.config)); + Seq requests = schematic.tiles.map(t -> new BuildPlan(t.x, t.y, t.rotation, t.block).configure(t.config)); Draw.flush(); //scale each request to fit schematic @@ -276,8 +276,8 @@ public class Schematics implements Loadable{ } /** Creates an array of build requests from a schematic's data, centered on the provided x+y coordinates. */ - public Seq toRequests(Schematic schem, int x, int y){ - return schem.tiles.map(t -> new BuildRequest(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block).original(t.x, t.y, schem.width, schem.height).configure(t.config)) + public Seq toRequests(Schematic schem, int x, int y){ + return schem.tiles.map(t -> new BuildPlan(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block).original(t.x, t.y, schem.width, schem.height).configure(t.config)) .removeAll(s -> !s.block.isVisible() || !s.block.unlockedCur()); } @@ -558,7 +558,7 @@ public class Schematics implements Loadable{ int ox = schem.width/2, oy = schem.height/2; schem.tiles.each(req -> { - req.config = BuildRequest.pointConfig(req.config, p -> { + req.config = BuildPlan.pointConfig(req.config, p -> { int cx = p.x, cy = p.y; int lx = cx; diff --git a/core/src/mindustry/game/Team.java b/core/src/mindustry/game/Team.java index c2948d875e..fd0273ac10 100644 --- a/core/src/mindustry/game/Team.java +++ b/core/src/mindustry/game/Team.java @@ -6,6 +6,7 @@ import arc.math.*; import arc.struct.*; import arc.util.*; import arc.util.ArcAnnotate.*; +import mindustry.game.Rules.*; import mindustry.game.Teams.*; import mindustry.graphics.*; import mindustry.world.blocks.storage.CoreBlock.*; @@ -55,6 +56,11 @@ public class Team implements Comparable{ all[us] = this; } + /** @return the team-specific rules. */ + public TeamRule rules(){ + return state.rules.teams.get(this); + } + public Seq enemies(){ return state.teams.enemiesOf(this); } diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index e14d37548c..fedfe2bb37 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -174,7 +174,7 @@ public class Teams{ /** @return whether this team is controlled by the AI and builds bases. */ public boolean hasAI(){ - return state.rules.attackMode && team == state.rules.waveTeam && state.rules.buildAI; + return state.rules.attackMode && team.rules().ai; } @Override diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 6ae7cfb81c..566188e2ec 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -42,7 +42,7 @@ public class DesktopInput extends InputHandler{ /** Animation scale for line. */ private float selectScale; /** Selected build request for movement. */ - private @Nullable BuildRequest sreq; + private @Nullable BuildPlan sreq; /** Whether player is currently deleting removal requests. */ private boolean deleting = false, shouldShoot = false; @@ -124,19 +124,19 @@ public class DesktopInput extends InputHandler{ //draw hover request if(mode == none && !isPlacing()){ - BuildRequest req = getRequest(cursorX, cursorY); + BuildPlan req = getRequest(cursorX, cursorY); if(req != null){ drawSelected(req.x, req.y, req.breaking ? req.tile().block() : req.block, Pal.accent); } } //draw schematic requests - for(BuildRequest request : selectRequests){ + for(BuildPlan request : selectRequests){ request.animScale = 1f; drawRequest(request); } - for(BuildRequest request : selectRequests){ + for(BuildPlan request : selectRequests){ drawOverRequest(request); } @@ -144,7 +144,7 @@ public class DesktopInput extends InputHandler{ //draw things that may be placed soon if(mode == placing && block != null){ for(int i = 0; i < lineRequests.size; i++){ - BuildRequest req = lineRequests.get(i); + BuildPlan req = lineRequests.get(i); if(i == lineRequests.size - 1 && req.block.rotate){ drawArrow(block, req.x, req.y, req.rotation); } @@ -425,7 +425,7 @@ public class DesktopInput extends InputHandler{ } if(Core.input.keyTap(Binding.select) && !Core.scene.hasMouse()){ - BuildRequest req = getRequest(cursorX, cursorY); + BuildPlan req = getRequest(cursorX, cursorY); if(Core.input.keyDown(Binding.break_block)){ mode = none; @@ -444,7 +444,7 @@ public class DesktopInput extends InputHandler{ deleting = true; }else if(selected != null){ //only begin shooting if there's no cursor event - if(!tileTapped(selected.entity) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().requests().size == 0 || !player.builder().isBuilding()) && !droppingItem && + if(!tileTapped(selected.entity) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().plans().size == 0 || !player.builder().isBuilding()) && !droppingItem && !tryBeginMine(selected) && player.miner().mineTile() == null && !Core.scene.hasKeyboard()){ isShooting = shouldShoot; } @@ -466,9 +466,9 @@ public class DesktopInput extends InputHandler{ } if(Core.input.keyDown(Binding.select) && mode == none && !isPlacing() && deleting){ - BuildRequest req = getRequest(cursorX, cursorY); + BuildPlan req = getRequest(cursorX, cursorY); if(req != null && req.breaking){ - player.builder().requests().remove(req); + player.builder().plans().remove(req); } }else{ deleting = false; @@ -497,7 +497,7 @@ public class DesktopInput extends InputHandler{ if(sreq != null){ if(getRequest(sreq.x, sreq.y, sreq.block.size, sreq) != null){ - player.builder().requests().remove(sreq, true); + player.builder().plans().remove(sreq, true); } sreq = null; } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 9445eb0465..fc42071ca1 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -64,10 +64,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ protected @Nullable Schematic lastSchematic; protected GestureDetector detector; protected PlaceLine line = new PlaceLine(); - protected BuildRequest resultreq; - protected BuildRequest brequest = new BuildRequest(); - protected Seq lineRequests = new Seq<>(); - protected Seq selectRequests = new Seq<>(); + protected BuildPlan resultreq; + protected BuildPlan brequest = new BuildPlan(); + protected Seq lineRequests = new Seq<>(); + protected Seq selectRequests = new Seq<>(); //methods to override @@ -232,11 +232,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } - public Eachable allRequests(){ + public Eachable allRequests(){ return cons -> { - for(BuildRequest request : player.builder().requests()) cons.get(request); - for(BuildRequest request : selectRequests) cons.get(request); - for(BuildRequest request : lineRequests) cons.get(request); + for(BuildPlan request : player.builder().plans()) cons.get(request); + for(BuildPlan request : selectRequests) cons.get(request); + for(BuildPlan request : lineRequests) cons.get(request); }; } @@ -317,7 +317,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ Drawf.selected(x, y, block, color); } - public void drawBreaking(BuildRequest request){ + public void drawBreaking(BuildPlan request){ if(request.breaking){ drawBreaking(request.x, request.y); }else{ @@ -325,7 +325,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } } - public boolean requestMatches(BuildRequest request){ + public boolean requestMatches(BuildPlan request){ Tile tile = world.tile(request.x, request.y); return tile != null && tile.block() instanceof BuildBlock && tile.ent().cblock == request.block; } @@ -362,7 +362,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ }); } - public void rotateRequests(Seq requests, int direction){ + public void rotateRequests(Seq requests, int direction){ int ox = schemOriginX(), oy = schemOriginY(); requests.each(req -> { @@ -396,7 +396,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ }); } - public void flipRequests(Seq requests, boolean x){ + public void flipRequests(Seq requests, boolean x){ int origin = (x ? schemOriginX() : schemOriginY()) * tilesize; requests.each(req -> { @@ -436,18 +436,18 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } /** Returns the selection request that overlaps this position, or null. */ - protected BuildRequest getRequest(int x, int y){ + protected BuildPlan getRequest(int x, int y){ return getRequest(x, y, 1, null); } /** Returns the selection request that overlaps this position, or null. */ - protected BuildRequest getRequest(int x, int y, int size, BuildRequest skip){ + protected BuildPlan getRequest(int x, int y, int size, BuildPlan skip){ float offset = ((size + 1) % 2) * tilesize / 2f; r2.setSize(tilesize * size); r2.setCenter(x * tilesize + offset, y * tilesize + offset); resultreq = null; - Boolf test = req -> { + Boolf test = req -> { if(req == skip) return false; Tile other = req.tile(); @@ -464,11 +464,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ return r2.overlaps(r1); }; - for(BuildRequest req : player.builder().requests()){ + for(BuildPlan req : player.builder().plans()){ if(test.get(req)) return req; } - for(BuildRequest req : selectRequests){ + for(BuildPlan req : selectRequests){ if(test.get(req)) return req; } @@ -493,14 +493,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ Draw.color(Pal.remove); Lines.stroke(1f); - for(BuildRequest req : player.builder().requests()){ + for(BuildPlan req : player.builder().plans()){ if(req.breaking) continue; if(req.bounds(Tmp.r2).overlaps(Tmp.r1)){ drawBreaking(req); } } - for(BuildRequest req : selectRequests){ + for(BuildPlan req : selectRequests){ if(req.breaking) continue; if(req.bounds(Tmp.r2).overlaps(Tmp.r1)){ drawBreaking(req); @@ -533,10 +533,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ Lines.rect(result.x, result.y, result.x2 - result.x, result.y2 - result.y); } - protected void flushSelectRequests(Seq requests){ - for(BuildRequest req : requests){ + protected void flushSelectRequests(Seq requests){ + for(BuildPlan req : requests){ if(req.block != null && validPlace(req.x, req.y, req.block, req.rotation)){ - BuildRequest other = getRequest(req.x, req.y, req.block.size, null); + BuildPlan other = getRequest(req.x, req.y, req.block.size, null); if(other == null){ selectRequests.add(req.copy()); }else if(!other.breaking && other.x == req.x && other.y == req.y && other.block.size == req.block.size){ @@ -547,16 +547,16 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } } - protected void flushRequests(Seq requests){ - for(BuildRequest req : requests){ + protected void flushRequests(Seq requests){ + for(BuildPlan req : requests){ if(req.block != null && validPlace(req.x, req.y, req.block, req.rotation)){ - BuildRequest copy = req.copy(); + BuildPlan copy = req.copy(); player.builder().addBuild(copy); } } } - protected void drawOverRequest(BuildRequest request){ + protected void drawOverRequest(BuildPlan request){ boolean valid = validPlace(request.x, request.y, request.block, request.rotation); Draw.reset(); @@ -566,7 +566,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ Draw.reset(); } - protected void drawRequest(BuildRequest request){ + protected void drawRequest(BuildPlan request){ request.block.drawRequest(request, allRequests(), validPlace(request.x, request.y, request.block, request.rotation)); if(request.block.saveConfig && request.block.lastConfig != null && !request.hasConfig){ @@ -604,7 +604,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(!flush){ tryBreakBlock(wx, wy); }else if(validBreak(tile.x, tile.y) && !selectRequests.contains(r -> r.tile() != null && r.tile() == tile)){ - selectRequests.add(new BuildRequest(tile.x, tile.y)); + selectRequests.add(new BuildPlan(tile.x, tile.y)); } } } @@ -612,9 +612,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ //remove build requests Tmp.r1.set(result.x * tilesize, result.y * tilesize, (result.x2 - result.x) * tilesize, (result.y2 - result.y) * tilesize); - Iterator it = player.builder().requests().iterator(); + Iterator it = player.builder().plans().iterator(); while(it.hasNext()){ - BuildRequest req = it.next(); + BuildPlan req = it.next(); if(!req.breaking && req.bounds(Tmp.r2).overlaps(Tmp.r1)){ it.remove(); } @@ -622,7 +622,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ it = selectRequests.iterator(); while(it.hasNext()){ - BuildRequest req = it.next(); + BuildPlan req = it.next(); if(!req.breaking && req.bounds(Tmp.r2).overlaps(Tmp.r1)){ it.remove(); } @@ -643,7 +643,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ lineRequests.clear(); iterateLine(x1, y1, x2, y2, l -> { rotation = l.rotation; - BuildRequest req = new BuildRequest(l.x, l.y, l.rotation, block); + BuildPlan req = new BuildPlan(l.x, l.y, l.rotation, block); req.animScale = 1f; lineRequests.add(req); }); @@ -898,8 +898,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ return validPlace(x, y, type, rotation, null); } - public boolean validPlace(int x, int y, Block type, int rotation, BuildRequest ignore){ - for(BuildRequest req : player.builder().requests()){ + public boolean validPlace(int x, int y, Block type, int rotation, BuildPlan ignore){ + for(BuildPlan req : player.builder().plans()){ if(req != ignore && !req.breaking && req.block.bounds(req.x, req.y, Tmp.r1).overlaps(type.bounds(x, y, Tmp.r2)) @@ -915,18 +915,18 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } public void placeBlock(int x, int y, Block block, int rotation){ - BuildRequest req = getRequest(x, y); + BuildPlan req = getRequest(x, y); if(req != null){ - player.builder().requests().remove(req); + player.builder().plans().remove(req); } - player.builder().addBuild(new BuildRequest(x, y, rotation, block)); + player.builder().addBuild(new BuildPlan(x, y, rotation, block)); } public void breakBlock(int x, int y){ Tile tile = world.tile(x, y); //TODO hacky if(tile != null && tile.entity != null) tile = tile.entity.tile(); - player.builder().addBuild(new BuildRequest(tile.x, tile.y)); + player.builder().addBuild(new BuildPlan(tile.x, tile.y)); } public void drawArrow(Block block, int x, int y, int rotation){ diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 57d4946ef9..8320bb47d1 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -48,7 +48,7 @@ public class MobileInput extends InputHandler implements GestureListener{ private float shiftDeltaX, shiftDeltaY; /** Place requests to be removed. */ - private Seq removals = new Seq<>(); + private Seq removals = new Seq<>(); /** Whether or not the player is currently shifting all placed tiles. */ private boolean selecting; /** Whether the player is currently in line-place mode. */ @@ -58,7 +58,7 @@ public class MobileInput extends InputHandler implements GestureListener{ /** Whether no recipe was available when switching to break mode. */ private Block lastBlock; /** Last placed request. Used for drawing block overlay. */ - private BuildRequest lastPlaced; + private BuildPlan lastPlaced; /** Down tracking for panning.*/ private boolean down = false; @@ -97,7 +97,7 @@ public class MobileInput extends InputHandler implements GestureListener{ r2.setSize(block.size * tilesize); r2.setCenter(x * tilesize + block.offset(), y * tilesize + block.offset()); - for(BuildRequest req : selectRequests){ + for(BuildPlan req : selectRequests){ Tile other = req.tile(); if(other == null || req.breaking) continue; @@ -110,7 +110,7 @@ public class MobileInput extends InputHandler implements GestureListener{ } } - for(BuildRequest req : player.builder().requests()){ + for(BuildPlan req : player.builder().plans()){ Tile other = world.tile(req.x, req.y); if(other == null || req.breaking) continue; @@ -126,11 +126,11 @@ public class MobileInput extends InputHandler implements GestureListener{ } /** Returns the selection request that overlaps this tile, or null. */ - BuildRequest getRequest(Tile tile){ + BuildPlan getRequest(Tile tile){ r2.setSize(tilesize); r2.setCenter(tile.worldx(), tile.worldy()); - for(BuildRequest req : selectRequests){ + for(BuildPlan req : selectRequests){ Tile other = req.tile(); if(other == null) continue; @@ -149,7 +149,7 @@ public class MobileInput extends InputHandler implements GestureListener{ return null; } - void removeRequest(BuildRequest request){ + void removeRequest(BuildPlan request){ selectRequests.remove(request, true); if(!request.breaking){ removals.add(request); @@ -204,20 +204,20 @@ public class MobileInput extends InputHandler implements GestureListener{ //confirm button table.button(Icon.ok, Styles.clearPartiali, () -> { - for(BuildRequest request : selectRequests){ + for(BuildPlan request : selectRequests){ Tile tile = request.tile(); //actually place/break all selected blocks if(tile != null){ if(!request.breaking){ if(validPlace(request.x, request.y, request.block, request.rotation)){ - BuildRequest other = getRequest(request.x, request.y, request.block.size, null); - BuildRequest copy = request.copy(); + BuildPlan other = getRequest(request.x, request.y, request.block.size, null); + BuildPlan copy = request.copy(); if(other == null){ player.builder().addBuild(copy); }else if(!other.breaking && other.x == request.x && other.y == request.y && other.block.size == request.block.size){ - player.builder().requests().remove(other); + player.builder().plans().remove(other); player.builder().addBuild(copy); } } @@ -278,7 +278,7 @@ public class MobileInput extends InputHandler implements GestureListener{ Lines.stroke(1f); //draw removals - for(BuildRequest request : removals){ + for(BuildPlan request : removals){ Tile tile = request.tile(); if(tile == null) continue; @@ -293,7 +293,7 @@ public class MobileInput extends InputHandler implements GestureListener{ } //draw list of requests - for(BuildRequest request : selectRequests){ + for(BuildPlan request : selectRequests){ Tile tile = request.tile(); if(tile == null) continue; @@ -333,7 +333,7 @@ public class MobileInput extends InputHandler implements GestureListener{ if(mode == placing && block != null){ //draw placing for(int i = 0; i < lineRequests.size; i++){ - BuildRequest request = lineRequests.get(i); + BuildPlan request = lineRequests.get(i); if(i == lineRequests.size - 1 && request.block.rotate){ drawArrow(block, request.x, request.y, request.rotation); } @@ -376,7 +376,7 @@ public class MobileInput extends InputHandler implements GestureListener{ } @Override - protected void drawRequest(BuildRequest request){ + protected void drawRequest(BuildPlan request){ if(request.tile() == null) return; brequest.animScale = request.animScale = Mathf.lerpDelta(request.animScale, 1f, 0.1f); @@ -551,10 +551,10 @@ public class MobileInput extends InputHandler implements GestureListener{ removeRequest(getRequest(cursor)); }else if(mode == placing && isPlacing() && validPlace(cursor.x, cursor.y, block, rotation) && !checkOverlapPlacement(cursor.x, cursor.y, block)){ //add to selection queue if it's a valid place position - selectRequests.add(lastPlaced = new BuildRequest(cursor.x, cursor.y, rotation, block)); + selectRequests.add(lastPlaced = new BuildPlan(cursor.x, cursor.y, rotation, block)); }else if(mode == breaking && validBreak(linked.x,linked.y) && !hasRequest(linked)){ //add to selection queue if it's a valid BREAK position - selectRequests.add(new BuildRequest(linked.x, linked.y)); + selectRequests.add(new BuildPlan(linked.x, linked.y)); }else if(!canTapPlayer(worldx, worldy) && !tileTapped(linked.entity)){ tryBeginMine(cursor); } @@ -659,7 +659,7 @@ public class MobileInput extends InputHandler implements GestureListener{ //remove place requests that have disappeared for(int i = removals.size - 1; i >= 0; i--){ - BuildRequest request = removals.get(i); + BuildPlan request = removals.get(i); if(request.animScale <= 0.0001f){ removals.remove(i); @@ -720,7 +720,7 @@ public class MobileInput extends InputHandler implements GestureListener{ int shiftedY = (int)(shiftDeltaY / tilesize); if(Math.abs(shiftedX) > 0 || Math.abs(shiftedY) > 0){ - for(BuildRequest req : selectRequests){ + for(BuildPlan req : selectRequests){ if(req.breaking) continue; //don't shift removal requests req.x += shiftedX; req.y += shiftedY; diff --git a/core/src/mindustry/io/TypeIO.java b/core/src/mindustry/io/TypeIO.java index bc5b4b877f..42f9d3a2b6 100644 --- a/core/src/mindustry/io/TypeIO.java +++ b/core/src/mindustry/io/TypeIO.java @@ -154,7 +154,7 @@ public class TypeIO{ return content.block(read.s()); } - public static void writeRequest(Writes write, BuildRequest request){ + public static void writeRequest(Writes write, BuildPlan request){ write.b(request.breaking ? (byte)1 : 0); write.i(Point2.pack(request.x, request.y)); if(!request.breaking){ @@ -165,8 +165,8 @@ public class TypeIO{ } } - public static BuildRequest readRequest(Reads read){ - BuildRequest currentRequest; + public static BuildPlan readRequest(Reads read){ + BuildPlan currentRequest; byte type = read.b(); int position = read.i(); @@ -176,13 +176,13 @@ public class TypeIO{ } if(type == 1){ //remove - currentRequest = new BuildRequest(Point2.x(position), Point2.y(position)); + currentRequest = new BuildPlan(Point2.x(position), Point2.y(position)); }else{ //place short block = read.s(); byte rotation = read.b(); boolean hasConfig = read.b() == 1; Object config = readObject(read); - currentRequest = new BuildRequest(Point2.x(position), Point2.y(position), rotation, content.block(block)); + currentRequest = new BuildPlan(Point2.x(position), Point2.y(position), rotation, content.block(block)); if(hasConfig){ currentRequest.configure(config); } @@ -191,26 +191,26 @@ public class TypeIO{ return currentRequest; } - public static void writeRequests(Writes write, BuildRequest[] requests){ + public static void writeRequests(Writes write, BuildPlan[] requests){ if(requests == null){ write.s(-1); return; } write.s((short)requests.length); - for(BuildRequest request : requests){ + for(BuildPlan request : requests){ writeRequest(write, request); } } - public static BuildRequest[] readRequests(Reads read){ + public static BuildPlan[] readRequests(Reads read){ short reqamount = read.s(); if(reqamount == -1){ return null; } - BuildRequest[] reqs = new BuildRequest[reqamount]; + BuildPlan[] reqs = new BuildPlan[reqamount]; for(int i = 0; i < reqamount; i++){ - BuildRequest request = readRequest(read); + BuildPlan request = readRequest(read); if(request != null){ reqs[i] = request; } diff --git a/core/src/mindustry/net/NetConnection.java b/core/src/mindustry/net/NetConnection.java index d4ff73a7f0..3fbc5ada21 100644 --- a/core/src/mindustry/net/NetConnection.java +++ b/core/src/mindustry/net/NetConnection.java @@ -27,7 +27,7 @@ public abstract class NetConnection{ /** Timestamp of last recieved snapshot. */ public long lastRecievedClientTime; /** Build requests that have been recently rejected. This is cleared every snapshot. */ - public Seq rejectedRequests = new Seq<>(); + public Seq rejectedRequests = new Seq<>(); public boolean hasConnected, hasBegunConnecting, hasDisconnected; public float viewWidth, viewHeight, viewX, viewY; diff --git a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java index 2a40472260..7f522aa189 100644 --- a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java @@ -161,7 +161,6 @@ public class CustomRulesDialog extends BaseDialog{ title("$rules.title.enemy"); check("$rules.attack", b -> rules.attackMode = b, () -> rules.attackMode); - check("$rules.enemyCheat", b -> rules.enemyCheat = b, () -> rules.enemyCheat); number("$rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200)); title("$rules.title.environment"); diff --git a/core/src/mindustry/ui/dialogs/SchematicsDialog.java b/core/src/mindustry/ui/dialogs/SchematicsDialog.java index bfe16a064c..345609653a 100644 --- a/core/src/mindustry/ui/dialogs/SchematicsDialog.java +++ b/core/src/mindustry/ui/dialogs/SchematicsDialog.java @@ -338,7 +338,7 @@ public class SchematicsDialog extends BaseDialog{ for(ItemStack s : arr){ r.image(s.item.icon(Cicon.small)).left(); r.label(() -> { - Tilec core = player.closestCore(); + Tilec core = player.core(); if(core == null || state.rules.infiniteResources || core.items().has(s.item, s.amount)) return "[lightgray]" + s.amount + ""; return (core.items().has(s.item, s.amount) ? "[lightgray]" : "[scarlet]") + Math.min(core.items().get(s.item), s.amount) + "[lightgray]/" + s.amount; }).padLeft(2).left().padRight(4); diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index c4c0c4d09c..7b057a6167 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -94,7 +94,7 @@ public class PlacementFragment extends Fragment{ Block tryRecipe = tile == null ? null : tile.block(); Object tryConfig = tile == null ? null : tile.config(); - for(BuildRequest req : player.builder().requests()){ + for(BuildPlan req : player.builder().plans()){ if(!req.breaking && req.block.bounds(req.x, req.y, Tmp.r1).contains(Core.input.mouseWorld())){ tryRecipe = req.block; tryConfig = req.config; @@ -222,7 +222,7 @@ public class PlacementFragment extends Fragment{ button.resizeImage(Cicon.medium.size); button.update(() -> { //color unplacable things gray - Tilec core = player.closestCore(); + Tilec core = player.core(); Color color = (state.rules.infiniteResources || (core != null && (core.items().has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources))) && player.isBuilder() ? Color.white : Color.gray; button.forEach(elem -> elem.setColor(color)); button.setChecked(control.input.block == block); @@ -310,7 +310,7 @@ public class PlacementFragment extends Fragment{ line.image(stack.item.icon(Cicon.small)).size(8 * 2); line.add(stack.item.localizedName).maxWidth(140f).fillX().color(Color.lightGray).padLeft(2).left().get().setEllipsis(true); line.labelWrap(() -> { - Tilec core = player.closestCore(); + Tilec core = player.core(); if(core == null || state.rules.infiniteResources) return "*/*"; int amount = core.items().get(stack.item); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 0d27db2582..498340c03d 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -342,11 +342,11 @@ public class Block extends UnlockableContent{ } /** @return a possible replacement for this block when placed in a line by the player. */ - public Block getReplacement(BuildRequest req, Seq requests){ + public Block getReplacement(BuildPlan req, Seq requests){ return this; } - public void drawRequest(BuildRequest req, Eachable list, boolean valid){ + public void drawRequest(BuildPlan req, Eachable list, boolean valid){ Draw.reset(); Draw.mixcol(!valid ? Pal.breakInvalid : Color.white, (!valid ? 0.4f : 0.24f) + Mathf.absin(Time.globalTime(), 6f, 0.28f)); Draw.alpha(1f); @@ -357,7 +357,7 @@ public class Block extends UnlockableContent{ Draw.reset(); } - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ TextureRegion reg = getRequestRegion(req, list); Draw.rect(reg, req.drawx(), req.drawy(), !rotate ? 0 : req.rotation * 90); @@ -366,15 +366,15 @@ public class Block extends UnlockableContent{ } } - public TextureRegion getRequestRegion(BuildRequest req, Eachable list){ + public TextureRegion getRequestRegion(BuildPlan req, Eachable list){ return icon(Cicon.full); } - public void drawRequestConfig(BuildRequest req, Eachable list){ + public void drawRequestConfig(BuildPlan req, Eachable list){ } - public void drawRequestConfigCenter(BuildRequest req, Object content, String region){ + public void drawRequestConfigCenter(BuildPlan req, Object content, String region){ Color color = content instanceof Item ? ((Item)content).color : content instanceof Liquid ? ((Liquid)content).color : null; if(color == null) return; @@ -383,7 +383,7 @@ public class Block extends UnlockableContent{ Draw.color(); } - public void drawRequestConfigTop(BuildRequest req, Eachable list){ + public void drawRequestConfigTop(BuildPlan req, Eachable list){ } diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 726ced1015..1078057ea7 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -346,10 +346,6 @@ public class Tile implements Position, QuadTreeObject{ return block.destructible || block.breakable || block.update; } - public boolean isEnemyCheat(){ - return team() == state.rules.waveTeam && state.rules.enemyCheat; - } - /** * Returns the list of all tiles linked to this multiblock, or just itself if it's not a multiblock. * This array contains all linked tiles, including this tile itself. diff --git a/core/src/mindustry/world/blocks/Autotiler.java b/core/src/mindustry/world/blocks/Autotiler.java index bfa4c309e0..375f2d318c 100644 --- a/core/src/mindustry/world/blocks/Autotiler.java +++ b/core/src/mindustry/world/blocks/Autotiler.java @@ -17,7 +17,7 @@ public interface Autotiler{ //holds some static temporary variables, required due to some RoboVM bugs class AutotilerHolder{ static final int[] blendresult = new int[5]; - static final BuildRequest[] directionals = new BuildRequest[4]; + static final BuildPlan[] directionals = new BuildPlan[4]; } /** slices a texture region: @@ -44,9 +44,9 @@ public interface Autotiler{ return region; } - default @Nullable int[] getTiling(BuildRequest req, Eachable list){ + default @Nullable int[] getTiling(BuildPlan req, Eachable list){ if(req.tile() == null) return null; - BuildRequest[] directionals = AutotilerHolder.directionals; + BuildPlan[] directionals = AutotilerHolder.directionals; Arrays.fill(directionals, null); list.each(other -> { @@ -78,7 +78,7 @@ public interface Autotiler{ * [3]: a 4-bit mask with bits 0-3 indicating blend state in that direction (0 being 0 degrees, 1 being 90, etc) * [4]: same as [3] but only blends with non-square sprites * */ - default int[] buildBlending(Tile tile, int rotation, BuildRequest[] directional, boolean world){ + default int[] buildBlending(Tile tile, int rotation, BuildPlan[] directional, boolean world){ int[] blendresult = AutotilerHolder.blendresult; blendresult[0] = 0; blendresult[1] = blendresult[2] = 1; @@ -134,10 +134,10 @@ public interface Autotiler{ return Point2.equals(x + Geometry.d4(rotation).x,y + Geometry.d4(rotation).y, x2, y2); } - default boolean blends(Tile tile, int rotation, @Nullable BuildRequest[] directional, int direction, boolean checkWorld){ + default boolean blends(Tile tile, int rotation, @Nullable BuildPlan[] directional, int direction, boolean checkWorld){ int realDir = Mathf.mod(rotation - direction, 4); if(directional != null && directional[realDir] != null){ - BuildRequest req = directional[realDir]; + BuildPlan req = directional[realDir]; if(blends(tile, rotation, req.x, req.y, req.rotation, req.block)){ return true; } diff --git a/core/src/mindustry/world/blocks/BuildBlock.java b/core/src/mindustry/world/blocks/BuildBlock.java index eb9e8fafd1..7cf9dd889f 100644 --- a/core/src/mindustry/world/blocks/BuildBlock.java +++ b/core/src/mindustry/world/blocks/BuildBlock.java @@ -154,7 +154,7 @@ public class BuildBlock extends Block{ if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){ control.input.isBuilding = true; } - player.builder().addBuild(new BuildRequest(tile.x, tile.y, tile.rotation(), cblock), false); + player.builder().addBuild(new BuildPlan(tile.x, tile.y, tile.rotation(), cblock), false); } } diff --git a/core/src/mindustry/world/blocks/defense/Door.java b/core/src/mindustry/world/blocks/defense/Door.java index 54e6aed17c..24cadf20cc 100644 --- a/core/src/mindustry/world/blocks/defense/Door.java +++ b/core/src/mindustry/world/blocks/defense/Door.java @@ -38,7 +38,7 @@ public class Door extends Wall{ } @Override - public TextureRegion getRequestRegion(BuildRequest req, Eachable list){ + public TextureRegion getRequestRegion(BuildPlan req, Eachable list){ return req.config == Boolean.TRUE ? openRegion : region; } diff --git a/core/src/mindustry/world/blocks/defense/MendProjector.java b/core/src/mindustry/world/blocks/defense/MendProjector.java index d9c25dc27b..dbaad0d859 100644 --- a/core/src/mindustry/world/blocks/defense/MendProjector.java +++ b/core/src/mindustry/world/blocks/defense/MendProjector.java @@ -62,7 +62,7 @@ public class MendProjector extends Block{ @Override public void updateTile(){ - heat = Mathf.lerpDelta(heat, consValid() || tile.isEnemyCheat() ? 1f : 0f, 0.08f); + heat = Mathf.lerpDelta(heat, consValid() || cheating() ? 1f : 0f, 0.08f); charge += heat * delta(); phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons().optionalValid()), 0.1f); diff --git a/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java b/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java index 4cb155fc99..5a06857771 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/ItemTurret.java @@ -67,7 +67,7 @@ public class ItemTurret extends Turret{ super.onProximityAdded(); //add first ammo item to cheaty blocks so they can shoot properly - if(tile.isEnemyCheat() && ammo.size > 0){ + if(cheating() && ammo.size > 0){ handleItem(this, ammoTypes.entries().next().key); } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java index 9cb5992bdb..54278241a0 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -68,7 +68,7 @@ public class LaserTurret extends PowerTurret{ Liquid liquid = liquids().current(); float maxUsed = consumes.get(ConsumeType.liquid).amount; - float used = (tile.isEnemyCheat() ? maxUsed * Time.delta() : Math.min(liquids.get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier; + float used = (cheating() ? maxUsed * Time.delta() : Math.min(liquids.get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier; reload -= used; liquids.remove(liquid, used); @@ -85,7 +85,7 @@ public class LaserTurret extends PowerTurret{ return; } - if(reload <= 0 && (consValid() || tile.isEnemyCheat())){ + if(reload <= 0 && (consValid() || cheating())){ BulletType type = peekAmmo(); shoot(type); diff --git a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java index 12b7b08139..b65325ec65 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java @@ -101,7 +101,7 @@ public class LiquidTurret extends Turret{ @Override public BulletType useAmmo(){ - if(tile.isEnemyCheat()) return ammoTypes.get(liquids.current()); + if(cheating()) return ammoTypes.get(liquids.current()); BulletType type = ammoTypes.get(liquids.current()); liquids.remove(liquids.current(), type.ammoMultiplier); return type; diff --git a/core/src/mindustry/world/blocks/defense/turrets/PowerTurret.java b/core/src/mindustry/world/blocks/defense/turrets/PowerTurret.java index 7abbfe9924..fd62367feb 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/PowerTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/PowerTurret.java @@ -47,7 +47,7 @@ public class PowerTurret extends Turret{ @Override protected float baseReloadSpeed(){ - return tile.isEnemyCheat() ? 1f : power.status; + return cheating() ? 1f : power.status; } } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index cd6b0421c0..1376ea9f5a 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -281,7 +281,7 @@ public abstract class Turret extends Block{ /** Consume ammo and return a type. */ public BulletType useAmmo(){ - if(tile.isEnemyCheat()) return peekAmmo(); + if(cheating()) return peekAmmo(); AmmoEntry entry = ammo.peek(); entry.amount -= ammoPerShot; diff --git a/core/src/mindustry/world/blocks/distribution/Conveyor.java b/core/src/mindustry/world/blocks/distribution/Conveyor.java index 25fbc92381..194877294b 100644 --- a/core/src/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/mindustry/world/blocks/distribution/Conveyor.java @@ -56,7 +56,7 @@ public class Conveyor extends Block implements Autotiler{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ int[] bits = getTiling(req, list); if(bits == null) return; @@ -81,7 +81,7 @@ public class Conveyor extends Block implements Autotiler{ } @Override - public Block getReplacement(BuildRequest req, Seq requests){ + public Block getReplacement(BuildPlan req, Seq requests){ Boolf cont = p -> requests.contains(o -> o.x == req.x + p.x && o.y == req.y + p.y && o.rotation == req.rotation && (req.block instanceof Conveyor || req.block instanceof Junction)); return cont.get(Geometry.d4(req.rotation)) && cont.get(Geometry.d4(req.rotation - 2)) && diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index eab96ee848..2ff00e47b2 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -20,7 +20,7 @@ import mindustry.world.meta.*; import static mindustry.Vars.*; public class ItemBridge extends Block{ - private static BuildRequest otherReq; + private static BuildPlan otherReq; public final int timerTransport = timers++; public int range; @@ -50,7 +50,7 @@ public class ItemBridge extends Block{ } @Override - public void drawRequestConfigTop(BuildRequest req, Eachable list){ + public void drawRequestConfigTop(BuildPlan req, Eachable list){ otherReq = null; list.each(other -> { if(other.block == this && req != other && req.config instanceof Point2 && ((Point2)req.config).equals(other.x - req.x, other.y - req.y)){ diff --git a/core/src/mindustry/world/blocks/distribution/PayloadRouter.java b/core/src/mindustry/world/blocks/distribution/PayloadRouter.java index e0a721024e..2fea02a283 100644 --- a/core/src/mindustry/world/blocks/distribution/PayloadRouter.java +++ b/core/src/mindustry/world/blocks/distribution/PayloadRouter.java @@ -18,7 +18,7 @@ public class PayloadRouter extends PayloadConveyor{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ super.drawRequestRegion(req, list); Draw.rect(overRegion, req.drawx(), req.drawy()); diff --git a/core/src/mindustry/world/blocks/distribution/Sorter.java b/core/src/mindustry/world/blocks/distribution/Sorter.java index fba4125554..ca8c0502b2 100644 --- a/core/src/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/mindustry/world/blocks/distribution/Sorter.java @@ -33,7 +33,7 @@ public class Sorter extends Block{ } @Override - public void drawRequestConfig(BuildRequest req, Eachable list){ + public void drawRequestConfig(BuildPlan req, Eachable list){ drawRequestConfigCenter(req, req.config, "center"); } diff --git a/core/src/mindustry/world/blocks/distribution/StackConveyor.java b/core/src/mindustry/world/blocks/distribution/StackConveyor.java index b81b5b2248..d219391b49 100644 --- a/core/src/mindustry/world/blocks/distribution/StackConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/StackConveyor.java @@ -67,7 +67,7 @@ public class StackConveyor extends Block implements Autotiler{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ int[] bits = getTiling(req, list); if(bits == null) return; diff --git a/core/src/mindustry/world/blocks/experimental/BlockForge.java b/core/src/mindustry/world/blocks/experimental/BlockForge.java index 78716f2b69..47b86e048f 100644 --- a/core/src/mindustry/world/blocks/experimental/BlockForge.java +++ b/core/src/mindustry/world/blocks/experimental/BlockForge.java @@ -54,7 +54,7 @@ public class BlockForge extends PayloadAcceptor{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ Draw.rect(region, req.drawx(), req.drawy()); Draw.rect(outRegion, req.drawx(), req.drawy(), req.rotation * 90); } diff --git a/core/src/mindustry/world/blocks/experimental/BlockLoader.java b/core/src/mindustry/world/blocks/experimental/BlockLoader.java index f687dad8da..ee152813b9 100644 --- a/core/src/mindustry/world/blocks/experimental/BlockLoader.java +++ b/core/src/mindustry/world/blocks/experimental/BlockLoader.java @@ -44,7 +44,7 @@ public class BlockLoader extends PayloadAcceptor{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ Draw.rect(region, req.drawx(), req.drawy()); Draw.rect(outRegion, req.drawx(), req.drawy(), req.rotation * 90); Draw.rect(topRegion, req.drawx(), req.drawy()); diff --git a/core/src/mindustry/world/blocks/liquid/Conduit.java b/core/src/mindustry/world/blocks/liquid/Conduit.java index fb4f6123e4..292c22d7be 100644 --- a/core/src/mindustry/world/blocks/liquid/Conduit.java +++ b/core/src/mindustry/world/blocks/liquid/Conduit.java @@ -38,7 +38,7 @@ public class Conduit extends LiquidBlock implements Autotiler{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ int[] bits = getTiling(req, list); if(bits == null) return; @@ -53,7 +53,7 @@ public class Conduit extends LiquidBlock implements Autotiler{ } @Override - public Block getReplacement(BuildRequest req, Seq requests){ + public Block getReplacement(BuildPlan req, Seq requests){ Boolf cont = p -> requests.contains(o -> o.x == req.x + p.x && o.y == req.y + p.y && o.rotation == req.rotation && (req.block instanceof Conduit || req.block instanceof LiquidJunction)); return cont.get(Geometry.d4(req.rotation)) && cont.get(Geometry.d4(req.rotation - 2)) && diff --git a/core/src/mindustry/world/blocks/power/PowerDiode.java b/core/src/mindustry/world/blocks/power/PowerDiode.java index 53bed896ee..75f74814b8 100644 --- a/core/src/mindustry/world/blocks/power/PowerDiode.java +++ b/core/src/mindustry/world/blocks/power/PowerDiode.java @@ -32,7 +32,7 @@ public class PowerDiode extends Block{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ Draw.rect(icon(Cicon.full), req.drawx(), req.drawy()); Draw.rect(arrow, req.drawx(), req.drawy(), !rotate ? 0 : req.rotation * 90); } diff --git a/core/src/mindustry/world/blocks/power/PowerGraph.java b/core/src/mindustry/world/blocks/power/PowerGraph.java index bc0b9e117f..9078e56685 100644 --- a/core/src/mindustry/world/blocks/power/PowerGraph.java +++ b/core/src/mindustry/world/blocks/power/PowerGraph.java @@ -178,7 +178,7 @@ public class PowerGraph{ public void update(){ if(Core.graphics.getFrameId() == lastFrameUpdated){ return; - }else if(!consumers.isEmpty() && consumers.first().tile().isEnemyCheat()){ + }else if(!consumers.isEmpty() && consumers.first().cheating()){ //when cheating, just set status to 1 for(Tilec tile : consumers){ tile.power().status = 1f; diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 88b670fdb5..e282f27db2 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -22,7 +22,7 @@ import static mindustry.Vars.*; public class PowerNode extends PowerBlock{ protected static boolean returnValue = false; - protected static BuildRequest otherReq; + protected static BuildPlan otherReq; protected final ObjectSet graphs = new ObjectSet<>(); protected final Vec2 t1 = new Vec2(), t2 = new Vec2(); @@ -201,7 +201,7 @@ public class PowerNode extends PowerBlock{ } @Override - public void drawRequestConfigTop(BuildRequest req, Eachable list){ + public void drawRequestConfigTop(BuildPlan req, Eachable list){ if(req.config instanceof Point2[]){ for(Point2 point : (Point2[])req.config){ otherReq = null; diff --git a/core/src/mindustry/world/blocks/production/Drill.java b/core/src/mindustry/world/blocks/production/Drill.java index 192852dd65..11df0df2e4 100644 --- a/core/src/mindustry/world/blocks/production/Drill.java +++ b/core/src/mindustry/world/blocks/production/Drill.java @@ -68,7 +68,7 @@ public class Drill extends Block{ } @Override - public void drawRequestConfigTop(BuildRequest req, Eachable list){ + public void drawRequestConfigTop(BuildPlan req, Eachable list){ if(!req.worldContext) return; Tile tile = req.tile(); if(tile == null) return; diff --git a/core/src/mindustry/world/blocks/sandbox/ItemSource.java b/core/src/mindustry/world/blocks/sandbox/ItemSource.java index aab3e3979a..0e08160ef8 100644 --- a/core/src/mindustry/world/blocks/sandbox/ItemSource.java +++ b/core/src/mindustry/world/blocks/sandbox/ItemSource.java @@ -35,7 +35,7 @@ public class ItemSource extends Block{ } @Override - public void drawRequestConfig(BuildRequest req, Eachable list){ + public void drawRequestConfig(BuildPlan req, Eachable list){ drawRequestConfigCenter(req, req.config, "center"); } diff --git a/core/src/mindustry/world/blocks/sandbox/LiquidSource.java b/core/src/mindustry/world/blocks/sandbox/LiquidSource.java index 9ce4edc8e8..146283fe41 100644 --- a/core/src/mindustry/world/blocks/sandbox/LiquidSource.java +++ b/core/src/mindustry/world/blocks/sandbox/LiquidSource.java @@ -37,7 +37,7 @@ public class LiquidSource extends Block{ } @Override - public void drawRequestConfig(BuildRequest req, Eachable list){ + public void drawRequestConfig(BuildPlan req, Eachable list){ drawRequestConfigCenter(req, req.config, "center"); } diff --git a/core/src/mindustry/world/blocks/storage/Unloader.java b/core/src/mindustry/world/blocks/storage/Unloader.java index 4809b8f47c..560992c40c 100644 --- a/core/src/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/mindustry/world/blocks/storage/Unloader.java @@ -36,7 +36,7 @@ public class Unloader extends Block{ } @Override - public void drawRequestConfig(BuildRequest req, Eachable list){ + public void drawRequestConfig(BuildPlan req, Eachable list){ drawRequestConfigCenter(req, req.config, "unloader-center"); } diff --git a/core/src/mindustry/world/blocks/units/Reconstructor.java b/core/src/mindustry/world/blocks/units/Reconstructor.java index 43194b073a..7c102ffff9 100644 --- a/core/src/mindustry/world/blocks/units/Reconstructor.java +++ b/core/src/mindustry/world/blocks/units/Reconstructor.java @@ -27,7 +27,7 @@ public class Reconstructor extends UnitBlock{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ Draw.rect(region, req.drawx(), req.drawy()); Draw.rect(outRegion, req.drawx(), req.drawy(), req.rotation * 90); Draw.rect(topRegion, req.drawx(), req.drawy()); diff --git a/core/src/mindustry/world/blocks/units/UnitFactory.java b/core/src/mindustry/world/blocks/units/UnitFactory.java index 452eb6300b..4648916b1c 100644 --- a/core/src/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/mindustry/world/blocks/units/UnitFactory.java @@ -90,7 +90,7 @@ public class UnitFactory extends UnitBlock{ } @Override - public void drawRequestRegion(BuildRequest req, Eachable list){ + public void drawRequestRegion(BuildPlan req, Eachable list){ Draw.rect(region, req.drawx(), req.drawy()); Draw.rect(outRegion, req.drawx(), req.drawy(), req.rotation * 90); Draw.rect(topRegion, req.drawx(), req.drawy()); diff --git a/core/src/mindustry/world/modules/ConsumeModule.java b/core/src/mindustry/world/modules/ConsumeModule.java index 67fc49a881..fc1936be2a 100644 --- a/core/src/mindustry/world/modules/ConsumeModule.java +++ b/core/src/mindustry/world/modules/ConsumeModule.java @@ -26,8 +26,8 @@ public class ConsumeModule extends BlockModule{ } public void update(){ - //everything is valid here - if(entity.tile().isEnemyCheat()){ + //everything is valid when cheating + if(entity.cheating()){ valid = optionalValid = true; return; } diff --git a/desktop/src/mindustry/desktop/steam/SStats.java b/desktop/src/mindustry/desktop/steam/SStats.java index cc53717d10..4beb269bb5 100644 --- a/desktop/src/mindustry/desktop/steam/SStats.java +++ b/desktop/src/mindustry/desktop/steam/SStats.java @@ -93,7 +93,7 @@ public class SStats implements SteamUserStatsCallback{ }); Events.on(Trigger.newGame, () -> Core.app.post(() -> { - if(campaign() && player.closestCore() != null && player.closestCore().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 b8958e4529..6250d21a17 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=a074a6f49cf19f417b40fede82a429dab8c91cc0 +archash=5c3e9ec21d1b541f3b0e6ecde5f4d468b92efc25 diff --git a/tests/src/test/java/ApplicationTests.java b/tests/src/test/java/ApplicationTests.java index d36fbc6f0f..e075d527c8 100644 --- a/tests/src/test/java/ApplicationTests.java +++ b/tests/src/test/java/ApplicationTests.java @@ -492,8 +492,8 @@ public class ApplicationTests{ d1.set(0f, 0f); d2.set(20f, 20f); - d1.addBuild(new BuildRequest(0, 0, 0, Blocks.copperWallLarge)); - d2.addBuild(new BuildRequest(1, 1, 0, Blocks.copperWallLarge)); + d1.addBuild(new BuildPlan(0, 0, 0, Blocks.copperWallLarge)); + d2.addBuild(new BuildPlan(1, 1, 0, Blocks.copperWallLarge)); d1.update(); d2.update(); @@ -514,8 +514,8 @@ public class ApplicationTests{ d1.set(10f, 20f); d2.set(10f, 20f); - d1.addBuild(new BuildRequest(0, 0, 0, Blocks.copperWallLarge)); - d2.addBuild(new BuildRequest(1, 1)); + d1.addBuild(new BuildPlan(0, 0, 0, Blocks.copperWallLarge)); + d2.addBuild(new BuildPlan(1, 1)); Time.setDeltaProvider(() -> 3f); d1.update(); @@ -532,7 +532,7 @@ public class ApplicationTests{ assertEquals(Blocks.copperWallLarge, world.tile(1, 1).block()); d2.clearBuilding(); - d2.addBuild(new BuildRequest(1, 1)); + d2.addBuild(new BuildPlan(1, 1)); d2.update(); assertEquals(Blocks.air, world.tile(0, 0).block()); diff --git a/tests/src/test/java/IOTests.java b/tests/src/test/java/IOTests.java index 47b1e42e64..e44270e9c2 100644 --- a/tests/src/test/java/IOTests.java +++ b/tests/src/test/java/IOTests.java @@ -10,11 +10,6 @@ import static org.junit.jupiter.api.Assertions.*; public class IOTests{ - @Test - void writeEntities(){ - //TODO - } - @Test void writeEnglish(){ ByteBuffer buffer = ByteBuffer.allocate(500);