mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Added Units class, removed writeString() from SaveFileVersion
This commit is contained in:
parent
b4ec2ccb90
commit
807c4688c2
@ -25,7 +25,7 @@ allprojects {
|
||||
appName = 'Mindustry'
|
||||
gdxVersion = '1.9.8'
|
||||
aiVersion = '1.8.1'
|
||||
uCoreVersion = '36de2b4'
|
||||
uCoreVersion = 'cfc0943'
|
||||
|
||||
getVersionString = {
|
||||
String buildVersion = getBuildVersion()
|
||||
|
@ -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
|
||||
|
32
core/src/io/anuke/mindustry/entities/Units.java
Normal file
32
core/src/io/anuke/mindustry/entities/Units.java
Normal 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){
|
||||
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user