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

View File

@ -25,7 +25,7 @@ allprojects {
appName = 'Mindustry'
gdxVersion = '1.9.8'
aiVersion = '1.8.1'
uCoreVersion = '36de2b4'
uCoreVersion = 'cfc0943'
getVersionString = {
String buildVersion = getBuildVersion()

View File

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Wed Mar 14 23:06:35 EDT 2018
#Thu Mar 15 12:56:43 EDT 2018
version=release
androidBuildCode=521
androidBuildCode=523
name=Mindustry
code=3.4
build=custom build

View File

@ -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){
}
}

View File

@ -23,16 +23,4 @@ public abstract class SaveFileVersion {
public abstract void read(DataInputStream 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);
}
}

View File

@ -65,7 +65,7 @@ public class Save16 extends SaveFileVersion {
IntMap<Block> map = new IntMap<>();
for(int i = 0; i < blocksize; i ++){
String name = readString(stream);
String name = stream.readUTF();
int id = stream.readShort();
map.put(id, Block.getByName(name));
@ -221,7 +221,7 @@ public class Save16 extends SaveFileVersion {
for(int i = 0; i < Block.getAllBlocks().size; i ++){
Block block = Block.getAllBlocks().get(i);
writeString(stream, block.name);
stream.writeUTF(block.name);
stream.writeShort(block.id);
}