Implemented various suggestions
- Pathfinding weighs walls more - C disables all HUD - Unloader doesn't store items - Some bugfixes
This commit is contained in:
@@ -62,7 +62,7 @@ public class Pathfinder implements Runnable{
|
||||
|
||||
/** Packs a tile into its internal representation. */
|
||||
private int packTile(Tile tile){
|
||||
return PathTile.get(tile.cost, tile.getTeamID(), (byte)0, !tile.solid() && tile.floor().drownTime <= 0f);
|
||||
return PathTile.get(tile.cost, tile.getTeamID(), !tile.solid() && tile.floor().drownTime <= 0f);
|
||||
}
|
||||
|
||||
/** Starts or restarts the pathfinding thread. */
|
||||
@@ -360,11 +360,11 @@ public class Pathfinder implements Runnable{
|
||||
@Struct
|
||||
class PathTileStruct{
|
||||
//traversal cost
|
||||
byte cost;
|
||||
short cost;
|
||||
//team of block, if applicable (0 by default)
|
||||
byte team;
|
||||
//type of target; TODO remove
|
||||
byte type;
|
||||
//byte type;
|
||||
//whether it's viable to pass this block
|
||||
boolean passable;
|
||||
}
|
||||
|
||||
@@ -489,6 +489,7 @@ public class Bullets implements ContentList{
|
||||
despawnEffect = Fx.none;
|
||||
hitSize = 4;
|
||||
lifetime = 16f;
|
||||
drawSize = 400f;
|
||||
}};
|
||||
|
||||
meltdownLaser = new BulletType(0.001f, 70){
|
||||
|
||||
@@ -477,7 +477,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
||||
* Tries to put this item into a nearby container, if there are no available
|
||||
* containers, it gets added to the block's inventory.
|
||||
*/
|
||||
public void offloadNear(Item item){
|
||||
public void offload(Item item){
|
||||
Array<Tilec> proximity = proximity();
|
||||
int dump = rotation() / block.dumpIncrement;
|
||||
useContent(item);
|
||||
@@ -494,6 +494,26 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
||||
handleItem(this, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to put this item into a nearby container. Returns success. Unlike #offload(), this method does not change the block inventory.
|
||||
*/
|
||||
public boolean put(Item item){
|
||||
Array<Tilec> proximity = proximity();
|
||||
int dump = rotation() / block.dumpIncrement;
|
||||
useContent(item);
|
||||
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
incrementDump(proximity.size);
|
||||
Tilec other = proximity.get((i + dump) % proximity.size);
|
||||
if(other.team() == team() && other.acceptItem(this, item) && canDump(other, item)){
|
||||
other.handleItem(this, item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Try dumping any item near the */
|
||||
public boolean dump(){
|
||||
return dump(null);
|
||||
|
||||
@@ -40,7 +40,8 @@ public class LoadRenderer implements Disposable{
|
||||
private long lastFrameTime;
|
||||
|
||||
{
|
||||
fx.addEffect(new VignettingFilter(false));
|
||||
//vignetting is probably too much
|
||||
//fx.addEffect(new VignettingFilter(false));
|
||||
fx.addEffect(new BloomFilter());
|
||||
|
||||
bars = new Bar[]{
|
||||
|
||||
@@ -43,7 +43,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
float rawHeight(Vec3 position){
|
||||
position = Tmp.v33.set(position).scl(scl);
|
||||
return Mathf.pow((float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y, position.z), 2.3f);
|
||||
return Mathf.pow((float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y, position.z), 2.3f) + 0.05f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -344,7 +344,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
}
|
||||
});
|
||||
|
||||
graphics.checkPref("linear", !mobile, b -> {
|
||||
graphics.checkPref("linear", true, b -> {
|
||||
for(Texture tex : Core.atlas.getTextures()){
|
||||
TextureFilter filter = b ? TextureFilter.Linear : TextureFilter.Nearest;
|
||||
tex.setFilter(filter, filter);
|
||||
|
||||
@@ -181,7 +181,7 @@ public class HudFragment extends Fragment{
|
||||
|
||||
//fps display
|
||||
cont.table(info -> {
|
||||
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps"));
|
||||
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps") && shown);
|
||||
info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -Scl.scl(dsize * 4 + 3), 0));
|
||||
IntFormat fps = new IntFormat("fps");
|
||||
IntFormat ping = new IntFormat("ping");
|
||||
@@ -193,7 +193,7 @@ public class HudFragment extends Fragment{
|
||||
});
|
||||
|
||||
parent.fill(t -> {
|
||||
t.visible(() -> Core.settings.getBool("minimap") && !state.rules.tutorial);
|
||||
t.visible(() -> Core.settings.getBool("minimap") && !state.rules.tutorial && shown);
|
||||
//minimap
|
||||
t.add(new Minimap());
|
||||
t.row();
|
||||
|
||||
@@ -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