Barely functional IO

This commit is contained in:
Anuken
2020-02-13 19:26:36 -05:00
parent ad248e2e20
commit e3621f44da
68 changed files with 323 additions and 497 deletions

View File

@@ -370,7 +370,7 @@ public class Block extends BlockStorage{
/** Call when some content is produced. This unlocks the content if it is applicable. */
public void useContent(Tile tile, UnlockableContent content){
//only unlocks content in zones
if(!headless && tile.team() == player.team() && world.isZone()){
if(!headless && tile.team() == player.team() && world.isCampaign()){
logic.handleContent(content);
}
}

View File

@@ -365,8 +365,8 @@ public class BuildBlock extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
progress = stream.readFloat();
short pid = stream.readShort();
short rid = stream.readShort();

View File

@@ -24,7 +24,7 @@ public class ItemSelection{
int i = 0;
for(T item : items){
if(!data.isUnlocked(item) && world.isZone()) continue;
if(!data.isUnlocked(item) && world.isCampaign()) continue;
ImageButton button = cont.addImageButton(Tex.whiteui, Styles.clearToggleTransi, 24, () -> control.input.frag.config.hideConfig()).group(group).get();
button.changed(() -> consumer.get(button.isChecked() ? item : null));

View File

@@ -9,7 +9,6 @@ import arc.math.geom.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.gen.*;
import mindustry.world.*;
import java.io.*;
@@ -99,8 +98,8 @@ public class Door extends Wall{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
open = stream.readBoolean();
}
}

View File

@@ -181,8 +181,8 @@ public class ForceProjector extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
broken = stream.readBoolean();
buildup = stream.readFloat();
radscl = stream.readFloat();

View File

@@ -133,8 +133,8 @@ public class MendProjector extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
heat = stream.readFloat();
phaseHeat = stream.readFloat();
}

View File

@@ -131,8 +131,8 @@ public class OverdriveProjector extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
heat = stream.readFloat();
phaseHeat = stream.readFloat();
}

View File

@@ -46,7 +46,7 @@ public class ItemTurret extends CooledTurret{
@Override
public void build(Tile tile, Table table){
MultiReqImage image = new MultiReqImage();
content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium)),
content.items().each(i -> filter.get(i) && (!world.isCampaign() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium)),
() -> tile.entity != null && !((ItemTurretEntity)tile.entity).ammo.isEmpty() && ((ItemEntry)tile.<ItemTurretEntity>ent().ammo.peek()).item == item)));
table.add(image).size(8 * 4);
@@ -162,8 +162,8 @@ public class ItemTurret extends CooledTurret{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
byte amount = stream.readByte();
for(int i = 0; i < amount; i++){
Item item = Vars.content.item(stream.readByte());

View File

@@ -327,8 +327,8 @@ public abstract class Turret extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
reload = stream.readFloat();
rotation = stream.readFloat();
}

View File

@@ -47,8 +47,8 @@ public class BufferedItemBridge extends ExtendingItemBridge{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
buffer.read(stream);
}
}

View File

@@ -361,8 +361,8 @@ public class Conveyor extends Block implements Autotiler{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
int amount = stream.readInt();
len = Math.min(amount, capacity);

View File

@@ -389,8 +389,8 @@ public class ItemBridge extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
link = stream.readInt();
uptime = stream.readFloat();
byte links = stream.readByte();

View File

@@ -95,8 +95,8 @@ public class Junction extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
buffer.read(stream);
}
}

View File

@@ -340,8 +340,8 @@ public class MassDriver extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
link = stream.readInt();
rotation = stream.readFloat();
state = DriverState.values()[stream.readByte()];

View File

@@ -7,6 +7,8 @@ import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.meta.*;
import java.io.*;
public class OverflowGate extends Block{
public float speed = 1f;
public boolean invert = false;
@@ -120,5 +122,13 @@ public class OverflowGate extends Block{
Item lastItem;
Tile lastInput;
float time;
@Override
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
if(revision == 1){
new DirectionalItemBuffer(25, 50f).read(stream);
}
}
}
}

View File

@@ -162,9 +162,13 @@ public class Sorter extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
sortItem = content.item(stream.readShort());
if(revision == 1){
new DirectionalItemBuffer(20, 45f).read(stream);
}
}
}
}

View File

@@ -12,7 +12,6 @@ import arc.util.*;
import arc.util.pooling.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.gen.*;
import mindustry.net.*;
import mindustry.ui.*;
import mindustry.ui.dialogs.*;
@@ -157,8 +156,8 @@ public class MessageBlock extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
message = stream.readUTF();
}
}

View File

@@ -171,8 +171,8 @@ public class ImpactReactor extends PowerGenerator{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
warmup = stream.readFloat();
}
}

View File

@@ -5,7 +5,6 @@ import arc.graphics.g2d.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.gen.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.world.*;
@@ -87,8 +86,8 @@ public class LightBlock extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
color = stream.readInt();
}
}

View File

@@ -192,8 +192,8 @@ public class NuclearReactor extends PowerGenerator{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
heat = stream.readFloat();
}
}

View File

@@ -65,8 +65,8 @@ public class PowerGenerator extends PowerDistributor{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
productionEfficiency = stream.readFloat();
}
}

View File

@@ -126,8 +126,8 @@ public class Cultivator extends GenericCrafter{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
warmup = stream.readFloat();
}
}

View File

@@ -158,8 +158,8 @@ public class GenericCrafter extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
progress = stream.readFloat();
warmup = stream.readFloat();
}

View File

@@ -107,8 +107,8 @@ public class ItemSource extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
outputItem = content.item(stream.readShort());
}
}

View File

@@ -103,8 +103,8 @@ public class LiquidSource extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
byte id = stream.readByte();
source = id == -1 ? null : content.liquid(id);
}

View File

@@ -73,7 +73,7 @@ public class LaunchPad extends StorageBlock{
public void update(Tile tile){
Tilec entity = tile.entity;
if(world.isZone() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale())){
if(world.isCampaign() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale())){
for(Item item : Vars.content.items()){
Events.fire(Trigger.itemLaunch);
Fx.padlaunch.at(tile);

View File

@@ -144,8 +144,8 @@ public class Unloader extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
byte id = stream.readByte();
sortItem = id == -1 ? null : content.items().get(id);
}

View File

@@ -132,8 +132,8 @@ public class CommandCenter extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
command = UnitCommand.all[stream.readByte()];
}
}

View File

@@ -148,8 +148,8 @@ public class MechPad extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
progress = stream.readFloat();
time = stream.readFloat();
heat = stream.readFloat();

View File

@@ -196,8 +196,8 @@ public class UnitFactory extends Block{
}
@Override
public void read(DataInput stream) throws IOException{
super.read(stream);
public void read(DataInput stream, byte revision) throws IOException{
super.read(stream, revision);
buildTime = stream.readFloat();
spawned = stream.readInt();
}

View File

@@ -35,7 +35,7 @@ public class ConsumeItemFilter extends Consume{
@Override
public void build(Tile tile, Table table){
MultiReqImage image = new MultiReqImage();
content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(item))));
content.items().each(i -> filter.get(i) && (!world.isCampaign() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(item))));
table.add(image).size(8 * 4);
}

View File

@@ -8,7 +8,7 @@ public enum BuildVisibility{
shown(() -> true),
debugOnly(() -> false),
sandboxOnly(() -> Vars.state.rules.infiniteResources),
campaignOnly(() -> Vars.world.isZone()),
campaignOnly(() -> Vars.world.isCampaign()),
lightingOnly(() -> Vars.state.rules.lighting);
private final Boolp visible;