Added Units class, removed writeString() from SaveFileVersion

This commit is contained in:
Anuken
2018-03-15 13:30:06 -04:00
parent b4ec2ccb90
commit 807c4688c2
5 changed files with 37 additions and 17 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ allprojects {
appName = 'Mindustry' appName = 'Mindustry'
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
aiVersion = '1.8.1' aiVersion = '1.8.1'
uCoreVersion = '36de2b4' uCoreVersion = 'cfc0943'
getVersionString = { getVersionString = {
String buildVersion = getBuildVersion() String buildVersion = getBuildVersion()
+2 -2
View File
@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Wed Mar 14 23:06:35 EDT 2018 #Thu Mar 15 12:56:43 EDT 2018
version=release version=release
androidBuildCode=521 androidBuildCode=523
name=Mindustry name=Mindustry
code=3.4 code=3.4
build=custom build build=custom build
@@ -0,0 +1,32 @@
package io.anuke.mindustry.entities;
import com.badlogic.gdx.math.Rectangle;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.game.Team;
import io.anuke.ucore.entities.EntityGroup;
import io.anuke.ucore.function.Consumer;
import static io.anuke.mindustry.Vars.playerGroup;
import static io.anuke.mindustry.Vars.unitGroups;
/**Utility class for unit-based interactions.*/
public class Units {
public static void allUnits(Consumer<Unit> cons){
for(EntityGroup<BaseUnit> group : unitGroups){
if(!group.isEmpty()){
for(BaseUnit unit : group.all()){
cons.accept(unit);
}
}
}
for(Player player : playerGroup.all()){
cons.accept(player);
}
}
public static void getNearbyEnemies(Team team, Rectangle rect, Consumer<Unit> cons){
}
}
@@ -23,16 +23,4 @@ public abstract class SaveFileVersion {
public abstract void read(DataInputStream stream) throws IOException; public abstract void read(DataInputStream stream) throws IOException;
public abstract void write(DataOutputStream stream) throws IOException; public abstract void write(DataOutputStream stream) throws IOException;
public static void writeString(DataOutputStream stream, String string) throws IOException{
stream.writeByte(string.length());
stream.writeBytes(string);
}
public static String readString(DataInputStream stream) throws IOException{
int length = stream.readByte();
byte[] result = new byte[length];
stream.read(result);
return new String(result);
}
} }
@@ -65,7 +65,7 @@ public class Save16 extends SaveFileVersion {
IntMap<Block> map = new IntMap<>(); IntMap<Block> map = new IntMap<>();
for(int i = 0; i < blocksize; i ++){ for(int i = 0; i < blocksize; i ++){
String name = readString(stream); String name = stream.readUTF();
int id = stream.readShort(); int id = stream.readShort();
map.put(id, Block.getByName(name)); map.put(id, Block.getByName(name));
@@ -221,7 +221,7 @@ public class Save16 extends SaveFileVersion {
for(int i = 0; i < Block.getAllBlocks().size; i ++){ for(int i = 0; i < Block.getAllBlocks().size; i ++){
Block block = Block.getAllBlocks().get(i); Block block = Block.getAllBlocks().get(i);
writeString(stream, block.name); stream.writeUTF(block.name);
stream.writeShort(block.id); stream.writeShort(block.id);
} }