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