Bugfixes
This commit is contained in:
@@ -258,7 +258,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
ui.planet.hide();
|
ui.planet.hide();
|
||||||
SaveSlot slot = sector.save;
|
SaveSlot slot = sector.save;
|
||||||
//TODO comment for new sector states
|
//TODO comment for new sector states
|
||||||
slot = null;
|
//slot = null;
|
||||||
if(slot != null){
|
if(slot != null){
|
||||||
try{
|
try{
|
||||||
net.reset();
|
net.reset();
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ public class EditorTile extends Tile{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void changed(Team team){
|
protected void changeEntity(Team team){
|
||||||
if(state.isGame()){
|
if(state.isGame()){
|
||||||
super.changed(team);
|
super.changeEntity(team);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
|||||||
private CachedTile ctile = new CachedTile(){
|
private CachedTile ctile = new CachedTile(){
|
||||||
//nothing.
|
//nothing.
|
||||||
@Override
|
@Override
|
||||||
protected void changed(Team team){
|
protected void changeEntity(Team team){
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -929,16 +929,21 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
|
|
||||||
public void removeFromProximity(){
|
public void removeFromProximity(){
|
||||||
onProximityRemoved();
|
onProximityRemoved();
|
||||||
|
tmpTiles.clear();
|
||||||
|
|
||||||
Point2[] nearby = Edges.getEdges(block.size);
|
Point2[] nearby = Edges.getEdges(block.size);
|
||||||
for(Point2 point : nearby){
|
for(Point2 point : nearby){
|
||||||
Tilec other = world.ent(tile.x + point.x, tile.y + point.y);
|
Tilec other = world.ent(tile.x + point.x, tile.y + point.y);
|
||||||
//remove this tile from all nearby tile's proximities
|
//remove this tile from all nearby tile's proximities
|
||||||
if(other != null){
|
if(other != null){
|
||||||
other.onProximityUpdate();
|
tmpTiles.add(other);
|
||||||
other.proximity().remove(this, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(Tilec other : tmpTiles){
|
||||||
|
other.proximity().remove(this, true);
|
||||||
|
other.onProximityUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateProximity(){
|
public void updateProximity(){
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class CachedTile extends Tile{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void changed(Team team){
|
protected void changeEntity(Team team){
|
||||||
entity = null;
|
entity = null;
|
||||||
|
|
||||||
Block block = block();
|
Block block = block();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.Arrays;
|
|||||||
import static mindustry.Vars.world;
|
import static mindustry.Vars.world;
|
||||||
|
|
||||||
public class Edges{
|
public class Edges{
|
||||||
private static final int maxSize = 11;
|
private static final int maxSize = 14;
|
||||||
private static final int maxRadius = 12;
|
private static final int maxRadius = 12;
|
||||||
private static Point2[][] edges = new Point2[maxSize][0];
|
private static Point2[][] edges = new Point2[maxSize][0];
|
||||||
private static Point2[][] edgeInside = new Point2[maxSize][0];
|
private static Point2[][] edgeInside = new Point2[maxSize][0];
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import mindustry.world.modules.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class Tile implements Position, QuadTreeObject{
|
public class Tile implements Position, QuadTreeObject{
|
||||||
|
static final ObjectSet<Tilec> tileSet = new ObjectSet<>();
|
||||||
|
|
||||||
/** Tile traversal cost. */
|
/** Tile traversal cost. */
|
||||||
public byte cost = 1;
|
public byte cost = 1;
|
||||||
/** Tile entity, usually null. */
|
/** Tile entity, usually null. */
|
||||||
@@ -27,6 +29,7 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
protected @NonNull Floor overlay;
|
protected @NonNull Floor overlay;
|
||||||
/** Rotation, 0-3. Also used to store offload location, 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.*/
|
||||||
protected byte rotation;
|
protected byte rotation;
|
||||||
|
protected boolean changing = false;
|
||||||
|
|
||||||
public Tile(int x, int y){
|
public Tile(int x, int y){
|
||||||
this.x = (short)x;
|
this.x = (short)x;
|
||||||
@@ -42,7 +45,8 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
this.block = wall;
|
this.block = wall;
|
||||||
|
|
||||||
//update entity and create it if needed
|
//update entity and create it if needed
|
||||||
changed(Team.derelict);
|
changeEntity(Team.derelict);
|
||||||
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile(int x, int y, int floor, int overlay, int wall){
|
public Tile(int x, int y, int floor, int overlay, int wall){
|
||||||
@@ -161,10 +165,12 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(@NonNull Block type, Team team, int rotation){
|
public void setBlock(@NonNull Block type, Team team, int rotation){
|
||||||
preChanged();
|
changing = true;
|
||||||
|
|
||||||
this.block = type;
|
this.block = type;
|
||||||
this.rotation = rotation == 0 ? 0 : (byte)Mathf.mod(rotation, 4);
|
this.rotation = rotation == 0 ? 0 : (byte)Mathf.mod(rotation, 4);
|
||||||
changed(team);
|
preChanged();
|
||||||
|
changeEntity(team);
|
||||||
|
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
entity.team(team);
|
entity.team(team);
|
||||||
@@ -205,6 +211,9 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changed();
|
||||||
|
changing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(@NonNull Block type, Team team){
|
public void setBlock(@NonNull Block type, Team team){
|
||||||
@@ -501,12 +510,12 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
//reset entity and block *manually* - thus, preChanged() will not be called anywhere else, for multiblocks
|
//reset entity and block *manually* - thus, preChanged() will not be called anywhere else, for multiblocks
|
||||||
if(other != this){ //do not remove own entity so it can be processed in changed()
|
if(other != this){ //do not remove own entity so it can be processed in changed()
|
||||||
other.entity = null;
|
other.entity = null;
|
||||||
}
|
other.block = Blocks.air;
|
||||||
other.block = Blocks.air;
|
|
||||||
|
|
||||||
//manually call changed event
|
//manually call changed event
|
||||||
other.updateOcclusion();
|
other.updateOcclusion();
|
||||||
world.notifyChanged(other);
|
world.notifyChanged(other);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -520,13 +529,27 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void changed(Team team){
|
protected void changeEntity(Team team){
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
|
int size = entity.block().size;
|
||||||
entity.remove();
|
entity.remove();
|
||||||
entity = null;
|
entity = null;
|
||||||
}
|
|
||||||
|
|
||||||
Block block = block();
|
//update edge entities
|
||||||
|
tileSet.clear();
|
||||||
|
|
||||||
|
for(Point2 edge : Edges.getEdges(size)){
|
||||||
|
Tilec other = world.ent(x + edge.x, y + edge.y);
|
||||||
|
if(other != null){
|
||||||
|
tileSet.add(other);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//update proximity, since multiblock was just removed
|
||||||
|
for(Tilec t : tileSet){
|
||||||
|
t.updateProximity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(block.hasEntity()){
|
if(block.hasEntity()){
|
||||||
entity = block.newEntity().init(this, team, block.update);
|
entity = block.newEntity().init(this, team, block.update);
|
||||||
@@ -537,16 +560,20 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
entity.power(new PowerModule());
|
entity.power(new PowerModule());
|
||||||
entity.power().graph.add(entity);
|
entity.power().graph.add(entity);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!world.isGenerating()){
|
protected void changed(){
|
||||||
|
if(!world.isGenerating()){
|
||||||
|
if(entity != null){
|
||||||
entity.updateProximity();
|
entity.updateProximity();
|
||||||
}
|
}else{
|
||||||
}else if(!world.isGenerating()){
|
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
|
||||||
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
|
for(Point2 p : Geometry.d4){
|
||||||
for(Point2 p : Geometry.d4){
|
Tilec tile = world.ent(x + p.x, y + p.y);
|
||||||
Tilec tile = world.ent(x + p.x, y + p.y);
|
if(tile != null && !tile.tile().changing){
|
||||||
if(tile != null){
|
tile.onProximityUpdate();
|
||||||
tile.onProximityUpdate();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,15 +68,17 @@ public class MassConveyor extends Block{
|
|||||||
public void onProximityUpdate(){
|
public void onProximityUpdate(){
|
||||||
super.onProximityUpdate();
|
super.onProximityUpdate();
|
||||||
|
|
||||||
Tilec accept = nearby(Geometry.d4[rotation()].x * size, Geometry.d4[rotation()].y * size);
|
Tilec accept = nearby(Geometry.d4(rotation()).x * size, Geometry.d4(rotation()).y * size);
|
||||||
//next block must be aligned and of the same size
|
//next block must be aligned and of the same size
|
||||||
if(accept != null && accept.block().size == size &&
|
if(accept != null && accept.block().size == size &&
|
||||||
tileX() + Geometry.d4[rotation()].x * size == accept.tileX() && tileY() + Geometry.d4[rotation()].y * size == accept.tileY()){
|
tileX() + Geometry.d4(rotation()).x * size == accept.tileX() && tileY() + Geometry.d4(rotation()).y * size == accept.tileY()){
|
||||||
next = accept;
|
next = accept;
|
||||||
|
}else{
|
||||||
|
next = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ntrns = 1 + size/2;
|
int ntrns = 1 + size/2;
|
||||||
Tile next = tile.getNearby(Geometry.d4[rotation()].x * ntrns, Geometry.d4[rotation()].y * ntrns);
|
Tile next = tile.getNearby(Geometry.d4(rotation()).x * ntrns, Geometry.d4(rotation()).y * ntrns);
|
||||||
blocked = (next != null && next.solid()) || (this.next != null && (this.next.rotation() + 2)%4 == rotation());
|
blocked = (next != null && next.solid()) || (this.next != null && (this.next.rotation() + 2)%4 == rotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +111,7 @@ public class MassConveyor extends Block{
|
|||||||
}
|
}
|
||||||
}else if(!blocked){
|
}else if(!blocked){
|
||||||
//dump item forward
|
//dump item forward
|
||||||
float trnext = size * tilesize / 2f, cx = Geometry.d4[rotation()].x, cy = Geometry.d4[rotation()].y, rot = rotation() * 90;
|
float trnext = size * tilesize / 2f, cx = Geometry.d4(rotation()).x, cy = Geometry.d4(rotation()).y, rot = rotation() * 90;
|
||||||
|
|
||||||
if(item.dump(x + cx * trnext, y + cy * trnext, rotation() * 90)){
|
if(item.dump(x + cx * trnext, y + cy * trnext, rotation() * 90)){
|
||||||
item = null;
|
item = null;
|
||||||
@@ -192,14 +194,14 @@ public class MassConveyor extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptPayload(Tilec source, Payload payload){
|
public boolean acceptPayload(Tilec source, Payload payload){
|
||||||
return this.item == null;
|
return this.item == null && progress <= 5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePayload(Tilec source, Payload payload){
|
public void handlePayload(Tilec source, Payload payload){
|
||||||
this.item = payload;
|
this.item = payload;
|
||||||
this.stepAccepted = curStep();
|
this.stepAccepted = curStep();
|
||||||
this.itemRotation = source.rotation() * 90;
|
this.itemRotation = source.angleTo(this);
|
||||||
this.animation = 0;
|
this.animation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,10 +209,10 @@ public class MassConveyor extends Block{
|
|||||||
if(direction == rotation()){
|
if(direction == rotation()){
|
||||||
return !blocked || next != null;
|
return !blocked || next != null;
|
||||||
}else{
|
}else{
|
||||||
Tilec accept = nearby(Geometry.d4[direction].x * size, Geometry.d4[direction].y * size);
|
Tilec accept = nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size);
|
||||||
return accept != null && accept.block().size == size && accept.block().outputsPayload &&
|
return accept != null && accept.block().size == size && accept.block().outputsPayload &&
|
||||||
//block must either be facing this one, or not be rotating
|
//block must either be facing this one, or not be rotating
|
||||||
((accept.tileX() + Geometry.d4[accept.rotation()].x * size == tileX() && accept.tileY() + Geometry.d4[accept.rotation()].y * size == tileY()) || !accept.block().rotate);
|
((accept.tileX() + Geometry.d4(accept.rotation()).x * size == tileX() && accept.tileY() + Geometry.d4(accept.rotation()).y * size == tileY()) || !accept.block().rotate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
233
core/src/mindustry/world/blocks/units/PayloadUnitFactory.java
Normal file
233
core/src/mindustry/world/blocks/units/PayloadUnitFactory.java
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
package mindustry.world.blocks.units;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.math.*;
|
||||||
|
import arc.scene.ui.layout.*;
|
||||||
|
import arc.struct.*;
|
||||||
|
import arc.util.ArcAnnotate.*;
|
||||||
|
import arc.util.io.*;
|
||||||
|
import mindustry.*;
|
||||||
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.entities.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.*;
|
||||||
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
import mindustry.world.consumers.*;
|
||||||
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
|
//TODO remove
|
||||||
|
public class PayloadUnitFactory extends Block{
|
||||||
|
public float launchVelocity = 0f;
|
||||||
|
public TextureRegion topRegion;
|
||||||
|
public int[] capacities;
|
||||||
|
|
||||||
|
public UnitPlan[] plans = new UnitPlan[0];
|
||||||
|
|
||||||
|
public PayloadUnitFactory(String name){
|
||||||
|
super(name);
|
||||||
|
update = true;
|
||||||
|
hasPower = true;
|
||||||
|
hasItems = true;
|
||||||
|
solid = false;
|
||||||
|
flags = EnumSet.of(BlockFlag.producer);
|
||||||
|
configurable = true;
|
||||||
|
outputsPayload = true;
|
||||||
|
|
||||||
|
config(Integer.class, (tile, i) -> ((UnitFactoryEntity)tile).currentPlan = i < 0 || i >= plans.length ? -1 : i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Remote(called = Loc.server)
|
||||||
|
public static void onUnitFactorySpawn(Tile tile){
|
||||||
|
if(!(tile.entity instanceof UnitFactoryEntity)) return;
|
||||||
|
tile.<UnitFactoryEntity>ent().spawned();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(){
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
capacities = new int[Vars.content.items().size];
|
||||||
|
if(consumes.has(ConsumeType.item)){
|
||||||
|
ConsumeItems cons = consumes.get(ConsumeType.item);
|
||||||
|
for(ItemStack stack : cons.items){
|
||||||
|
capacities[stack.item.id] = stack.amount * 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(){
|
||||||
|
super.load();
|
||||||
|
|
||||||
|
topRegion = Core.atlas.find(name + "-top");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBars(){
|
||||||
|
super.setBars();
|
||||||
|
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, ((UnitFactoryEntity)entity)::fraction));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean outputsItems(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStats(){
|
||||||
|
super.setStats();
|
||||||
|
|
||||||
|
stats.remove(BlockStat.itemCapacity);
|
||||||
|
//TODO
|
||||||
|
//stats.add(BlockStat.productionTime, produceTime / 60f, StatUnit.seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] generateIcons(){
|
||||||
|
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UnitPlan{
|
||||||
|
public UnitType unit;
|
||||||
|
public ItemStack[] requirements;
|
||||||
|
public float time;
|
||||||
|
|
||||||
|
public UnitPlan(UnitType unit, float time, ItemStack[] requirements){
|
||||||
|
this.unit = unit;
|
||||||
|
this.time = time;
|
||||||
|
this.requirements = requirements;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnitPlan(){}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UnitFactoryEntity extends TileEntity{
|
||||||
|
public int currentPlan = -1;
|
||||||
|
|
||||||
|
public float progress, time, speedScl;
|
||||||
|
public @Nullable UnitPayload payload;
|
||||||
|
|
||||||
|
public float fraction(){
|
||||||
|
return currentPlan == -1 ? 0 : progress / plans[currentPlan].time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void spawned(){
|
||||||
|
progress = 0f;
|
||||||
|
|
||||||
|
Effects.shake(2f, 3f, this);
|
||||||
|
Fx.producesmoke.at(this);
|
||||||
|
|
||||||
|
if(currentPlan != -1){
|
||||||
|
UnitPlan plan = plans[currentPlan];
|
||||||
|
Unitc unit = plan.unit.create(team);
|
||||||
|
|
||||||
|
payload = new UnitPayload(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildConfiguration(Table table){
|
||||||
|
Array<UnitType> units = Array.with(plans).map(u -> u.unit);
|
||||||
|
|
||||||
|
ItemSelection.buildTable(table, units, () -> currentPlan == -1 ? null : plans[currentPlan].unit, unit -> tile.configure(units.indexOf(unit)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object config(){
|
||||||
|
return currentPlan;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
super.draw();
|
||||||
|
|
||||||
|
if(currentPlan != -1){
|
||||||
|
UnitPlan plan = plans[currentPlan];
|
||||||
|
|
||||||
|
TextureRegion region = plan.unit.icon(Cicon.full);
|
||||||
|
|
||||||
|
Shaders.build.region = region;
|
||||||
|
Shaders.build.progress = progress / plan.time;
|
||||||
|
Shaders.build.color.set(Pal.accent);
|
||||||
|
Shaders.build.color.a = speedScl;
|
||||||
|
Shaders.build.time = -time / 20f;
|
||||||
|
|
||||||
|
Draw.shader(Shaders.build);
|
||||||
|
Draw.rect(region, x, y);
|
||||||
|
Draw.shader();
|
||||||
|
|
||||||
|
Draw.color(Pal.accent);
|
||||||
|
Draw.alpha(speedScl);
|
||||||
|
|
||||||
|
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.rect(topRegion, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTile(){
|
||||||
|
if(currentPlan < 0 || currentPlan >= plans.length){
|
||||||
|
currentPlan = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((consValid() || tile.isEnemyCheat()) && currentPlan != -1 && payload == null){
|
||||||
|
time += delta() * efficiency() * speedScl * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||||
|
progress += delta() * efficiency() * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||||
|
speedScl = Mathf.lerpDelta(speedScl, 1f, 0.05f);
|
||||||
|
}else{
|
||||||
|
speedScl = Mathf.lerpDelta(speedScl, 0f, 0.05f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(payload != null && dumpPayload(payload)){
|
||||||
|
payload = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentPlan != -1){
|
||||||
|
UnitPlan plan = plans[currentPlan];
|
||||||
|
|
||||||
|
if(progress >= plan.time){
|
||||||
|
progress = 0f;
|
||||||
|
|
||||||
|
Call.onUnitFactorySpawn(tile);
|
||||||
|
useContent(plan.unit);
|
||||||
|
consume();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
progress = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaximumAccepted(Item item){
|
||||||
|
return capacities[item.id];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte version(){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(Writes write){
|
||||||
|
super.write(write);
|
||||||
|
write.f(progress);
|
||||||
|
write.s(currentPlan);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Reads read, byte revision){
|
||||||
|
super.read(read, revision);
|
||||||
|
progress = read.f();
|
||||||
|
currentPlan = read.s();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -108,7 +108,6 @@ public class UnitFactory extends Block{
|
|||||||
|
|
||||||
public class UnitFactoryEntity extends TileEntity{
|
public class UnitFactoryEntity extends TileEntity{
|
||||||
public int currentPlan = -1;
|
public int currentPlan = -1;
|
||||||
|
|
||||||
public float progress, time, speedScl;
|
public float progress, time, speedScl;
|
||||||
|
|
||||||
public float fraction(){
|
public float fraction(){
|
||||||
@@ -216,12 +215,14 @@ public class UnitFactory extends Block{
|
|||||||
public void write(Writes write){
|
public void write(Writes write){
|
||||||
super.write(write);
|
super.write(write);
|
||||||
write.f(progress);
|
write.f(progress);
|
||||||
|
write.s(currentPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(Reads read, byte revision){
|
public void read(Reads read, byte revision){
|
||||||
super.read(read, revision);
|
super.read(read, revision);
|
||||||
progress = read.f();
|
progress = read.f();
|
||||||
|
currentPlan = read.s();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user