Implemented various suggestions
- Pathfinding weighs walls more - C disables all HUD - Unloader doesn't store items - Some bugfixes
This commit is contained in:
@@ -302,7 +302,7 @@ public class Block extends UnlockableContent{
|
||||
|
||||
// Note: Power stats are added by the consumers.
|
||||
if(hasLiquids) stats.add(BlockStat.liquidCapacity, liquidCapacity, StatUnit.liquidUnits);
|
||||
if(hasItems) stats.add(BlockStat.itemCapacity, itemCapacity, StatUnit.items);
|
||||
if(hasItems && itemCapacity > 0) stats.add(BlockStat.itemCapacity, itemCapacity, StatUnit.items);
|
||||
}
|
||||
|
||||
public void setBars(){
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Tile implements Position, QuadTreeObject{
|
||||
static final ObjectSet<Tilec> tileSet = new ObjectSet<>();
|
||||
|
||||
/** Tile traversal cost. */
|
||||
public byte cost = 1;
|
||||
public short cost = 1;
|
||||
/** Tile entity, usually null. */
|
||||
public @Nullable Tilec entity;
|
||||
public short x, y;
|
||||
@@ -452,32 +452,22 @@ public class Tile implements Position, QuadTreeObject{
|
||||
}
|
||||
}
|
||||
|
||||
//+24
|
||||
|
||||
if(occluded){
|
||||
cost += 2;
|
||||
}
|
||||
|
||||
//+26
|
||||
|
||||
if(block.synthetic() && solid()){
|
||||
cost += Mathf.clamp(block.health / 10f, 0, 20);
|
||||
cost += Mathf.clamp(block.health / 6f, 0, 1000);
|
||||
}
|
||||
|
||||
//+46
|
||||
|
||||
if(floor.isLiquid){
|
||||
cost += 10;
|
||||
}
|
||||
|
||||
//+56
|
||||
|
||||
if(floor.drownTime > 0){
|
||||
cost += 70;
|
||||
}
|
||||
|
||||
//+126
|
||||
|
||||
if(cost < 0){
|
||||
cost = Byte.MAX_VALUE;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
if(dominantItems > 0 && progress >= drillTime + hardnessDrillMultiplier * dominantItem.hardness && items.total() < itemCapacity){
|
||||
offloadNear(dominantItem);
|
||||
offload(dominantItem);
|
||||
useContent(dominantItem);
|
||||
|
||||
index++;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class GenericCrafter extends Block{
|
||||
if(outputItem != null){
|
||||
useContent(outputItem.item);
|
||||
for(int i = 0; i < outputItem.amount; i++){
|
||||
offloadNear(outputItem.item);
|
||||
offload(outputItem.item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Separator extends Block{
|
||||
consume();
|
||||
|
||||
if(item != null && items.get(item) < itemCapacity){
|
||||
offloadNear(item);
|
||||
offload(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public class Unloader extends Block{
|
||||
hasItems = true;
|
||||
configurable = true;
|
||||
saveConfig = true;
|
||||
itemCapacity = 0;
|
||||
|
||||
config(Item.class, (tile, item) -> {
|
||||
tile.items().clear();
|
||||
@@ -47,40 +48,31 @@ public class Unloader extends Block{
|
||||
|
||||
public class UnloaderEntity extends TileEntity{
|
||||
public Item sortItem = null;
|
||||
|
||||
private Item removeItem(Tilec tile, Item item){
|
||||
if(item == null){
|
||||
return tile.items().take();
|
||||
}else{
|
||||
if(tile.items().has(item)){
|
||||
tile.items().remove(item, 1);
|
||||
return item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasItem(Tilec tile, Item item){
|
||||
if(item == null){
|
||||
return tile.items().total() > 0;
|
||||
}else{
|
||||
return tile.items().has(item);
|
||||
}
|
||||
}
|
||||
public Tilec dumpingTo;
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(timer(timerUnload, speed / timeScale()) && items.total() == 0){
|
||||
if(timer(timerUnload, speed / timeScale())){
|
||||
for(Tilec other : proximity){
|
||||
if(other.interactable(team) && other.block().unloadable && other.block().hasItems && items.total() == 0 &&
|
||||
((sortItem == null && items.total() > 0) || hasItem(other, sortItem))){
|
||||
offloadNear(removeItem(other, sortItem));
|
||||
if(other.interactable(team) && other.block().unloadable && other.block().hasItems
|
||||
&& ((sortItem == null && other.items().total() > 0) || (sortItem != null && other.items().has(sortItem)))){
|
||||
//make sure the item can't be dumped back into this block
|
||||
dumpingTo = other;
|
||||
|
||||
//get item to be taken
|
||||
Item item = sortItem == null ? other.items().beginTake() : sortItem;
|
||||
|
||||
//remove item if it's dumped correctly
|
||||
if(put(item)){
|
||||
if(sortItem == null){
|
||||
other.items().endTake(item);
|
||||
}else{
|
||||
other.items().remove(item, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dump();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +102,7 @@ public class Unloader extends Block{
|
||||
|
||||
@Override
|
||||
public boolean canDump(Tilec to, Item item){
|
||||
return !(to.block() instanceof StorageBlock);
|
||||
return !(to.block() instanceof StorageBlock) && to != dumpingTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -160,6 +160,25 @@ public class ItemModule extends BlockModule{
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Begins a speculative take operation. This returns the item that would be returned by #take(), but does not change state. */
|
||||
public Item beginTake(){
|
||||
for(int i = 0; i < items.length; i++){
|
||||
int index = (i + takeRotation);
|
||||
if(index >= items.length) index -= items.length;
|
||||
if(items[index] > 0){
|
||||
return content.item(index);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Finishes a take operation. Updates take state, removes the item. */
|
||||
public void endTake(Item item){
|
||||
items[item.id] --;
|
||||
total --;
|
||||
takeRotation = item.id + 1;
|
||||
}
|
||||
|
||||
public int get(int id){
|
||||
return items[id];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user