Bugfixes / Compile error fixes / Removed routers
This commit is contained in:
@@ -44,11 +44,11 @@ public class Recipes implements ContentList{
|
||||
|
||||
//starter lead transporation
|
||||
new Recipe(distribution, DistributionBlocks.junction, new ItemStack(Items.lead, 2));
|
||||
new Recipe(distribution, DistributionBlocks.router, new ItemStack(Items.lead, 6));
|
||||
new Recipe(distribution, DistributionBlocks.splitter, new ItemStack(Items.lead, 6));
|
||||
|
||||
//advanced carbide transporation
|
||||
new Recipe(distribution, DistributionBlocks.splitter, new ItemStack(Items.carbide, 2), new ItemStack(Items.tungsten, 2));
|
||||
new Recipe(distribution, DistributionBlocks.multiplexer, new ItemStack(Items.carbide, 8), new ItemStack(Items.tungsten, 8));
|
||||
//new Recipe(distribution, DistributionBlocks.splitter, new ItemStack(Items.carbide, 2), new ItemStack(Items.tungsten, 2));
|
||||
new Recipe(distribution, DistributionBlocks.distributor, new ItemStack(Items.carbide, 8), new ItemStack(Items.tungsten, 8));
|
||||
new Recipe(distribution, DistributionBlocks.sorter, new ItemStack(Items.carbide, 4), new ItemStack(Items.tungsten, 4));
|
||||
new Recipe(distribution, DistributionBlocks.overflowGate, new ItemStack(Items.carbide, 4), new ItemStack(Items.tungsten, 8));
|
||||
new Recipe(distribution, DistributionBlocks.bridgeConveyor, new ItemStack(Items.carbide, 8), new ItemStack(Items.tungsten, 8));
|
||||
|
||||
@@ -5,7 +5,7 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.distribution.*;
|
||||
|
||||
public class DistributionBlocks extends BlockList implements ContentList{
|
||||
public static Block conveyor, titaniumconveyor, router, multiplexer, junction,
|
||||
public static Block conveyor, titaniumconveyor, distributor, junction,
|
||||
bridgeConveyor, phaseConveyor, sorter, splitter, overflowGate, massDriver;
|
||||
|
||||
@Override
|
||||
@@ -21,13 +21,6 @@ public class DistributionBlocks extends BlockList implements ContentList{
|
||||
speed = 0.07f;
|
||||
}};
|
||||
|
||||
router = new Router("router");
|
||||
|
||||
multiplexer = new Router("multiplexer") {{
|
||||
size = 2;
|
||||
itemCapacity = 80;
|
||||
}};
|
||||
|
||||
junction = new Junction("junction") {{
|
||||
speed = 26;
|
||||
capacity = 32;
|
||||
@@ -46,6 +39,11 @@ public class DistributionBlocks extends BlockList implements ContentList{
|
||||
|
||||
splitter = new Splitter("splitter");
|
||||
|
||||
distributor = new Splitter("distributor") {{
|
||||
size = 2;
|
||||
itemCapacity = 80;
|
||||
}};
|
||||
|
||||
overflowGate = new OverflowGate("overflow-gate");
|
||||
|
||||
massDriver = new MassDriver("mass-driver"){{
|
||||
|
||||
@@ -87,6 +87,7 @@ public class UnitInventory implements Saveable{
|
||||
}
|
||||
|
||||
public void addAmmo(AmmoType type){
|
||||
if(type == null) return;
|
||||
totalAmmo += type.quantityMultiplier;
|
||||
|
||||
//find ammo entry by type
|
||||
|
||||
@@ -71,6 +71,10 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
return type;
|
||||
}
|
||||
|
||||
public Tile getSpawner(){
|
||||
return world.tile(spawner);
|
||||
}
|
||||
|
||||
/**internal constructor used for deserialization, DO NOT USE*/
|
||||
public BaseUnit(){}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ public abstract class BaseBlock {
|
||||
public boolean hasLiquids;
|
||||
public boolean hasPower;
|
||||
|
||||
public boolean singleLiquid = true;
|
||||
|
||||
public int itemCapacity;
|
||||
public float liquidCapacity = 10f;
|
||||
public float liquidFlowFactor = 4.9f;
|
||||
@@ -61,7 +63,8 @@ public abstract class BaseBlock {
|
||||
}
|
||||
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return tile.entity.liquids.get(liquid) + amount < liquidCapacity;
|
||||
return tile.entity.liquids.get(liquid) + amount < liquidCapacity &&
|
||||
(!singleLiquid || (tile.entity.liquids.current() == liquid || tile.entity.liquids.get(tile.entity.liquids.current()) < 0.01f));
|
||||
}
|
||||
|
||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class LiquidTurret extends Turret {
|
||||
public void setBars() {
|
||||
super.setBars();
|
||||
bars.remove(BarType.inventory);
|
||||
bars.replace(new BlockBar(BarType.liquid, true, tile -> tile.entity.liquids.amount / liquidCapacity));
|
||||
bars.replace(new BlockBar(BarType.liquid, true, tile -> tile.entity.liquids.total() / liquidCapacity));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,20 +53,20 @@ public abstract class LiquidTurret extends Turret {
|
||||
@Override
|
||||
public AmmoType useAmmo(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
AmmoType type = liquidAmmoMap.get(entity.liquids.liquid);
|
||||
entity.liquids.amount -= type.quantityMultiplier;
|
||||
AmmoType type = liquidAmmoMap.get(entity.liquids.current());
|
||||
entity.liquids.remove(type.liquid, type.quantityMultiplier);
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AmmoType peekAmmo(Tile tile){
|
||||
return liquidAmmoMap.get(tile.entity.liquids.liquid);
|
||||
return liquidAmmoMap.get(tile.entity.liquids.current());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAmmo(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
return liquidAmmoMap.get(entity.liquids.liquid) != null && entity.liquids.amount >= liquidAmmoMap.get(entity.liquids.liquid).quantityMultiplier;
|
||||
return liquidAmmoMap.get(entity.liquids.current()) != null && entity.liquids.total() >= liquidAmmoMap.get(entity.liquids.current()).quantityMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +89,8 @@ public abstract class LiquidTurret extends Turret {
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return super.acceptLiquid(tile, source, liquid, amount) && liquidAmmoMap.get(liquid) != null;
|
||||
return super.acceptLiquid(tile, source, liquid, amount) && liquidAmmoMap.get(liquid) != null
|
||||
&& (tile.entity.liquids.current() == liquid || tile.entity.liquids.get(tile.entity.liquids.current()) < 0.01f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class Conduit extends LiquidBlock {
|
||||
super.load();
|
||||
|
||||
liquidRegion = Draw.region("conduit-liquid");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,8 +68,7 @@ public class Conduit extends LiquidBlock {
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
||||
tile.entity.wakeUp();
|
||||
return super.acceptLiquid(tile, source, liquid, amount) && (tile.entity.liquids.current() == liquid || tile.entity.liquids.get(tile.entity.liquids.current()) < 0.01f) &&
|
||||
((2 + source.relativeTo(tile.x, tile.y)) % 4 != tile.getRotation());
|
||||
return super.acceptLiquid(tile, source, liquid, amount) && ((2 + source.relativeTo(tile.x, tile.y)) % 4 != tile.getRotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@ public class LiquidBridge extends ItemBridge {
|
||||
|
||||
Tile other = world.tile(entity.link);
|
||||
if(!linkValid(tile, other)){
|
||||
tryDumpLiquid(tile);
|
||||
tryDumpLiquid(tile, entity.liquids.current());
|
||||
}else{
|
||||
float use = Math.min(powerCapacity, powerUse * Timers.delta());
|
||||
|
||||
@@ -37,7 +37,7 @@ public class LiquidBridge extends ItemBridge {
|
||||
|
||||
if(entity.uptime >= 0.5f){
|
||||
|
||||
if(tryMoveLiquid(tile, other, false) > 0.1f){
|
||||
if(tryMoveLiquid(tile, other, false, entity.liquids.current()) > 0.1f){
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f);
|
||||
}else{
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 1f, 0.01f);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge {
|
||||
|
||||
Tile other = world.tile(entity.link);
|
||||
if(!linkValid(tile, other)){
|
||||
tryDumpLiquid(tile);
|
||||
tryDumpLiquid(tile, entity.liquids.current());
|
||||
}else{
|
||||
float use = Math.min(powerCapacity, powerUse * Timers.delta());
|
||||
|
||||
@@ -37,7 +37,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge {
|
||||
|
||||
if(entity.uptime >= 0.5f){
|
||||
|
||||
if(tryMoveLiquid(tile, other, false) > 0.1f){
|
||||
if(tryMoveLiquid(tile, other, false, entity.liquids.current()) > 0.1f){
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f);
|
||||
}else{
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 1f, 0.01f);
|
||||
|
||||
@@ -12,8 +12,8 @@ public class LiquidRouter extends LiquidBlock{
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
|
||||
if(tile.entity.liquids.amount > 0){
|
||||
tryDumpLiquid(tile);
|
||||
if(tile.entity.liquids.total() > 0.01f){
|
||||
tryDumpLiquid(tile, tile.entity.liquids.current());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,9 @@ public class MassDriver extends Block {
|
||||
DriverBulletData data = Pooling.obtain(DriverBulletData.class);
|
||||
data.from = entity;
|
||||
data.to = other;
|
||||
System.arraycopy(entity.items.items, 0, data.items, 0, data.items.length);
|
||||
for (int i = 0; i < Item.all().size; i++) {
|
||||
data.items[i] = entity.items.get(Item.getByID(i));
|
||||
}
|
||||
entity.items.clear();
|
||||
|
||||
float angle = tile.angleTo(target);
|
||||
@@ -226,7 +228,7 @@ public class MassDriver extends Block {
|
||||
//add all the items possible
|
||||
for(int i = 0; i < data.items.length; i ++){
|
||||
int maxAdd = Math.min(data.items[i], itemCapacity - totalItems);
|
||||
items.items[i] += maxAdd;
|
||||
items.add(Item.getByID(i), maxAdd);
|
||||
data.items[i] -= maxAdd;
|
||||
totalItems += maxAdd;
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Splitter extends Block{
|
||||
|
||||
@@ -31,33 +34,17 @@ public class Splitter extends Block{
|
||||
}
|
||||
|
||||
Tile getTileTarget(Item item, Tile dest, Tile source, boolean flip){
|
||||
int dir = source.relativeTo(dest.x, dest.y);
|
||||
if(dir == -1) return null;
|
||||
Tile to;
|
||||
|
||||
Tile a = dest.getNearby(Mathf.mod(dir - 1, 4));
|
||||
Tile b = dest.getNearby(Mathf.mod(dir + 1, 4));
|
||||
boolean ac = !(a.block().instantTransfer && source.block().instantTransfer) &&
|
||||
a.block().acceptItem(item, a, dest);
|
||||
boolean bc = !(b.block().instantTransfer && source.block().instantTransfer) &&
|
||||
b.block().acceptItem(item, b, dest);
|
||||
|
||||
if(ac && !bc){
|
||||
to = a;
|
||||
}else if(bc && !ac){
|
||||
to = b;
|
||||
}else{
|
||||
if(dest.getDump() == 0){
|
||||
to = a;
|
||||
if(flip)
|
||||
dest.setDump((byte)1);
|
||||
}else{
|
||||
to = b;
|
||||
if(flip)
|
||||
dest.setDump((byte)0);
|
||||
GridPoint2[] points = Edges.getEdges(size);
|
||||
int counter = source.getDump();
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
GridPoint2 point = points[(i + counter++) % points.length];
|
||||
source.setDump((byte)(counter % points.length));
|
||||
Tile tile = world.tile(dest.x + point.x, dest.y + point.y);
|
||||
if(tile != source && !(tile.block().instantTransfer && source.block().instantTransfer) &&
|
||||
tile.block().acceptItem(item, tile, dest)){
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class CoreBlock extends StorageBlock {
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source) {
|
||||
return tile.entity.items.items[item.id] < itemCapacity && item.type == ItemType.material;
|
||||
return tile.entity.items.get(item) < itemCapacity && item.type == ItemType.material;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -220,10 +220,10 @@ public class CoreBlock extends StorageBlock {
|
||||
Units.getNearby(tile.getTeam(), rect, unit -> {
|
||||
if(unit.isDead() || unit.distanceTo(tile.drawx(), tile.drawy()) > supplyRadius || unit.getGroup() == null) return;
|
||||
|
||||
for(int i = 0; i < tile.entity.items.items.length; i ++){
|
||||
for(int i = 0; i < Item.all().size; i ++){
|
||||
Item item = Item.getByID(i);
|
||||
if(tile.entity.items.items[i] > 0 && unit.acceptsAmmo(item)){
|
||||
tile.entity.items.items[i] --;
|
||||
if(tile.entity.items.get(item) > 0 && unit.acceptsAmmo(item)){
|
||||
tile.entity.items.remove(item, 1);
|
||||
unit.addAmmo(item);
|
||||
CallEntity.transferAmmo(item, tile.drawx(), tile.drawy(), unit);
|
||||
return;
|
||||
|
||||
@@ -16,24 +16,27 @@ public abstract class StorageBlock extends Block {
|
||||
* Returns null if no items are there.*/
|
||||
public Item removeItem(Tile tile, Item item){
|
||||
TileEntity entity = tile.entity;
|
||||
for(int i = 0; i < entity.items.items.length; i ++){
|
||||
if(entity.items.items[i] > 0 && (item == null || i == item.id)){
|
||||
entity.items.items[i] --;
|
||||
return Item.getByID(i);
|
||||
|
||||
if(item == null){
|
||||
return entity.items.take();
|
||||
}else{
|
||||
if(entity.items.has(item)){
|
||||
entity.items.remove(item, 1);
|
||||
return item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**Returns whether this storage block has the specified item.
|
||||
* If the item is null, it should return whether it has ANY items.*/
|
||||
public boolean hasItem(Tile tile, Item item){
|
||||
TileEntity entity = tile.entity;
|
||||
for(int i = 0; i < entity.items.items.length; i ++){
|
||||
if(entity.items.items[i] > 0 && (item == null || i == item.id)){
|
||||
return true;
|
||||
}
|
||||
if(item == null){
|
||||
return entity.items.total() > 0;
|
||||
}else{
|
||||
return entity.items.has(item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,10 +85,10 @@ public class ResupplyPoint extends Block{
|
||||
}else if(entity.target != null && entity.strength > 0.5f){
|
||||
|
||||
if(entity.timer.get(timerSupply, supplyInterval)) {
|
||||
for (int i = 0; i < tile.entity.items.items.length; i++) {
|
||||
for (int i = 0; i < Item.all().size; i++) {
|
||||
Item item = Item.getByID(i);
|
||||
if (tile.entity.items.items[i] > 0 && entity.target.acceptsAmmo(item)) {
|
||||
tile.entity.items.items[i]--;
|
||||
if (tile.entity.items.has(item) && entity.target.acceptsAmmo(item)) {
|
||||
tile.entity.items.remove(item, 1);
|
||||
entity.target.addAmmo(item);
|
||||
break;
|
||||
}
|
||||
@@ -130,9 +130,9 @@ public class ResupplyPoint extends Block{
|
||||
if(unit == null || unit.inventory.totalAmmo() >= unit.inventory.ammoCapacity()
|
||||
|| unit.isDead()) return false;
|
||||
|
||||
for(int i = 0; i < entity.items.items.length; i ++) {
|
||||
for (int i = 0; i < Item.all().size; i++) {
|
||||
Item item = Item.getByID(i);
|
||||
if (entity.items.items[i] > 0 && unit.acceptsAmmo(item)) {
|
||||
if (entity.items.has(item) && unit.acceptsAmmo(item)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@ import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.BarType;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.modules.InventoryModule;
|
||||
import io.anuke.mindustry.world.meta.BlockBar;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.meta.values.ItemListValue;
|
||||
import io.anuke.mindustry.world.modules.InventoryModule;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@@ -136,6 +136,17 @@ public class UnitFactory extends Block {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(!entity.hasSpawned){
|
||||
for(BaseUnit unit : unitGroups[tile.getTeamID()].all()){
|
||||
if(unit.getType() == type && unit.getSpawner() == null){
|
||||
entity.hasSpawned = true;
|
||||
unit.setSpawner(tile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if(!entity.hasSpawned && hasRequirements(entity.items, entity.buildTime/produceTime) &&
|
||||
entity.power.amount >= used && !entity.open){
|
||||
|
||||
@@ -214,11 +225,13 @@ public class UnitFactory extends Block {
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException {
|
||||
stream.writeFloat(buildTime);
|
||||
stream.writeBoolean(hasSpawned);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException {
|
||||
buildTime = stream.readFloat();
|
||||
hasSpawned = stream.readBoolean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user