Added spatial indexing of tile targets, many bugfixes

This commit is contained in:
Anuken
2018-06-20 22:56:53 -04:00
parent 45da578756
commit ca30f49481
11 changed files with 105 additions and 52 deletions
+5
View File
@@ -1,6 +1,7 @@
package io.anuke.mindustry.io;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.ucore.function.Supplier;
import java.io.InputStream;
@@ -24,6 +25,10 @@ public class Map {
this.stream = streamSupplier;
}
public Map(String unknownName, int width, int height){
this(unknownName, new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null);
}
public String getDisplayName(){
return meta.tags.get("name", name);
}
@@ -9,13 +9,13 @@ import io.anuke.mindustry.entities.traits.TypeTrait;
import io.anuke.mindustry.game.Difficulty;
import io.anuke.mindustry.game.GameMode;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.io.Map;
import io.anuke.mindustry.io.SaveFileVersion;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.BlockPart;
import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.entities.EntityGroup;
import io.anuke.ucore.entities.EntityPhysics;
import io.anuke.ucore.entities.trait.Entity;
import io.anuke.ucore.util.Bits;
@@ -23,7 +23,8 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.world;
public class Save16 extends SaveFileVersion {
@@ -39,7 +40,8 @@ public class Save16 extends SaveFileVersion {
//general state
byte mode = stream.readByte();
String mapname = stream.readUTF();
world.setMap(world.maps().getByName(mapname));
Map map = world.maps().getByName(mapname);
world.setMap(map);
int wave = stream.readInt();
byte difficulty = stream.readByte();
@@ -55,13 +57,13 @@ public class Save16 extends SaveFileVersion {
int blocksize = stream.readInt();
IntMap<Block> map = new IntMap<>();
IntMap<Block> blockMap = new IntMap<>();
for(int i = 0; i < blocksize; i ++){
String name = stream.readUTF();
int id = stream.readShort();
map.put(id, Block.getByName(name));
blockMap.put(id, Block.getByName(name));
}
//entities
@@ -82,7 +84,9 @@ public class Save16 extends SaveFileVersion {
short width = stream.readShort();
short height = stream.readShort();
EntityPhysics.resizeTree(0, 0, width * tilesize, height * tilesize);
if(map == null){
world.setMap(new Map("unknown", width, height));
}
world.beginMapLoad();