diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index e79077e3e9..36c0c64959 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -6,7 +6,6 @@ import arc.math.*; import arc.math.geom.*; import arc.struct.EnumSet; import arc.struct.*; -import arc.util.*; import mindustry.content.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -111,11 +110,10 @@ public class BlockIndexer{ } private GridBits structQuadrant(Team t){ - int id = Pack.u(t.id); - if(structQuadrants[id] == null){ - structQuadrants[id] = new GridBits(Mathf.ceil(world.width() / (float)quadrantSize), Mathf.ceil(world.height() / (float)quadrantSize)); + if(structQuadrants[t.id] == null){ + structQuadrants[t.id] = new GridBits(Mathf.ceil(world.width() / (float)quadrantSize), Mathf.ceil(world.height() / (float)quadrantSize)); } - return structQuadrants[id]; + return structQuadrants[t.id]; } /** Updates all the structure quadrants for a newly activated team. */ diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index c7c7ac00bf..00fc4567d3 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -68,7 +68,7 @@ public class Pathfinder implements Runnable{ /** Packs a tile into its internal representation. */ private int packTile(Tile tile){ - return PathTile.get(tile.cost, tile.getTeamID(), !tile.solid() && tile.floor().drownTime <= 0f, !tile.solid() && tile.floor().isLiquid); + return PathTile.get(tile.cost, (byte)tile.getTeamID(), !tile.solid() && tile.floor().drownTime <= 0f, !tile.solid() && tile.floor().isLiquid); } /** Starts or restarts the pathfinding thread. */ @@ -144,9 +144,9 @@ public class Pathfinder implements Runnable{ Core.app.post(() -> { //remove its used state - if(fieldMap[team.uid] != null){ - fieldMap[team.uid].remove(data.target); - fieldMapUsed[team.uid].remove(data.target); + if(fieldMap[team.id] != null){ + fieldMap[team.id].remove(data.target); + fieldMapUsed[team.id].remove(data.target); } //remove from main thread list mainList.remove(data); @@ -180,16 +180,16 @@ public class Pathfinder implements Runnable{ public Tile getTargetTile(Tile tile, Team team, PathTarget target){ if(tile == null) return null; - if(fieldMap[team.uid] == null){ - fieldMap[team.uid] = new ObjectMap<>(); - fieldMapUsed[team.uid] = new ObjectSet<>(); + if(fieldMap[team.id] == null){ + fieldMap[team.id] = new ObjectMap<>(); + fieldMapUsed[team.id] = new ObjectSet<>(); } - Flowfield data = fieldMap[team.uid].get(target); + Flowfield data = fieldMap[team.id].get(target); if(data == null){ //if this combination is not found, create it on request - if(fieldMapUsed[team.uid].add(target)){ + if(fieldMapUsed[team.id].add(target)){ //grab targets since this is run on main thread IntSeq targets = target.getPositions(team, new IntSeq()); queue.post(() -> createPath(team, target, targets)); @@ -311,8 +311,8 @@ public class Pathfinder implements Runnable{ //add to main thread's list of paths Core.app.post(() -> { mainList.add(path); - if(fieldMap[team.uid] != null){ - fieldMap[team.uid].put(target, path); + if(fieldMap[team.id] != null){ + fieldMap[team.id].put(target, path); } }); diff --git a/core/src/mindustry/async/TeamIndexProcess.java b/core/src/mindustry/async/TeamIndexProcess.java index b31ebcbe0b..f1d9a6324b 100644 --- a/core/src/mindustry/async/TeamIndexProcess.java +++ b/core/src/mindustry/async/TeamIndexProcess.java @@ -13,9 +13,9 @@ public class TeamIndexProcess implements AsyncProcess{ private int[] counts = new int[Team.all.length]; public QuadTree tree(Team team){ - if(trees[team.uid] == null) trees[team.uid] = new QuadTree<>(Vars.world.getQuadBounds(new Rect())); + if(trees[team.id] == null) trees[team.id] = new QuadTree<>(Vars.world.getQuadBounds(new Rect())); - return trees[team.uid]; + return trees[team.id]; } public int count(Team team){ @@ -36,8 +36,8 @@ public class TeamIndexProcess implements AsyncProcess{ public void begin(){ for(Team team : Team.all){ - if(trees[team.uid] != null){ - trees[team.uid].clear(); + if(trees[team.id] != null){ + trees[team.id].clear(); } } diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 6d4ffe8743..5be0e99890 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -1689,7 +1689,6 @@ public class Blocks implements ContentList{ plans = new UnitPlan[]{ new UnitPlan(UnitTypes.wraith, 200f, with(Items.silicon, 10)), new UnitPlan(UnitTypes.spirit, 200f, with(Items.silicon, 10)), - new UnitPlan(UnitTypes.draug, 200f, with(Items.silicon, 10)), new UnitPlan(UnitTypes.phantom, 200f, with(Items.silicon, 10)), }; size = 3; diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 079794ed06..34f664aecb 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -13,7 +13,7 @@ import mindustry.type.*; public class UnitTypes implements ContentList{ //ground - public static @EntityDef({Unitc.class, Mechc.class}) UnitType mace, dagger, crawler, fortress, chaosArray, eradicator; + public static @EntityDef({Unitc.class, Mechc.class}) UnitType mace, dagger, crawler, fortress, siegeArray, eradicator; //ground + builder public static @EntityDef({Unitc.class, Mechc.class, Builderc.class}) UnitType tau; @@ -24,14 +24,14 @@ public class UnitTypes implements ContentList{ //legs public static @EntityDef({Unitc.class, Legsc.class}) UnitType cix, eruptor; - //air + //air (no special traits) public static @EntityDef({Unitc.class}) UnitType wraith, reaper, ghoul, revenant, lich; - //air + mining - public static @EntityDef({Unitc.class, Minerc.class}) UnitType draug; - //air + building - public static @EntityDef({Unitc.class, Builderc.class}) UnitType phantom, spirit; + public static @EntityDef({Unitc.class, Builderc.class}) UnitType spirit; + + //air + mining + public static @EntityDef({Unitc.class, Minerc.class}) UnitType phantom; //air + building + mining //TODO implement other starter drones @@ -403,19 +403,6 @@ public class UnitTypes implements ContentList{ }}); }}; - draug = new UnitType("draug"){{ - flying = true; - drag = 0.05f; - speed = 2f; - range = 50f; - accel = 0.2f; - health = 80; - mineSpeed = 0.9f; - engineSize = 1.8f; - engineOffset = 5.7f; - mineTier = 1; - }}; - spirit = new UnitType("spirit"){{ flying = true; drag = 0.05f; diff --git a/core/src/mindustry/editor/DrawOperation.java b/core/src/mindustry/editor/DrawOperation.java index 0d6607e8ff..c28219f629 100755 --- a/core/src/mindustry/editor/DrawOperation.java +++ b/core/src/mindustry/editor/DrawOperation.java @@ -52,7 +52,7 @@ public class DrawOperation{ }else if(type == OpType.rotation.ordinal()){ return tile.rotation(); }else if(type == OpType.team.ordinal()){ - return tile.getTeamID(); + return (byte)tile.getTeamID(); }else if(type == OpType.overlay.ordinal()){ return tile.overlayID(); } diff --git a/core/src/mindustry/editor/EditorTile.java b/core/src/mindustry/editor/EditorTile.java index 853b141415..45965b4dab 100644 --- a/core/src/mindustry/editor/EditorTile.java +++ b/core/src/mindustry/editor/EditorTile.java @@ -55,7 +55,7 @@ public class EditorTile extends Tile{ op(OpType.block, block.id); if(rotation != 0) op(OpType.rotation, (byte)rotation); - if(team() != Team.derelict) op(OpType.team, team().id); + if(team() != Team.derelict) op(OpType.team, (byte)team().id); super.setBlock(type, team, rotation); } @@ -67,7 +67,7 @@ public class EditorTile extends Tile{ } if(getTeamID() == team.id) return; - op(OpType.team, getTeamID()); + op(OpType.team, (byte)getTeamID()); super.setTeam(team); } diff --git a/core/src/mindustry/editor/EditorTool.java b/core/src/mindustry/editor/EditorTool.java index a6493d4401..47053049e2 100644 --- a/core/src/mindustry/editor/EditorTool.java +++ b/core/src/mindustry/editor/EditorTool.java @@ -139,7 +139,7 @@ public enum EditorTool{ if(tile.synthetic()){ Team dest = tile.team(); if(dest == editor.drawTeam) return; - fill(editor, x, y, false, t -> t.getTeamID() == (int)dest.id && t.synthetic(), t -> t.setTeam(editor.drawTeam)); + fill(editor, x, y, false, t -> t.getTeamID() == dest.id && t.synthetic(), t -> t.setTeam(editor.drawTeam)); } } } diff --git a/core/src/mindustry/editor/MapGenerateDialog.java b/core/src/mindustry/editor/MapGenerateDialog.java index 0fafa14815..c7d7d86ae4 100644 --- a/core/src/mindustry/editor/MapGenerateDialog.java +++ b/core/src/mindustry/editor/MapGenerateDialog.java @@ -409,7 +409,7 @@ public class MapGenerateDialog extends BaseDialog{ this.floor = floor.id; this.block = wall.id; this.ore = ore.id; - this.team = team.id; + this.team = (byte)team.id; this.rotation = (byte)rotation; } diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 16be684f13..ebea044ba2 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -747,8 +747,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, public void drawTeamTop(){ if(block.teamRegion.found()){ - if(block.teamRegions[team.uid] == block.teamRegion) Draw.color(team.color); - Draw.rect(block.teamRegions[team.uid], x, y); + if(block.teamRegions[team.id] == block.teamRegion) Draw.color(team.color); + Draw.rect(block.teamRegions[team.id], x, y); Draw.color(); } } diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index ad614fa6a2..1797c8d9ee 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -95,7 +95,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{ float ex = mineTile.worldx() + Mathf.sin(Time.time() + 48, swingScl, swingMag); float ey = mineTile.worldy() + Mathf.sin(Time.time() + 48, swingScl + 2f, swingMag); - Draw.z(Layer.power); + Draw.z(Layer.flyingUnit + 0.1f); Draw.color(Color.lightGray, Color.white, 1f - flashScl + Mathf.absin(Time.time(), 0.5f, flashScl)); diff --git a/core/src/mindustry/game/DefaultWaves.java b/core/src/mindustry/game/DefaultWaves.java index eac0714591..426bc75396 100644 --- a/core/src/mindustry/game/DefaultWaves.java +++ b/core/src/mindustry/game/DefaultWaves.java @@ -157,7 +157,7 @@ public class DefaultWaves{ spacing = 3; }}, - new SpawnGroup(UnitTypes.chaosArray){{ + new SpawnGroup(UnitTypes.siegeArray){{ begin = 41; unitAmount = 1; unitScaling = 1; diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index f41a5bc6e0..83b0c67e6a 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -134,16 +134,16 @@ public class Rules{ 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()); + TeamRule out = values[team.id]; + if(out == null) values[team.id] = (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); + if(values[team.id] != null){ + json.writeValue(team.id + "", values[team.id], TeamRule.class); } } } diff --git a/core/src/mindustry/game/Team.java b/core/src/mindustry/game/Team.java index 0c3f4d391e..ec2e437f61 100644 --- a/core/src/mindustry/game/Team.java +++ b/core/src/mindustry/game/Team.java @@ -4,7 +4,6 @@ import arc.*; import arc.graphics.*; import arc.math.*; import arc.struct.*; -import arc.util.*; import arc.util.ArcAnnotate.*; import mindustry.game.Rules.*; import mindustry.game.Teams.*; @@ -14,8 +13,7 @@ import mindustry.world.blocks.storage.CoreBlock.*; import static mindustry.Vars.*; public class Team implements Comparable{ - public final byte id; - public final int uid; + public final int id; public final Color color; public final Color[] palette; public boolean hasPalette; @@ -52,12 +50,10 @@ public class Team implements Comparable{ protected Team(int id, String name, Color color){ this.name = name; this.color = color; - this.id = (byte)id; + this.id = id; - int us = Pack.u(this.id); - uid = us; - if(us < 6) baseTeams[us] = this; - all[us] = this; + if(id < 6) baseTeams[id] = this; + all[id] = this; palette = new Color[3]; palette[0] = color; diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index 2327e1c0d2..592aa9d444 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -62,10 +62,10 @@ public class Teams{ /** Returns team data by type. */ public TeamData get(Team team){ - if(map[team.uid] == null){ - map[team.uid] = new TeamData(team); + if(map[team.id] == null){ + map[team.id] = new TeamData(team); } - return map[team.uid]; + return map[team.id]; } public Seq playerCores(){ diff --git a/core/src/mindustry/io/SaveVersion.java b/core/src/mindustry/io/SaveVersion.java index 3caee54d27..c2e4ce88e1 100644 --- a/core/src/mindustry/io/SaveVersion.java +++ b/core/src/mindustry/io/SaveVersion.java @@ -98,7 +98,7 @@ public abstract class SaveVersion extends SaveFileReader{ "viewpos", Tmp.v1.set(player == null ? Vec2.ZERO : player).toString(), "controlledType", headless || control.input.controlledType == null ? "null" : control.input.controlledType.name, "nocores", state.rules.defaultTeam.cores().isEmpty(), - "playerteam", player == null ? state.rules.defaultTeam.uid : player.team().uid + "playerteam", player == null ? state.rules.defaultTeam.id : player.team().id ).merge(tags)); } @@ -119,7 +119,7 @@ public abstract class SaveVersion extends SaveFileReader{ player.set(Tmp.v1); control.input.controlledType = content.getByName(ContentType.unit, map.get("controlledType", "")); - Team team = Team.get(map.getInt("playerteam", state.rules.defaultTeam.uid)); + Team team = Team.get(map.getInt("playerteam", state.rules.defaultTeam.id)); if(!net.client() && team != Team.derelict){ player.team(team); } diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index d6a2333578..865d8dfc85 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -631,7 +631,7 @@ public class Block extends UnlockableContent{ //load specific team regions teamRegions = new TextureRegion[Team.all.length]; for(Team team : Team.all){ - teamRegions[team.uid] = teamRegion.found() ? Core.atlas.find(name + "-team-" + team.name, teamRegion) : teamRegion; + teamRegions[team.id] = teamRegion.found() ? Core.atlas.find(name + "-team-" + team.name, teamRegion) : teamRegion; } } diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 371e522a40..2406f4c269 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -171,7 +171,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ return build == null ? y : build.tile.y; } - public byte getTeamID(){ + public int getTeamID(){ return team().id; }