mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-11-13 07:15:28 +03:00
everything is borked
This commit is contained in:
parent
eb4f6f2e9f
commit
35b158dba7
@ -48,14 +48,10 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
||||
|
||||
TypeName jsonType = ClassName.bestGuess("io.anuke.arc.util.serialization.Json");
|
||||
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(ubJsonReaderType, "bjsonReader", Modifier.STATIC, Modifier.PRIVATE);
|
||||
classBuilder.addStaticBlock(CodeBlock.builder()
|
||||
.addStatement("bjson = new " + jsonType + "()")
|
||||
.addStatement("bjsonReader = new " + ubJsonReaderType + "()")
|
||||
.build());
|
||||
|
||||
for(TypeElement elem : elements){
|
||||
|
@ -30,7 +30,7 @@ public class Blocks implements ContentList{
|
||||
public static Block
|
||||
|
||||
//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,
|
||||
iceSnow, sandWater, darksandWater, duneRocks, sandRocks, moss, sporeMoss, shale, shaleRocks, shaleBoulder, grass, salt,
|
||||
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");
|
||||
|
||||
|
@ -90,17 +90,12 @@ public class ContentLoader{
|
||||
for(Array<Content> arr : contentMap){
|
||||
for(int i = 0; i < arr.size; i++){
|
||||
int id = arr.get(i).id;
|
||||
if(id < 0) id += 256;
|
||||
if(id != i){
|
||||
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){
|
||||
Log.info("--- CONTENT INFO ---");
|
||||
for(int k = 0; k < contentMap.length; k++){
|
||||
@ -129,7 +124,7 @@ public class ContentLoader{
|
||||
/** Loads block colors. */
|
||||
public void loadColors(){
|
||||
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){
|
||||
int color = pixmap.getPixel(i, 0);
|
||||
|
||||
@ -170,8 +165,6 @@ public class ContentLoader{
|
||||
}
|
||||
|
||||
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[type.ordinal()].length <= id || temporaryMapper[type.ordinal()][id] == null){
|
||||
@ -243,10 +236,4 @@ public class ContentLoader{
|
||||
TypeTrait.registerType(Bullet.class, Bullet::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];
|
||||
}
|
||||
|
||||
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){
|
||||
return tiles[x][y];
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setOverlayID(byte ore){
|
||||
byte previous = getOverlayID();
|
||||
byte previous = overlayID();
|
||||
if(previous == ore) return;
|
||||
super.setOverlayID(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.math.geom.Point2;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Interval;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.impl.BaseEntity;
|
||||
@ -116,10 +115,28 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
|
||||
@CallSuper
|
||||
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
|
||||
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){
|
||||
|
@ -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}. */
|
||||
public abstract class Content{
|
||||
public final byte id;
|
||||
public final short id;
|
||||
|
||||
public Content(){
|
||||
this.id = (byte)Vars.content.getBy(getContentType()).size;
|
||||
this.id = (short)Vars.content.getBy(getContentType()).size;
|
||||
Vars.content.handleContent(this);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.annotations.Annotations.Serialize;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
|
||||
/**
|
||||
* Defines current rules on how the game should function.
|
||||
@ -47,10 +48,10 @@ public class Rules{
|
||||
public float bossWaveMultiplier = 3f;
|
||||
/** How many times longer a launch wave takes. */
|
||||
public float launchWaveMultiplier = 2f;
|
||||
/** Zone ID, -1 for invalid zone. */
|
||||
public byte zone = -1;
|
||||
/** Zone for saves that have them.*/
|
||||
public Zone 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. */
|
||||
public boolean limitedRespawns = false;
|
||||
/** 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++){
|
||||
Tile tile = tiles[i % width][i / width];
|
||||
stream.writeByte(tile.getFloorID());
|
||||
stream.writeByte(tile.getOverlayID());
|
||||
stream.writeByte(tile.overlayID());
|
||||
int consecutives = 0;
|
||||
|
||||
for(int j = i + 1; j < width * height && consecutives < 255; j++){
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,7 @@ package io.anuke.mindustry.io;
|
||||
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.collection.ObjectMap.Entry;
|
||||
import io.anuke.arc.util.Pack;
|
||||
import io.anuke.arc.util.io.ReusableByteOutStream;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.entities.Entities;
|
||||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
@ -111,17 +109,17 @@ public abstract class SaveFileVersion{
|
||||
stream.writeShort(world.width());
|
||||
stream.writeShort(world.height());
|
||||
|
||||
//floor first
|
||||
//floor + overlay
|
||||
for(int i = 0; i < world.width() * world.height(); i++){
|
||||
Tile tile = world.tile(i % world.width(), i / world.width());
|
||||
stream.writeByte(tile.getFloorID());
|
||||
stream.writeByte(tile.getOverlayID());
|
||||
stream.writeShort(tile.floorID());
|
||||
stream.writeShort(tile.overlayID());
|
||||
int consecutives = 0;
|
||||
|
||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
||||
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;
|
||||
}
|
||||
|
||||
@ -135,19 +133,9 @@ public abstract class SaveFileVersion{
|
||||
//blocks
|
||||
for(int i = 0; i < world.width() * world.height(); i++){
|
||||
Tile tile = world.tile(i % world.width(), i / world.width());
|
||||
stream.writeByte(tile.getBlockID());
|
||||
|
||||
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);
|
||||
stream.writeShort(tile.blockID());
|
||||
|
||||
if(tile.entity != null){
|
||||
tile.entity.write(stream);
|
||||
}else{
|
||||
//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++){
|
||||
Tile nextTile = world.tile(j % world.width(), j / world.width());
|
||||
|
||||
if(nextTile.block() != tile.block()){
|
||||
if(nextTile.blockID() != tile.blockID()){
|
||||
break;
|
||||
}
|
||||
|
||||
@ -180,19 +168,15 @@ public abstract class SaveFileVersion{
|
||||
//read floor and create tiles first
|
||||
for(int i = 0; i < width * height; i++){
|
||||
int x = i % width, y = i / width;
|
||||
byte floorid = stream.readByte();
|
||||
byte oreid = stream.readByte();
|
||||
short floorid = stream.readShort();
|
||||
short oreid = stream.readShort();
|
||||
int consecutives = stream.readUnsignedByte();
|
||||
Block ore = content.block(oreid);
|
||||
|
||||
tiles[x][y] = new Tile(x, y, floorid, (byte)0);
|
||||
tiles[x][y].setOverlay(ore);
|
||||
tiles[x][y] = new Tile(false, x, y, floorid, oreid);
|
||||
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
Tile newTile = new Tile(newx, newy, floorid, (byte)0);
|
||||
newTile.setOverlay(ore);
|
||||
tiles[newx][newy] = newTile;
|
||||
tiles[newx][newy] = new Tile(false, newx, newy, floorid, oreid);
|
||||
}
|
||||
|
||||
i += consecutives;
|
||||
@ -205,24 +189,7 @@ public abstract class SaveFileVersion{
|
||||
Tile tile = tiles[x][y];
|
||||
tile.setBlock(block);
|
||||
|
||||
if(block == Blocks.part){
|
||||
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);
|
||||
|
||||
if(tile.entity != null){
|
||||
tile.entity.read(stream);
|
||||
}else{
|
||||
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){
|
||||
return false;
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package io.anuke.mindustry.world;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.Pack;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
@ -24,14 +22,12 @@ public class Tile implements Position, TargetTrait{
|
||||
public short x, y;
|
||||
protected Block block;
|
||||
protected Floor floor;
|
||||
/** Rotation, 0-3. Also used to store offload location and link, in which case it can be any number.
|
||||
* When saved in non-link form, this data is truncated to 4 bits = max 16.*/
|
||||
/** Rotation, 0-3. Also used to store offload location, in which case it can be any number.*/
|
||||
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.
|
||||
* Complications may arise from using signed bytes as well. Be careful.*/
|
||||
/** Team ordinal. */
|
||||
private byte team;
|
||||
/** Ore that is on top of this (floor) block. */
|
||||
private byte overlay = 0;
|
||||
private short overlay = 0;
|
||||
|
||||
public Tile(int x, int y){
|
||||
this.x = (short)x;
|
||||
@ -39,20 +35,11 @@ public class Tile implements Position, TargetTrait{
|
||||
block = floor = (Floor)Blocks.air;
|
||||
}
|
||||
|
||||
public Tile(int x, int y, byte floor, byte block){
|
||||
this(x, y);
|
||||
public Tile(boolean __removeThisLater, int x, int y, short floor, short overlay){
|
||||
this.x = (short)x;
|
||||
this.y = (short)y;
|
||||
this.floor = (Floor)content.block(floor);
|
||||
this.block = content.block(block);
|
||||
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;
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
/** Returns this tile's position as a {@link Pos}. */
|
||||
@ -60,14 +47,6 @@ public class Tile implements Position, TargetTrait{
|
||||
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. */
|
||||
public byte relativeTo(int cx, int cy){
|
||||
if(x == cx && y == cy - 1) return 1;
|
||||
@ -206,11 +185,19 @@ public class Tile implements Position, TargetTrait{
|
||||
this.rotation = dump;
|
||||
}
|
||||
|
||||
public byte getOverlayID(){
|
||||
public short overlayID(){
|
||||
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;
|
||||
}
|
||||
|
||||
@ -255,21 +242,7 @@ public class Tile implements Position, TargetTrait{
|
||||
}
|
||||
|
||||
public boolean isLinked(){
|
||||
return block == Blocks.part;
|
||||
}
|
||||
|
||||
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));
|
||||
return block instanceof BlockPart;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -315,7 +288,7 @@ public class Tile implements Position, TargetTrait{
|
||||
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(){
|
||||
if(!isLinked()){
|
||||
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(){
|
||||
Tile link = getLinked();
|
||||
return link == null ? this : link;
|
||||
}
|
||||
}*/
|
||||
|
||||
public Rectangle getHitbox(Rectangle rect){
|
||||
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) + "]" : "");
|
||||
}
|
||||
|
||||
//TODO remove these!
|
||||
|
||||
/**Returns the relative X from a link byte.*/
|
||||
public static int linkX(byte value){
|
||||
return -((byte)((value >> 4) & (byte)0x0F) - 8);
|
||||
|
@ -1,7 +1,5 @@
|
||||
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.Tile;
|
||||
|
||||
@ -11,18 +9,35 @@ import io.anuke.mindustry.world.Tile;
|
||||
* They are made to share all properties from the linked tile/block.
|
||||
*/
|
||||
public class BlockPart extends Block{
|
||||
public final static int maxSize = 9;
|
||||
private final static BlockPart[][] parts = new BlockPart[maxSize][maxSize];
|
||||
|
||||
public BlockPart(){
|
||||
super("part");
|
||||
private final int dx, dy;
|
||||
|
||||
public BlockPart(int dx, int dy){
|
||||
super("part_" + dx + "_" + dy);
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
solid = false;
|
||||
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
|
||||
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
|
||||
public boolean synthetic(){
|
||||
return true;
|
||||
@ -33,43 +48,4 @@ public class BlockPart extends Block{
|
||||
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
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(progress);
|
||||
stream.writeShort(previous == null ? -1 : previous.id);
|
||||
stream.writeShort(cblock == null ? -1 : cblock.id);
|
||||
@ -309,6 +310,7 @@ public class BuildBlock extends Block{
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
progress = stream.readFloat();
|
||||
short pid = stream.readShort();
|
||||
short rid = stream.readShort();
|
||||
|
@ -85,11 +85,13 @@ public class Door extends Wall{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeBoolean(open);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
open = stream.readBoolean();
|
||||
}
|
||||
}
|
||||
|
@ -203,6 +203,7 @@ public class ForceProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeBoolean(broken);
|
||||
stream.writeFloat(buildup);
|
||||
stream.writeFloat(radscl);
|
||||
@ -212,6 +213,7 @@ public class ForceProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
broken = stream.readBoolean();
|
||||
buildup = stream.readFloat();
|
||||
radscl = stream.readFloat();
|
||||
|
@ -149,12 +149,14 @@ public class MendProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(heat);
|
||||
stream.writeFloat(phaseHeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
heat = stream.readFloat();
|
||||
phaseHeat = stream.readFloat();
|
||||
}
|
||||
|
@ -148,12 +148,14 @@ public class OverdriveProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(heat);
|
||||
stream.writeFloat(phaseHeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
heat = stream.readFloat();
|
||||
phaseHeat = stream.readFloat();
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ public class ItemTurret extends CooledTurret{
|
||||
public class ItemTurretEntity extends TurretEntity{
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeByte(ammo.size);
|
||||
for(AmmoEntry entry : ammo){
|
||||
ItemEntry i = (ItemEntry)entry;
|
||||
@ -131,6 +132,7 @@ public class ItemTurret extends CooledTurret{
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
byte amount = stream.readByte();
|
||||
for(int i = 0; i < amount; i++){
|
||||
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.modules.LiquidModule;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class Conduit extends LiquidBlock{
|
||||
protected final int timerFlow = timers++;
|
||||
|
||||
@ -119,15 +117,5 @@ public class Conduit extends LiquidBlock{
|
||||
|
||||
byte blendbits;
|
||||
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
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeInt(convey.size);
|
||||
|
||||
for(int i = 0; i < convey.size; i++){
|
||||
@ -376,6 +377,7 @@ public class Conveyor extends Block{
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
convey.clear();
|
||||
int amount = stream.readInt();
|
||||
convey.ensureCapacity(Math.min(amount, 10));
|
||||
|
@ -327,6 +327,7 @@ public class ItemBridge extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeInt(link);
|
||||
stream.writeFloat(uptime);
|
||||
stream.writeByte(incoming.size);
|
||||
@ -340,6 +341,7 @@ public class ItemBridge extends Block{
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
link = stream.readInt();
|
||||
uptime = stream.readFloat();
|
||||
byte links = stream.readByte();
|
||||
|
@ -87,6 +87,7 @@ public class Junction extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
for(Buffer b : buffers){
|
||||
b.write(stream);
|
||||
}
|
||||
@ -94,6 +95,7 @@ public class Junction extends Block{
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
for(Buffer b : buffers){
|
||||
b.read(stream);
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -323,6 +321,7 @@ public class MassDriver extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeInt(link);
|
||||
stream.writeFloat(rotation);
|
||||
stream.writeByte((byte)state.ordinal());
|
||||
@ -330,6 +329,7 @@ public class MassDriver extends Block{
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
link = stream.readInt();
|
||||
rotation = stream.readFloat();
|
||||
state = DriverState.values()[stream.readByte()];
|
||||
|
@ -133,11 +133,13 @@ public class Sorter extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeByte(sortItem == null ? -1 : sortItem.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
byte b = stream.readByte();
|
||||
sortItem = b == -1 ? null : content.items().get(b);
|
||||
}
|
||||
|
@ -183,11 +183,13 @@ public class NuclearReactor extends PowerGenerator{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(heat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
heat = stream.readFloat();
|
||||
}
|
||||
}
|
||||
|
@ -63,11 +63,13 @@ public class PowerGenerator extends PowerDistributor{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(productionEfficiency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
productionEfficiency = stream.readFloat();
|
||||
}
|
||||
}
|
||||
|
@ -118,11 +118,13 @@ public class Cultivator extends GenericCrafter{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(warmup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
warmup = stream.readFloat();
|
||||
}
|
||||
}
|
||||
|
@ -150,12 +150,14 @@ public class GenericCrafter extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(progress);
|
||||
stream.writeFloat(warmup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
progress = 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.ImageButton;
|
||||
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.TileEntity;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
@ -117,11 +116,13 @@ public class LiquidSource extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeByte(source == null ? -1 : source.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
byte id = stream.readByte();
|
||||
source = id == -1 ? null : content.liquid(id);
|
||||
}
|
||||
|
@ -105,11 +105,13 @@ public class Unloader extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeByte(sortItem == null ? -1 : sortItem.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
byte id = stream.readByte();
|
||||
sortItem = id == -1 ? null : content.items().get(id);
|
||||
}
|
||||
|
@ -178,6 +178,7 @@ public class MechPad extends Block{
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(progress);
|
||||
stream.writeFloat(time);
|
||||
stream.writeFloat(heat);
|
||||
@ -185,6 +186,7 @@ public class MechPad extends Block{
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
progress = stream.readFloat();
|
||||
time = stream.readFloat();
|
||||
heat = stream.readFloat();
|
||||
|
@ -70,7 +70,7 @@ public class Generators{
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
for(Block block : content.blocks()){
|
||||
|
Loading…
Reference in New Issue
Block a user