everything is borked
This commit is contained in:
@@ -48,14 +48,10 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
TypeName jsonType = ClassName.bestGuess("io.anuke.arc.util.serialization.Json");
|
TypeName jsonType = ClassName.bestGuess("io.anuke.arc.util.serialization.Json");
|
||||||
TypeName jsonValueType = ClassName.bestGuess("io.anuke.arc.util.serialization.JsonValue");
|
TypeName jsonValueType = ClassName.bestGuess("io.anuke.arc.util.serialization.JsonValue");
|
||||||
TypeName ubJsonWriterType = ClassName.bestGuess("io.anuke.arc.util.serialization.UBJsonWriter");
|
|
||||||
TypeName ubJsonReaderType = ClassName.bestGuess("io.anuke.arc.util.serialization.UBJsonReader");
|
|
||||||
|
|
||||||
classBuilder.addField(jsonType, "bjson", Modifier.STATIC, Modifier.PRIVATE);
|
classBuilder.addField(jsonType, "bjson", Modifier.STATIC, Modifier.PRIVATE);
|
||||||
classBuilder.addField(ubJsonReaderType, "bjsonReader", Modifier.STATIC, Modifier.PRIVATE);
|
|
||||||
classBuilder.addStaticBlock(CodeBlock.builder()
|
classBuilder.addStaticBlock(CodeBlock.builder()
|
||||||
.addStatement("bjson = new " + jsonType + "()")
|
.addStatement("bjson = new " + jsonType + "()")
|
||||||
.addStatement("bjsonReader = new " + ubJsonReaderType + "()")
|
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
for(TypeElement elem : elements){
|
for(TypeElement elem : elements){
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class Blocks implements ContentList{
|
|||||||
public static Block
|
public static Block
|
||||||
|
|
||||||
//environment
|
//environment
|
||||||
air, part, spawn, deepwater, water, taintedWater, tar, stone, craters, charr, sand, darksand, ice, snow, darksandTaintedWater,
|
air, spawn, deepwater, water, taintedWater, tar, stone, craters, charr, sand, darksand, ice, snow, darksandTaintedWater,
|
||||||
holostone, rocks, sporerocks, icerocks, cliffs, sporePine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
|
holostone, rocks, sporerocks, icerocks, cliffs, sporePine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
|
||||||
iceSnow, sandWater, darksandWater, duneRocks, sandRocks, moss, sporeMoss, shale, shaleRocks, shaleBoulder, grass, salt,
|
iceSnow, sandWater, darksandWater, duneRocks, sandRocks, moss, sporeMoss, shale, shaleRocks, shaleBoulder, grass, salt,
|
||||||
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks, rock, snowrock, saltRocks,
|
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks, rock, snowrock, saltRocks,
|
||||||
@@ -109,7 +109,12 @@ public class Blocks implements ContentList{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
part = new BlockPart();
|
//create special blockpart variants
|
||||||
|
for(int dx = 0; dx < BlockPart.maxSize; dx++){
|
||||||
|
for(int dy = 0; dy < BlockPart.maxSize; dy++){
|
||||||
|
new BlockPart(dx - BlockPart.maxSize/2, dy - BlockPart.maxSize/2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
spawn = new Block("spawn");
|
spawn = new Block("spawn");
|
||||||
|
|
||||||
|
|||||||
@@ -90,17 +90,12 @@ public class ContentLoader{
|
|||||||
for(Array<Content> arr : contentMap){
|
for(Array<Content> arr : contentMap){
|
||||||
for(int i = 0; i < arr.size; i++){
|
for(int i = 0; i < arr.size; i++){
|
||||||
int id = arr.get(i).id;
|
int id = arr.get(i).id;
|
||||||
if(id < 0) id += 256;
|
|
||||||
if(id != i){
|
if(id != i){
|
||||||
throw new IllegalArgumentException("Out-of-order IDs for content '" + arr.get(i) + "' (expected " + i + " but got " + id + ")");
|
throw new IllegalArgumentException("Out-of-order IDs for content '" + arr.get(i) + "' (expected " + i + " but got " + id + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(blocks().size >= 256){
|
|
||||||
throw new ImpendingDoomException("THE TIME HAS COME. More than 256 blocks have been created.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(verbose){
|
if(verbose){
|
||||||
Log.info("--- CONTENT INFO ---");
|
Log.info("--- CONTENT INFO ---");
|
||||||
for(int k = 0; k < contentMap.length; k++){
|
for(int k = 0; k < contentMap.length; k++){
|
||||||
@@ -129,7 +124,7 @@ public class ContentLoader{
|
|||||||
/** Loads block colors. */
|
/** Loads block colors. */
|
||||||
public void loadColors(){
|
public void loadColors(){
|
||||||
Pixmap pixmap = new Pixmap(files.internal("sprites/block_colors.png"));
|
Pixmap pixmap = new Pixmap(files.internal("sprites/block_colors.png"));
|
||||||
for(int i = 0; i < 256; i++){
|
for(int i = 0; i < pixmap.getWidth(); i++){
|
||||||
if(blocks().size > i){
|
if(blocks().size > i){
|
||||||
int color = pixmap.getPixel(i, 0);
|
int color = pixmap.getPixel(i, 0);
|
||||||
|
|
||||||
@@ -170,8 +165,6 @@ public class ContentLoader{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Content> T getByID(ContentType type, int id){
|
public <T extends Content> T getByID(ContentType type, int id){
|
||||||
//offset negative values by 256, as they are probably a product of byte overflow
|
|
||||||
if(id < 0) id += 256;
|
|
||||||
|
|
||||||
if(temporaryMapper != null && temporaryMapper[type.ordinal()] != null && temporaryMapper[type.ordinal()].length != 0){
|
if(temporaryMapper != null && temporaryMapper[type.ordinal()] != null && temporaryMapper[type.ordinal()].length != 0){
|
||||||
if(temporaryMapper[type.ordinal()].length <= id || temporaryMapper[type.ordinal()][id] == null){
|
if(temporaryMapper[type.ordinal()].length <= id || temporaryMapper[type.ordinal()][id] == null){
|
||||||
@@ -243,10 +236,4 @@ public class ContentLoader{
|
|||||||
TypeTrait.registerType(Bullet.class, Bullet::new);
|
TypeTrait.registerType(Bullet.class, Bullet::new);
|
||||||
TypeTrait.registerType(Lightning.class, Lightning::new);
|
TypeTrait.registerType(Lightning.class, Lightning::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ImpendingDoomException extends RuntimeException{
|
|
||||||
ImpendingDoomException(String s){
|
|
||||||
super(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,12 @@ public class World implements ApplicationListener{
|
|||||||
return tiles[x][y];
|
return tiles[x][y];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable Tile ltile(int x, int y){
|
||||||
|
Tile tile = tile(x, y);
|
||||||
|
if(tile == null) return null;
|
||||||
|
return tile.block().linked(tile);
|
||||||
|
}
|
||||||
|
|
||||||
public Tile rawTile(int x, int y){
|
public Tile rawTile(int x, int y){
|
||||||
return tiles[x][y];
|
return tiles[x][y];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class EditorTile extends Tile{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOverlayID(byte ore){
|
public void setOverlayID(byte ore){
|
||||||
byte previous = getOverlayID();
|
byte previous = overlayID();
|
||||||
if(previous == ore) return;
|
if(previous == ore) return;
|
||||||
super.setOverlayID(ore);
|
super.setOverlayID(ore);
|
||||||
op(TileOp.get(x, y, (byte)OpType.ore.ordinal(), previous, ore));
|
op(TileOp.get(x, y, (byte)OpType.ore.ordinal(), previous, ore));
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import io.anuke.arc.collection.Array;
|
|||||||
import io.anuke.arc.collection.ObjectSet;
|
import io.anuke.arc.collection.ObjectSet;
|
||||||
import io.anuke.arc.math.geom.Point2;
|
import io.anuke.arc.math.geom.Point2;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.Interval;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
import io.anuke.mindustry.entities.EntityGroup;
|
import io.anuke.mindustry.entities.EntityGroup;
|
||||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||||
import io.anuke.mindustry.entities.impl.BaseEntity;
|
import io.anuke.mindustry.entities.impl.BaseEntity;
|
||||||
@@ -116,10 +115,28 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
stream.writeShort((short)health);
|
||||||
|
stream.writeByte(Pack.byteByte(tile.getTeamID(), tile.getRotation())); //team + rotation
|
||||||
|
if(items != null) items.write(stream);
|
||||||
|
if(power != null) power.write(stream);
|
||||||
|
if(liquids != null) liquids.write(stream);
|
||||||
|
if(cons != null) cons.write(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
health = stream.readUnsignedShort();
|
||||||
|
byte tr = stream.readByte();
|
||||||
|
byte team = Pack.leftByte(tr);
|
||||||
|
byte rotation = Pack.rightByte(tr);
|
||||||
|
|
||||||
|
tile.setTeam(Team.all[team]);
|
||||||
|
tile.setRotation(rotation);
|
||||||
|
|
||||||
|
if(items != null) items.read(stream);
|
||||||
|
if(power != null) power.read(stream);
|
||||||
|
if(liquids != null) liquids.read(stream);
|
||||||
|
if(cons != null) cons.read(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean collide(Bullet other){
|
public boolean collide(Bullet other){
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import io.anuke.mindustry.type.ContentType;
|
|||||||
|
|
||||||
/** Base class for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}. */
|
/** Base class for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}. */
|
||||||
public abstract class Content{
|
public abstract class Content{
|
||||||
public final byte id;
|
public final short id;
|
||||||
|
|
||||||
public Content(){
|
public Content(){
|
||||||
this.id = (byte)Vars.content.getBy(getContentType()).size;
|
this.id = (short)Vars.content.getBy(getContentType()).size;
|
||||||
Vars.content.handleContent(this);
|
Vars.content.handleContent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.game;
|
|||||||
|
|
||||||
import io.anuke.annotations.Annotations.Serialize;
|
import io.anuke.annotations.Annotations.Serialize;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
|
import io.anuke.mindustry.type.Zone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines current rules on how the game should function.
|
* Defines current rules on how the game should function.
|
||||||
@@ -47,10 +48,10 @@ public class Rules{
|
|||||||
public float bossWaveMultiplier = 3f;
|
public float bossWaveMultiplier = 3f;
|
||||||
/** How many times longer a launch wave takes. */
|
/** How many times longer a launch wave takes. */
|
||||||
public float launchWaveMultiplier = 2f;
|
public float launchWaveMultiplier = 2f;
|
||||||
/** Zone ID, -1 for invalid zone. */
|
/** Zone for saves that have them.*/
|
||||||
public byte zone = -1;
|
public Zone zone;
|
||||||
/** Spawn layout. Should be assigned on save load based on map or zone. */
|
/** Spawn layout. Should be assigned on save load based on map or zone. */
|
||||||
public transient Array<SpawnGroup> spawns = DefaultWaves.get();
|
public Array<SpawnGroup> spawns = DefaultWaves.get();
|
||||||
/** Determines if there should be limited respawns. */
|
/** Determines if there should be limited respawns. */
|
||||||
public boolean limitedRespawns = false;
|
public boolean limitedRespawns = false;
|
||||||
/** How many times player can respawn during one wave. */
|
/** How many times player can respawn during one wave. */
|
||||||
|
|||||||
@@ -144,13 +144,13 @@ public class MapIO{
|
|||||||
for(int i = 0; i < tiles.length * tiles[0].length; i++){
|
for(int i = 0; i < tiles.length * tiles[0].length; i++){
|
||||||
Tile tile = tiles[i % width][i / width];
|
Tile tile = tiles[i % width][i / width];
|
||||||
stream.writeByte(tile.getFloorID());
|
stream.writeByte(tile.getFloorID());
|
||||||
stream.writeByte(tile.getOverlayID());
|
stream.writeByte(tile.overlayID());
|
||||||
int consecutives = 0;
|
int consecutives = 0;
|
||||||
|
|
||||||
for(int j = i + 1; j < width * height && consecutives < 255; j++){
|
for(int j = i + 1; j < width * height && consecutives < 255; j++){
|
||||||
Tile nextTile = tiles[j % width][j / width];
|
Tile nextTile = tiles[j % width][j / width];
|
||||||
|
|
||||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.block() != Blocks.air || nextTile.getOverlayID() != tile.getOverlayID()){
|
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.block() != Blocks.air || nextTile.overlayID() != tile.overlayID()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package io.anuke.mindustry.io;
|
|||||||
|
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.collection.ObjectMap.Entry;
|
import io.anuke.arc.collection.ObjectMap.Entry;
|
||||||
import io.anuke.arc.util.Pack;
|
|
||||||
import io.anuke.arc.util.io.ReusableByteOutStream;
|
import io.anuke.arc.util.io.ReusableByteOutStream;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
|
||||||
import io.anuke.mindustry.entities.Entities;
|
import io.anuke.mindustry.entities.Entities;
|
||||||
import io.anuke.mindustry.entities.EntityGroup;
|
import io.anuke.mindustry.entities.EntityGroup;
|
||||||
import io.anuke.mindustry.entities.traits.*;
|
import io.anuke.mindustry.entities.traits.*;
|
||||||
@@ -111,17 +109,17 @@ public abstract class SaveFileVersion{
|
|||||||
stream.writeShort(world.width());
|
stream.writeShort(world.width());
|
||||||
stream.writeShort(world.height());
|
stream.writeShort(world.height());
|
||||||
|
|
||||||
//floor first
|
//floor + overlay
|
||||||
for(int i = 0; i < world.width() * world.height(); i++){
|
for(int i = 0; i < world.width() * world.height(); i++){
|
||||||
Tile tile = world.tile(i % world.width(), i / world.width());
|
Tile tile = world.tile(i % world.width(), i / world.width());
|
||||||
stream.writeByte(tile.getFloorID());
|
stream.writeShort(tile.floorID());
|
||||||
stream.writeByte(tile.getOverlayID());
|
stream.writeShort(tile.overlayID());
|
||||||
int consecutives = 0;
|
int consecutives = 0;
|
||||||
|
|
||||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
||||||
Tile nextTile = world.tile(j % world.width(), j / world.width());
|
Tile nextTile = world.tile(j % world.width(), j / world.width());
|
||||||
|
|
||||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.getOverlayID() != tile.getOverlayID()){
|
if(nextTile.floorID() != tile.floorID() || nextTile.overlayID() != tile.overlayID()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,19 +133,9 @@ public abstract class SaveFileVersion{
|
|||||||
//blocks
|
//blocks
|
||||||
for(int i = 0; i < world.width() * world.height(); i++){
|
for(int i = 0; i < world.width() * world.height(); i++){
|
||||||
Tile tile = world.tile(i % world.width(), i / world.width());
|
Tile tile = world.tile(i % world.width(), i / world.width());
|
||||||
stream.writeByte(tile.getBlockID());
|
stream.writeShort(tile.blockID());
|
||||||
|
|
||||||
if(tile.block() == Blocks.part){
|
|
||||||
stream.writeByte(tile.getLinkByte());
|
|
||||||
}else if(tile.entity != null){
|
|
||||||
stream.writeByte(Pack.byteByte(tile.getTeamID(), tile.getRotation())); //team + rotation
|
|
||||||
stream.writeShort((short)tile.entity.health); //health
|
|
||||||
|
|
||||||
if(tile.entity.items != null) tile.entity.items.write(stream);
|
|
||||||
if(tile.entity.power != null) tile.entity.power.write(stream);
|
|
||||||
if(tile.entity.liquids != null) tile.entity.liquids.write(stream);
|
|
||||||
if(tile.entity.cons != null) tile.entity.cons.write(stream);
|
|
||||||
|
|
||||||
|
if(tile.entity != null){
|
||||||
tile.entity.write(stream);
|
tile.entity.write(stream);
|
||||||
}else{
|
}else{
|
||||||
//write consecutive non-entity blocks
|
//write consecutive non-entity blocks
|
||||||
@@ -156,7 +144,7 @@ public abstract class SaveFileVersion{
|
|||||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
||||||
Tile nextTile = world.tile(j % world.width(), j / world.width());
|
Tile nextTile = world.tile(j % world.width(), j / world.width());
|
||||||
|
|
||||||
if(nextTile.block() != tile.block()){
|
if(nextTile.blockID() != tile.blockID()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,19 +168,15 @@ public abstract class SaveFileVersion{
|
|||||||
//read floor and create tiles first
|
//read floor and create tiles first
|
||||||
for(int i = 0; i < width * height; i++){
|
for(int i = 0; i < width * height; i++){
|
||||||
int x = i % width, y = i / width;
|
int x = i % width, y = i / width;
|
||||||
byte floorid = stream.readByte();
|
short floorid = stream.readShort();
|
||||||
byte oreid = stream.readByte();
|
short oreid = stream.readShort();
|
||||||
int consecutives = stream.readUnsignedByte();
|
int consecutives = stream.readUnsignedByte();
|
||||||
Block ore = content.block(oreid);
|
|
||||||
|
|
||||||
tiles[x][y] = new Tile(x, y, floorid, (byte)0);
|
tiles[x][y] = new Tile(false, x, y, floorid, oreid);
|
||||||
tiles[x][y].setOverlay(ore);
|
|
||||||
|
|
||||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||||
int newx = j % width, newy = j / width;
|
int newx = j % width, newy = j / width;
|
||||||
Tile newTile = new Tile(newx, newy, floorid, (byte)0);
|
tiles[newx][newy] = new Tile(false, newx, newy, floorid, oreid);
|
||||||
newTile.setOverlay(ore);
|
|
||||||
tiles[newx][newy] = newTile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i += consecutives;
|
i += consecutives;
|
||||||
@@ -205,24 +189,7 @@ public abstract class SaveFileVersion{
|
|||||||
Tile tile = tiles[x][y];
|
Tile tile = tiles[x][y];
|
||||||
tile.setBlock(block);
|
tile.setBlock(block);
|
||||||
|
|
||||||
if(block == Blocks.part){
|
if(tile.entity != null){
|
||||||
tile.setLinkByte(stream.readByte());
|
|
||||||
}else if(tile.entity != null){
|
|
||||||
byte tr = stream.readByte();
|
|
||||||
short health = stream.readShort();
|
|
||||||
|
|
||||||
byte team = Pack.leftByte(tr);
|
|
||||||
byte rotation = Pack.rightByte(tr);
|
|
||||||
|
|
||||||
tile.setTeam(Team.all[team]);
|
|
||||||
tile.entity.health = health;
|
|
||||||
tile.setRotation(rotation);
|
|
||||||
|
|
||||||
if(tile.entity.items != null) tile.entity.items.read(stream);
|
|
||||||
if(tile.entity.power != null) tile.entity.power.read(stream);
|
|
||||||
if(tile.entity.liquids != null) tile.entity.liquids.read(stream);
|
|
||||||
if(tile.entity.cons != null) tile.entity.cons.read(stream);
|
|
||||||
|
|
||||||
tile.entity.read(stream);
|
tile.entity.read(stream);
|
||||||
}else{
|
}else{
|
||||||
int consecutives = stream.readUnsignedByte();
|
int consecutives = stream.readUnsignedByte();
|
||||||
|
|||||||
@@ -451,6 +451,10 @@ public class Block extends BlockStorage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Tile linked(Tile tile){
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSolidFor(Tile tile){
|
public boolean isSolidFor(Tile tile){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.function.Consumer;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.*;
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.arc.util.Pack;
|
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||||
import io.anuke.mindustry.entities.type.TileEntity;
|
import io.anuke.mindustry.entities.type.TileEntity;
|
||||||
@@ -24,14 +22,12 @@ public class Tile implements Position, TargetTrait{
|
|||||||
public short x, y;
|
public short x, y;
|
||||||
protected Block block;
|
protected Block block;
|
||||||
protected Floor floor;
|
protected Floor floor;
|
||||||
/** Rotation, 0-3. Also used to store offload location and link, in which case it can be any number.
|
/** Rotation, 0-3. Also used to store offload location, in which case it can be any number.*/
|
||||||
* When saved in non-link form, this data is truncated to 4 bits = max 16.*/
|
|
||||||
private byte rotation;
|
private byte rotation;
|
||||||
/** Team ordinal. Keep in mind that this is written as 4 bits, which means that there are only 2^4 = 16 possible teams.
|
/** Team ordinal. */
|
||||||
* Complications may arise from using signed bytes as well. Be careful.*/
|
|
||||||
private byte team;
|
private byte team;
|
||||||
/** Ore that is on top of this (floor) block. */
|
/** Ore that is on top of this (floor) block. */
|
||||||
private byte overlay = 0;
|
private short overlay = 0;
|
||||||
|
|
||||||
public Tile(int x, int y){
|
public Tile(int x, int y){
|
||||||
this.x = (short)x;
|
this.x = (short)x;
|
||||||
@@ -39,20 +35,11 @@ public class Tile implements Position, TargetTrait{
|
|||||||
block = floor = (Floor)Blocks.air;
|
block = floor = (Floor)Blocks.air;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile(int x, int y, byte floor, byte block){
|
public Tile(boolean __removeThisLater, int x, int y, short floor, short overlay){
|
||||||
this(x, y);
|
this.x = (short)x;
|
||||||
|
this.y = (short)y;
|
||||||
this.floor = (Floor)content.block(floor);
|
this.floor = (Floor)content.block(floor);
|
||||||
this.block = content.block(block);
|
this.overlay = overlay;
|
||||||
changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tile(int x, int y, byte floor, byte block, byte rotation, byte team){
|
|
||||||
this(x, y);
|
|
||||||
this.floor = (Floor)content.block(floor);
|
|
||||||
this.block = content.block(block);
|
|
||||||
this.rotation = rotation;
|
|
||||||
changed();
|
|
||||||
this.team = team;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns this tile's position as a {@link Pos}. */
|
/** Returns this tile's position as a {@link Pos}. */
|
||||||
@@ -60,14 +47,6 @@ public class Tile implements Position, TargetTrait{
|
|||||||
return Pos.get(x, y);
|
return Pos.get(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getBlockID(){
|
|
||||||
return block.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getFloorID(){
|
|
||||||
return floor.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return relative rotation to a coordinate. Returns -1 if the coordinate is not near this tile. */
|
/** Return relative rotation to a coordinate. Returns -1 if the coordinate is not near this tile. */
|
||||||
public byte relativeTo(int cx, int cy){
|
public byte relativeTo(int cx, int cy){
|
||||||
if(x == cx && y == cy - 1) return 1;
|
if(x == cx && y == cy - 1) return 1;
|
||||||
@@ -206,11 +185,19 @@ public class Tile implements Position, TargetTrait{
|
|||||||
this.rotation = dump;
|
this.rotation = dump;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getOverlayID(){
|
public short overlayID(){
|
||||||
return overlay;
|
return overlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOverlayID(byte ore){
|
public short blockID(){
|
||||||
|
return block.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short floorID(){
|
||||||
|
return floor.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOverlayID(short ore){
|
||||||
this.overlay = ore;
|
this.overlay = ore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,21 +242,7 @@ public class Tile implements Position, TargetTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLinked(){
|
public boolean isLinked(){
|
||||||
return block == Blocks.part;
|
return block instanceof BlockPart;
|
||||||
}
|
|
||||||
|
|
||||||
public byte getLinkByte(){
|
|
||||||
return rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLinkByte(byte b){
|
|
||||||
this.rotation = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets this to a linked tile, which sets the block to a part. dx and dy can only be -8-7. */
|
|
||||||
public void setLinked(byte dx, byte dy){
|
|
||||||
setBlock(Blocks.part);
|
|
||||||
rotation = Pack.byteByte((byte)(dx + 8), (byte)(dy + 8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -315,7 +288,7 @@ public class Tile implements Position, TargetTrait{
|
|||||||
return tmpArray;
|
return tmpArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the block the multiblock is linked to, or null if it is not linked to any block. */
|
/** Returns the block the multiblock is linked to, or null if it is not linked to any block.
|
||||||
public Tile getLinked(){
|
public Tile getLinked(){
|
||||||
if(!isLinked()){
|
if(!isLinked()){
|
||||||
return null;
|
return null;
|
||||||
@@ -324,28 +297,10 @@ public class Tile implements Position, TargetTrait{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void allNearby(Consumer<Tile> cons){
|
|
||||||
for(Point2 point : Edges.getEdges(block().size)){
|
|
||||||
Tile tile = world.tile(x + point.x, y + point.y);
|
|
||||||
if(tile != null){
|
|
||||||
cons.accept(tile.target());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void allInside(Consumer<Tile> cons){
|
|
||||||
for(Point2 point : Edges.getInsideEdges(block().size)){
|
|
||||||
Tile tile = world.tile(x + point.x, y + point.y);
|
|
||||||
if(tile != null){
|
|
||||||
cons.accept(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tile target(){
|
public Tile target(){
|
||||||
Tile link = getLinked();
|
Tile link = getLinked();
|
||||||
return link == null ? this : link;
|
return link == null ? this : link;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public Rectangle getHitbox(Rectangle rect){
|
public Rectangle getHitbox(Rectangle rect){
|
||||||
return rect.setSize(block().size * tilesize).setCenter(drawx(), drawy());
|
return rect.setSize(block().size * tilesize).setCenter(drawx(), drawy());
|
||||||
@@ -507,6 +462,8 @@ public class Tile implements Position, TargetTrait{
|
|||||||
(isLinked() ? " link=[" + linkX(rotation) + ", " + linkY(rotation) + "]" : "");
|
(isLinked() ? " link=[" + linkX(rotation) + ", " + linkY(rotation) + "]" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO remove these!
|
||||||
|
|
||||||
/**Returns the relative X from a link byte.*/
|
/**Returns the relative X from a link byte.*/
|
||||||
public static int linkX(byte value){
|
public static int linkX(byte value){
|
||||||
return -((byte)((value >> 4) & (byte)0x0F) - 8);
|
return -((byte)((value >> 4) & (byte)0x0F) - 8);
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package io.anuke.mindustry.world.blocks;
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
import io.anuke.mindustry.type.Item;
|
|
||||||
import io.anuke.mindustry.type.Liquid;
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
@@ -11,18 +9,35 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
* They are made to share all properties from the linked tile/block.
|
* They are made to share all properties from the linked tile/block.
|
||||||
*/
|
*/
|
||||||
public class BlockPart extends Block{
|
public class BlockPart extends Block{
|
||||||
|
public final static int maxSize = 9;
|
||||||
|
private final static BlockPart[][] parts = new BlockPart[maxSize][maxSize];
|
||||||
|
|
||||||
public BlockPart(){
|
private final int dx, dy;
|
||||||
super("part");
|
|
||||||
|
public BlockPart(int dx, int dy){
|
||||||
|
super("part_" + dx + "_" + dy);
|
||||||
|
this.dx = dx;
|
||||||
|
this.dy = dy;
|
||||||
solid = false;
|
solid = false;
|
||||||
hasPower = hasItems = hasLiquids = true;
|
hasPower = hasItems = hasLiquids = true;
|
||||||
|
parts[dx + maxSize/2][dy + maxSize/2] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockPart get(int dx, int dy){
|
||||||
|
return parts[dx + maxSize/2][dy + maxSize/2];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTeam(Tile tile){
|
public Tile linked(Tile tile){
|
||||||
|
return tile.getNearby(dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawTeam(Tile tile){}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Tile tile){}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean synthetic(){
|
public boolean synthetic(){
|
||||||
return true;
|
return true;
|
||||||
@@ -33,43 +48,4 @@ public class BlockPart extends Block{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Tile tile){
|
|
||||||
//do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSolidFor(Tile tile){
|
|
||||||
return tile.getLinked() == null
|
|
||||||
|| (tile.getLinked().block() instanceof BlockPart || tile.getLinked().solid()
|
|
||||||
|| tile.getLinked().block().isSolidFor(tile.getLinked()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleItem(Item item, Tile tile, Tile source){
|
|
||||||
tile.getLinked().block().handleItem(item, tile.getLinked(), source);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
|
||||||
return tile.getLinked().block().acceptItem(item, tile.getLinked(), source);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
|
||||||
Block block = linked(tile);
|
|
||||||
return block.hasLiquids
|
|
||||||
&& block.acceptLiquid(tile.getLinked(), source, liquid, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
|
||||||
Block block = linked(tile);
|
|
||||||
block.handleLiquid(tile.getLinked(), source, liquid, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Block linked(Tile tile){
|
|
||||||
return tile.getLinked().block();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ public class BuildBlock extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeFloat(progress);
|
stream.writeFloat(progress);
|
||||||
stream.writeShort(previous == null ? -1 : previous.id);
|
stream.writeShort(previous == null ? -1 : previous.id);
|
||||||
stream.writeShort(cblock == null ? -1 : cblock.id);
|
stream.writeShort(cblock == null ? -1 : cblock.id);
|
||||||
@@ -309,6 +310,7 @@ public class BuildBlock extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
progress = stream.readFloat();
|
progress = stream.readFloat();
|
||||||
short pid = stream.readShort();
|
short pid = stream.readShort();
|
||||||
short rid = stream.readShort();
|
short rid = stream.readShort();
|
||||||
|
|||||||
@@ -85,11 +85,13 @@ public class Door extends Wall{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeBoolean(open);
|
stream.writeBoolean(open);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
open = stream.readBoolean();
|
open = stream.readBoolean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ public class ForceProjector extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeBoolean(broken);
|
stream.writeBoolean(broken);
|
||||||
stream.writeFloat(buildup);
|
stream.writeFloat(buildup);
|
||||||
stream.writeFloat(radscl);
|
stream.writeFloat(radscl);
|
||||||
@@ -212,6 +213,7 @@ public class ForceProjector extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
broken = stream.readBoolean();
|
broken = stream.readBoolean();
|
||||||
buildup = stream.readFloat();
|
buildup = stream.readFloat();
|
||||||
radscl = stream.readFloat();
|
radscl = stream.readFloat();
|
||||||
|
|||||||
@@ -149,12 +149,14 @@ public class MendProjector extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeFloat(heat);
|
stream.writeFloat(heat);
|
||||||
stream.writeFloat(phaseHeat);
|
stream.writeFloat(phaseHeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
heat = stream.readFloat();
|
heat = stream.readFloat();
|
||||||
phaseHeat = stream.readFloat();
|
phaseHeat = stream.readFloat();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,12 +148,14 @@ public class OverdriveProjector extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeFloat(heat);
|
stream.writeFloat(heat);
|
||||||
stream.writeFloat(phaseHeat);
|
stream.writeFloat(phaseHeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
heat = stream.readFloat();
|
heat = stream.readFloat();
|
||||||
phaseHeat = stream.readFloat();
|
phaseHeat = stream.readFloat();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ public class ItemTurret extends CooledTurret{
|
|||||||
public class ItemTurretEntity extends TurretEntity{
|
public class ItemTurretEntity extends TurretEntity{
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeByte(ammo.size);
|
stream.writeByte(ammo.size);
|
||||||
for(AmmoEntry entry : ammo){
|
for(AmmoEntry entry : ammo){
|
||||||
ItemEntry i = (ItemEntry)entry;
|
ItemEntry i = (ItemEntry)entry;
|
||||||
@@ -131,6 +132,7 @@ public class ItemTurret extends CooledTurret{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
byte amount = stream.readByte();
|
byte amount = stream.readByte();
|
||||||
for(int i = 0; i < amount; i++){
|
for(int i = 0; i < amount; i++){
|
||||||
Item item = Vars.content.item(stream.readByte());
|
Item item = Vars.content.item(stream.readByte());
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.LiquidBlock;
|
import io.anuke.mindustry.world.blocks.LiquidBlock;
|
||||||
import io.anuke.mindustry.world.modules.LiquidModule;
|
import io.anuke.mindustry.world.modules.LiquidModule;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class Conduit extends LiquidBlock{
|
public class Conduit extends LiquidBlock{
|
||||||
protected final int timerFlow = timers++;
|
protected final int timerFlow = timers++;
|
||||||
|
|
||||||
@@ -119,15 +117,5 @@ public class Conduit extends LiquidBlock{
|
|||||||
|
|
||||||
byte blendbits;
|
byte blendbits;
|
||||||
int blendshadowrot;
|
int blendshadowrot;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(DataOutput stream) throws IOException{
|
|
||||||
stream.writeFloat(smoothLiquid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(DataInput stream) throws IOException{
|
|
||||||
smoothLiquid = stream.readFloat();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -367,6 +367,7 @@ public class Conveyor extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeInt(convey.size);
|
stream.writeInt(convey.size);
|
||||||
|
|
||||||
for(int i = 0; i < convey.size; i++){
|
for(int i = 0; i < convey.size; i++){
|
||||||
@@ -376,6 +377,7 @@ public class Conveyor extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
convey.clear();
|
convey.clear();
|
||||||
int amount = stream.readInt();
|
int amount = stream.readInt();
|
||||||
convey.ensureCapacity(Math.min(amount, 10));
|
convey.ensureCapacity(Math.min(amount, 10));
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ public class ItemBridge extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeInt(link);
|
stream.writeInt(link);
|
||||||
stream.writeFloat(uptime);
|
stream.writeFloat(uptime);
|
||||||
stream.writeByte(incoming.size);
|
stream.writeByte(incoming.size);
|
||||||
@@ -340,6 +341,7 @@ public class ItemBridge extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
link = stream.readInt();
|
link = stream.readInt();
|
||||||
uptime = stream.readFloat();
|
uptime = stream.readFloat();
|
||||||
byte links = stream.readByte();
|
byte links = stream.readByte();
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public class Junction extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
for(Buffer b : buffers){
|
for(Buffer b : buffers){
|
||||||
b.write(stream);
|
b.write(stream);
|
||||||
}
|
}
|
||||||
@@ -94,6 +95,7 @@ public class Junction extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
for(Buffer b : buffers){
|
for(Buffer b : buffers){
|
||||||
b.read(stream);
|
b.read(stream);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import io.anuke.mindustry.graphics.Pal;
|
|||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.meta.BlockStat;
|
|
||||||
import io.anuke.mindustry.world.meta.StatUnit;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@@ -323,6 +321,7 @@ public class MassDriver extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeInt(link);
|
stream.writeInt(link);
|
||||||
stream.writeFloat(rotation);
|
stream.writeFloat(rotation);
|
||||||
stream.writeByte((byte)state.ordinal());
|
stream.writeByte((byte)state.ordinal());
|
||||||
@@ -330,6 +329,7 @@ public class MassDriver extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
link = stream.readInt();
|
link = stream.readInt();
|
||||||
rotation = stream.readFloat();
|
rotation = stream.readFloat();
|
||||||
state = DriverState.values()[stream.readByte()];
|
state = DriverState.values()[stream.readByte()];
|
||||||
|
|||||||
@@ -133,11 +133,13 @@ public class Sorter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeByte(sortItem == null ? -1 : sortItem.id);
|
stream.writeByte(sortItem == null ? -1 : sortItem.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
byte b = stream.readByte();
|
byte b = stream.readByte();
|
||||||
sortItem = b == -1 ? null : content.items().get(b);
|
sortItem = b == -1 ? null : content.items().get(b);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,11 +183,13 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeFloat(heat);
|
stream.writeFloat(heat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
heat = stream.readFloat();
|
heat = stream.readFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,11 +63,13 @@ public class PowerGenerator extends PowerDistributor{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeFloat(productionEfficiency);
|
stream.writeFloat(productionEfficiency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
productionEfficiency = stream.readFloat();
|
productionEfficiency = stream.readFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,11 +118,13 @@ public class Cultivator extends GenericCrafter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeFloat(warmup);
|
stream.writeFloat(warmup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
warmup = stream.readFloat();
|
warmup = stream.readFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,12 +150,14 @@ public class GenericCrafter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeFloat(progress);
|
stream.writeFloat(progress);
|
||||||
stream.writeFloat(warmup);
|
stream.writeFloat(warmup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
progress = stream.readFloat();
|
progress = stream.readFloat();
|
||||||
warmup = stream.readFloat();
|
warmup = stream.readFloat();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import io.anuke.arc.scene.style.TextureRegionDrawable;
|
|||||||
import io.anuke.arc.scene.ui.ButtonGroup;
|
import io.anuke.arc.scene.ui.ButtonGroup;
|
||||||
import io.anuke.arc.scene.ui.ImageButton;
|
import io.anuke.arc.scene.ui.ImageButton;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
import io.anuke.mindustry.content.Liquids;
|
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
import io.anuke.mindustry.entities.type.Player;
|
||||||
import io.anuke.mindustry.entities.type.TileEntity;
|
import io.anuke.mindustry.entities.type.TileEntity;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
@@ -117,11 +116,13 @@ public class LiquidSource extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeByte(source == null ? -1 : source.id);
|
stream.writeByte(source == null ? -1 : source.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
byte id = stream.readByte();
|
byte id = stream.readByte();
|
||||||
source = id == -1 ? null : content.liquid(id);
|
source = id == -1 ? null : content.liquid(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,11 +105,13 @@ public class Unloader extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeByte(sortItem == null ? -1 : sortItem.id);
|
stream.writeByte(sortItem == null ? -1 : sortItem.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
byte id = stream.readByte();
|
byte id = stream.readByte();
|
||||||
sortItem = id == -1 ? null : content.items().get(id);
|
sortItem = id == -1 ? null : content.items().get(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ public class MechPad extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
stream.writeFloat(progress);
|
stream.writeFloat(progress);
|
||||||
stream.writeFloat(time);
|
stream.writeFloat(time);
|
||||||
stream.writeFloat(heat);
|
stream.writeFloat(heat);
|
||||||
@@ -185,6 +186,7 @@ public class MechPad extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream) throws IOException{
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
progress = stream.readFloat();
|
progress = stream.readFloat();
|
||||||
time = stream.readFloat();
|
time = stream.readFloat();
|
||||||
heat = stream.readFloat();
|
heat = stream.readFloat();
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class Generators{
|
|||||||
});
|
});
|
||||||
|
|
||||||
ImagePacker.generate("block-icons", () -> {
|
ImagePacker.generate("block-icons", () -> {
|
||||||
Image colors = new Image(256, 1);
|
Image colors = new Image(content.blocks().size, 1);
|
||||||
Color outlineColor = new Color(0, 0, 0, 0.3f);
|
Color outlineColor = new Color(0, 0, 0, 0.3f);
|
||||||
|
|
||||||
for(Block block : content.blocks()){
|
for(Block block : content.blocks()){
|
||||||
|
|||||||
Reference in New Issue
Block a user