mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-03 13:30:25 +07:00
Fixed bugs with router clogging and save loading
This commit is contained in:
parent
f5583f6bc8
commit
56113cd1de
@ -92,13 +92,6 @@ public class Pathfind{
|
||||
}
|
||||
}
|
||||
|
||||
//TODO make this work?
|
||||
/*
|
||||
PathFinderRequest<Tile> request = new PathFinderRequest<Tile>();
|
||||
request.startNode = World.spawnpoints.get(0);
|
||||
request.endNode = World.core;
|
||||
passpathfinder.search(request, 1000); */
|
||||
|
||||
for(int i = 0; i < paths.size; i ++){
|
||||
SmoothGraphPath path = paths.get(i);
|
||||
|
||||
|
@ -76,13 +76,17 @@ public class LoadDialog extends FloatingDialog{
|
||||
hide();
|
||||
try{
|
||||
SaveIO.loadFromSlot(slot);
|
||||
GameState.set(State.playing);
|
||||
Vars.ui.hideMenu();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
Vars.ui.hideMenu();
|
||||
GameState.set(State.menu);
|
||||
Vars.control.reset();
|
||||
Vars.ui.showError("[orange]Save file corrupted or invalid!");
|
||||
return;
|
||||
}
|
||||
Vars.ui.hideMenu();
|
||||
GameState.set(State.playing);
|
||||
|
||||
}
|
||||
}, 3f/60f);
|
||||
}
|
||||
|
@ -79,14 +79,14 @@ public class Conveyor extends Block{
|
||||
for(int j = 0; j < entity.convey.size; j ++){
|
||||
ItemPos other = pos2.set(entity.convey.get(j));
|
||||
|
||||
if(other.y > pos.y && other.y - pos.y < 0.14){
|
||||
if(other.y > pos.y && other.y - pos.y < 0.14 * Timers.delta()){
|
||||
canmove = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(canmove){
|
||||
pos.y += speed * Timers.delta();
|
||||
pos.y += Math.max(speed * Timers.delta(), 1f/252f); //TODO fix precision issues?
|
||||
pos.x = MathUtils.lerp(pos.x, 0, 0.06f * Timers.delta());
|
||||
}else{
|
||||
pos.x = MathUtils.lerp(pos.x, pos.seed/128f/3f, 0.1f * Timers.delta());
|
||||
@ -138,7 +138,7 @@ public class Conveyor extends Block{
|
||||
* Conveyor data format:
|
||||
* [0] item ordinal
|
||||
* [1] x: byte ranging from -128 to 127, scaled should be at [-1, 1], corresponds to relative X from the conveyor middle
|
||||
* [2] y: byte ranging from 0 to 127, scaled should be at [0, 1], corresponds to relative Y from the conveyor start
|
||||
* [2] y: byte ranging from -128 to 127, scaled should be at [0, 1], corresponds to relative Y from the conveyor start
|
||||
* [3] seed: -128 to 127, unscaled
|
||||
* Size is 4 bytes, or one int.
|
||||
*/
|
||||
@ -178,7 +178,7 @@ public class Conveyor extends Block{
|
||||
byte[] values = Bits.getBytes(value);
|
||||
item = items[values[0]];
|
||||
x = values[1] / 127f;
|
||||
y = ((int)values[2]) / 127f;
|
||||
y = ((int)values[2] + 128) / 255f;
|
||||
seed = values[3];
|
||||
return this;
|
||||
}
|
||||
@ -191,7 +191,7 @@ public class Conveyor extends Block{
|
||||
byte[] bytes = Bits.getBytes(0);
|
||||
bytes[0] = (byte)item.ordinal();
|
||||
bytes[1] = (byte)(x*127);
|
||||
bytes[2] = (byte)(y*127);
|
||||
bytes[2] = (byte)(y*255-128);
|
||||
bytes[3] = seed;
|
||||
//UCore.log("Packing item: ", item, x, y, seed, "\n", Arrays.toString(bytes));
|
||||
//UCore.log(Arrays.toString(Bits.getBytes(Bits.packInt(bytes))));
|
||||
|
@ -9,6 +9,7 @@ import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Router extends Block{
|
||||
private ObjectMap<Tile, Byte> lastmap = new ObjectMap<>();
|
||||
@ -34,8 +35,10 @@ public class Router extends Block{
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
if(Timers.get(tile, "dump", 2) && tile.entity.totalItems() > 0){
|
||||
if(lastmap.get(tile, (byte)-1) != tile.rotation)
|
||||
if(lastmap.get(tile, (byte)-1) != tile.rotation
|
||||
|| Mathf.chance(0.3)){ //sometimes dump backwards at a 1/4 chance... this somehow works?
|
||||
tryDump(tile, tile.rotation, null);
|
||||
}
|
||||
|
||||
tile.rotation ++;
|
||||
tile.rotation %= 4;
|
||||
|
@ -17,7 +17,7 @@ public class DesktopLauncher {
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setTitle("Mindustry");
|
||||
config.setMaximized(true);
|
||||
//config.useVsync(false);
|
||||
config.useVsync(false);
|
||||
config.setWindowedMode(800, 600);
|
||||
config.setWindowIcon("sprites/icon.png");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user