Name refactor / Fixed crash / Power transfer fix
This commit is contained in:
@@ -134,7 +134,7 @@ public class DebugBlocks extends BlockList implements ContentList{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new LiquidSourceEntity();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -172,12 +172,12 @@ public class UI extends SceneModule{
|
||||
Group group = Core.scene.getRoot();
|
||||
|
||||
backfrag.build(group);
|
||||
control.input(0).getFrag().build(Core.scene.getRoot());
|
||||
hudfrag.build(group);
|
||||
menufrag.build(group);
|
||||
chatfrag.container().build(group);
|
||||
listfrag.build(group);
|
||||
loadfrag.build(group);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,6 @@ public abstract class InputHandler extends InputAdapter{
|
||||
public InputHandler(Player player){
|
||||
this.player = player;
|
||||
this.section = "player_" + (player.playerIndex + 1);
|
||||
Timers.run(1f, () -> frag.build(Core.scene.getRoot()));
|
||||
}
|
||||
|
||||
//methods to override
|
||||
@@ -122,6 +121,10 @@ public abstract class InputHandler extends InputAdapter{
|
||||
tile.block().tapped(tile, player);
|
||||
}
|
||||
|
||||
public OverlayFragment getFrag(){
|
||||
return frag;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
|
||||
}
|
||||
|
||||
@@ -159,6 +159,11 @@ public class Block extends BaseBlock {
|
||||
out.add(other);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < tile.entity.power.links.size; i++){
|
||||
Tile link = world.tile(tile.entity.power.links.get(i));
|
||||
if(link != null) out.add(link);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -468,7 +473,7 @@ public class Block extends BaseBlock {
|
||||
return destructible || update;
|
||||
}
|
||||
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new TileEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -416,7 +416,7 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
Block block = block();
|
||||
|
||||
if(block.hasEntity()){
|
||||
entity = block.getEntity().init(this, block.update);
|
||||
entity = block.newEntity().init(this, block.update);
|
||||
entity.cons = new ConsumeModule();
|
||||
if(block.hasItems) entity.items = new InventoryModule();
|
||||
if(block.hasLiquids) entity.liquids = new LiquidModule();
|
||||
|
||||
@@ -171,7 +171,7 @@ public class BuildBlock extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new BuildEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class DeflectorWall extends Wall{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new DeflectorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Door extends Wall{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new DoorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ public class ForceProjector extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new ForceEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public class MendProjector extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new MendEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class MendingWall extends Wall{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new DeflectorEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class OverdriveProjector extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new OverdriveEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ChargeTurret extends PowerTurret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new LaserTurretEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class LaserTurret extends PowerTurret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new LaserTurretEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ public abstract class Turret extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new TurretEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BufferedItemBridge extends ExtendingItemBridge{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new BufferedItemBridgeEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public class Conduit extends LiquidBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new ConduitEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@ public class Conveyor extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new ConveyorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new ItemBridgeEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Junction extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new JunctionEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ public class MassDriver extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new MassDriverEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Router extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new SplitterEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Sorter extends Block implements SelectionTrait{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new SorterEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ public class WarpGate extends PowerBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new TeleporterEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public class FusionReactor extends PowerGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new FusionReactorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class ItemGenerator extends PowerGenerator{
|
||||
protected abstract float getItemEfficiency(Item item);
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new ItemGeneratorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class LiquidGenerator extends PowerGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new ItemGeneratorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new NuclearReactorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class PowerGenerator extends PowerDistributor{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new GeneratorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,12 @@ public class PowerGraph{
|
||||
|
||||
lastFrameUpdated = threads.getFrameID();
|
||||
|
||||
float totalInput = 0f;
|
||||
|
||||
for(Tile producer : producers){
|
||||
totalInput += producer.entity.power.amount;
|
||||
}
|
||||
|
||||
for(Tile producer : producers){
|
||||
float accumulator = producer.entity.power.amount;
|
||||
|
||||
@@ -55,7 +61,7 @@ public class PowerGraph{
|
||||
}
|
||||
|
||||
for(Tile tile : consumers){
|
||||
float used = Math.min(tile.block().powerCapacity - tile.entity.power.amount, finalEach);
|
||||
float used = Math.min(tile.block().powerCapacity - tile.entity.power.amount, finalEach) * accumulator / totalInput;
|
||||
buffer += used;
|
||||
tile.entity.power.amount += used;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package io.anuke.mindustry.world.blocks.power;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
@@ -24,10 +22,6 @@ import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class PowerNode extends PowerBlock{
|
||||
@@ -60,15 +54,14 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
NodeEntity entity = tile.entity();
|
||||
|
||||
if(!entity.links.contains(other.packedPosition())){
|
||||
entity.links.add(other.packedPosition());
|
||||
if(!entity.power.links.contains(other.packedPosition())){
|
||||
entity.power.links.add(other.packedPosition());
|
||||
}
|
||||
|
||||
if(other.getTeamID() == tile.getTeamID() && other.block() instanceof PowerNode){
|
||||
NodeEntity oe = other.entity();
|
||||
if(other.getTeamID() == tile.getTeamID()){
|
||||
|
||||
if(!oe.links.contains(tile.packedPosition())){
|
||||
oe.links.add(tile.packedPosition());
|
||||
if(!other.entity.power.links.contains(tile.packedPosition())){
|
||||
other.entity.power.links.add(tile.packedPosition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,12 +74,10 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
NodeEntity entity = tile.entity();
|
||||
|
||||
entity.links.removeValue(other.packedPosition());
|
||||
entity.power.links.removeValue(other.packedPosition());
|
||||
|
||||
if(other.block() instanceof PowerNode){
|
||||
NodeEntity oe = other.entity();
|
||||
|
||||
oe.links.removeValue(tile.packedPosition());
|
||||
other.entity.power.links.removeValue(tile.packedPosition());
|
||||
}
|
||||
|
||||
//clear all graph data first
|
||||
@@ -138,7 +129,7 @@ public class PowerNode extends PowerBlock{
|
||||
if(linkValid(tile, other)){
|
||||
if(linked(tile, other)){
|
||||
threads.run(() -> Call.unlinkPowerNodes(null, tile, result));
|
||||
}else if(entity.links.size < maxNodes){
|
||||
}else if(entity.power.links.size < maxNodes){
|
||||
threads.run(() -> Call.linkPowerNodes(null, tile, result));
|
||||
}
|
||||
return false;
|
||||
@@ -186,7 +177,7 @@ public class PowerNode extends PowerBlock{
|
||||
Lines.square(link.drawx(), link.drawy(),
|
||||
link.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Timers.time(), 4f, 1f)));
|
||||
|
||||
if((entity.links.size >= maxNodes || (link.block() instanceof PowerNode && ((NodeEntity) link.entity).links.size >= ((PowerNode) link.block()).maxNodes)) && !linked){
|
||||
if((entity.power.links.size >= maxNodes || (link.block() instanceof PowerNode && ((NodeEntity) link.entity).power.links.size >= ((PowerNode) link.block()).maxNodes)) && !linked){
|
||||
Draw.color();
|
||||
Draw.rect("cross-" + link.block().size, link.drawx(), link.drawy());
|
||||
}
|
||||
@@ -215,28 +206,16 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
Draw.color(Palette.powerLaserFrom, Palette.powerLaserTo, 0f * (1f - flashScl) + Mathf.sin(Timers.time(), 1.7f, flashScl));
|
||||
|
||||
for(int i = 0; i < entity.links.size; i++){
|
||||
Tile link = world.tile(entity.links.get(i));
|
||||
for(int i = 0; i < entity.power.links.size; i++){
|
||||
Tile link = world.tile(entity.power.links.get(i));
|
||||
if(linkValid(tile, link)) drawLaser(tile, link);
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<Tile> getPowerConnections(Tile tile, Array<Tile> out){
|
||||
super.getPowerConnections(tile, out);
|
||||
NodeEntity entity = tile.entity();
|
||||
|
||||
for(int i = 0; i < entity.links.size; i++){
|
||||
Tile link = world.tile(entity.links.get(i));
|
||||
if(linkValid(tile, link)) out.add(link);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
protected boolean linked(Tile tile, Tile other){
|
||||
return tile.<NodeEntity>entity().links.contains(other.packedPosition());
|
||||
return tile.<NodeEntity>entity().power.links.contains(other.packedPosition());
|
||||
}
|
||||
|
||||
protected boolean linkValid(Tile tile, Tile link){
|
||||
@@ -252,7 +231,7 @@ public class PowerNode extends PowerBlock{
|
||||
return Vector2.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy()) <= Math.max(laserRange * tilesize,
|
||||
((PowerNode) link.block()).laserRange * tilesize) - tilesize / 2f
|
||||
+ (link.block().size - 1) * tilesize / 2f + (tile.block().size - 1) * tilesize / 2f &&
|
||||
(!checkMaxNodes || (oe.links.size < ((PowerNode) link.block()).maxNodes || oe.links.contains(tile.packedPosition())));
|
||||
(!checkMaxNodes || (oe.power.links.size < ((PowerNode) link.block()).maxNodes || oe.power.links.contains(tile.packedPosition())));
|
||||
}else{
|
||||
return Vector2.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy())
|
||||
<= laserRange * tilesize - tilesize / 2f + (link.block().size - 1) * tilesize;
|
||||
@@ -274,28 +253,12 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new NodeEntity();
|
||||
}
|
||||
|
||||
public static class NodeEntity extends TileEntity{
|
||||
public IntArray links = new IntArray();
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException{
|
||||
stream.writeShort(links.size);
|
||||
for(int i = 0; i < links.size; i++){
|
||||
stream.writeInt(links.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException{
|
||||
short amount = stream.readShort();
|
||||
for(int i = 0; i < amount; i++){
|
||||
links.add(stream.readInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Cultivator extends Drill{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new CultivatorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new DrillEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Fracker extends SolidPump{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new FrackerEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ public class GenericCrafter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new GenericCrafterEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public class Incinerator extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new IncineratorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class LiquidMixer extends LiquidBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new LiquidMixerEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class PowerCrafter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new GenericCrafterEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public class PowerSmelter extends PowerBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new PowerSmelterEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public class Separator extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new GenericCrafterEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class Smelter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new SmelterEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public class SolidPump extends Pump{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new SolidPumpEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new CoreEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SortedUnloader extends Unloader implements SelectionTrait{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new SortedUnloaderEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class CommandCenter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new CommandCenterEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ public class MechPad extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new MechFactoryEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ public class Reconstructor extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new ReconstructorEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public class RepairPoint extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new RepairPointEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ public class UnitFactory extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
public TileEntity newEntity(){
|
||||
return new UnitFactoryEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.world.modules;
|
||||
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import io.anuke.mindustry.world.blocks.power.PowerGraph;
|
||||
|
||||
import java.io.DataInput;
|
||||
@@ -11,6 +12,7 @@ public class PowerModule extends BlockModule{
|
||||
public float capacity = 10f;
|
||||
public float voltage = 0.0001f;
|
||||
public PowerGraph graph = new PowerGraph();
|
||||
public IntArray links = new IntArray();
|
||||
|
||||
public boolean acceptsPower(){
|
||||
return amount + 0.001f <= capacity;
|
||||
@@ -30,6 +32,11 @@ public class PowerModule extends BlockModule{
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
stream.writeFloat(amount);
|
||||
|
||||
stream.writeShort(links.size);
|
||||
for(int i = 0; i < links.size; i++){
|
||||
stream.writeInt(links.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,5 +45,10 @@ public class PowerModule extends BlockModule{
|
||||
if(Float.isNaN(amount)){
|
||||
amount = 0f;
|
||||
}
|
||||
|
||||
short amount = stream.readShort();
|
||||
for(int i = 0; i < amount; i++){
|
||||
links.add(stream.readInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user