Bugfixes
This commit is contained in:
@@ -283,7 +283,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
||||
/** Last progress.*/
|
||||
public float progress;
|
||||
/** Whether construction has started for this request.*/
|
||||
public boolean initialized;
|
||||
public boolean initialized, worldContext = true;
|
||||
|
||||
/** Visual scale. Used only for rendering.*/
|
||||
public float animScale = 0f;
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Schematics implements Loadable{
|
||||
all.sort();
|
||||
|
||||
Core.app.post(() -> {
|
||||
shadowBuffer = new FrameBuffer(maxSchematicSize + padding + 2, maxSchematicSize + padding + 2);
|
||||
shadowBuffer = new FrameBuffer(maxSchematicSize + padding + 8, maxSchematicSize + padding + 8);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ public class Schematics implements Loadable{
|
||||
//draw requests
|
||||
requests.each(req -> {
|
||||
req.animScale = 1f;
|
||||
req.worldContext = false;
|
||||
req.block.drawRequestRegion(req, requests::each);
|
||||
});
|
||||
|
||||
@@ -190,8 +191,11 @@ public class Schematics implements Loadable{
|
||||
public void add(Schematic schematic){
|
||||
all.add(schematic);
|
||||
try{
|
||||
write(schematic, schematicDirectory.child(Time.millis() + "." + schematicExtension));
|
||||
}catch(IOException e){
|
||||
FileHandle file = schematicDirectory.child(Time.millis() + "." + schematicExtension);
|
||||
write(schematic, file);
|
||||
schematic.file = file;
|
||||
}catch(Exception e){
|
||||
ui.showException(e);
|
||||
Log.err(e);
|
||||
}
|
||||
}
|
||||
@@ -216,6 +220,8 @@ public class Schematics implements Loadable{
|
||||
x2 = result.x2;
|
||||
y2 = result.y2;
|
||||
|
||||
int ox = x, oy = y, ox2 = x2, oy2 = y2;
|
||||
|
||||
Array<Stile> tiles = new Array<>();
|
||||
|
||||
int minx = x2, miny = y2, maxx = x, maxy = y;
|
||||
@@ -247,17 +253,19 @@ public class Schematics implements Loadable{
|
||||
|
||||
int width = x2 - x + 1, height = y2 - y + 1;
|
||||
int offsetX = -x, offsetY = -y;
|
||||
for(int cx = x; cx <= x2; cx++){
|
||||
for(int cy = y; cy <= y2; cy++){
|
||||
Tile tile = world.tile(cx, cy);
|
||||
IntSet counted = new IntSet();
|
||||
for(int cx = ox; cx <= ox2; cx++){
|
||||
for(int cy = oy; cy <= oy2; cy++){
|
||||
Tile tile = world.ltile(cx, cy);
|
||||
|
||||
if(tile != null && tile.entity != null){
|
||||
if(tile != null && tile.entity != null && !counted.contains(tile.pos())){
|
||||
int config = tile.entity.config();
|
||||
if(tile.block().posConfig){
|
||||
config = Pos.get(Pos.x(config) + offsetX, Pos.y(config) + offsetY);
|
||||
}
|
||||
|
||||
tiles.add(new Stile(tile.block(), cx + offsetX, cy + offsetY, config, tile.rotation()));
|
||||
tiles.add(new Stile(tile.block(), tile.x + offsetX, tile.y + offsetY, config, tile.rotation()));
|
||||
counted.add(tile.pos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class DesktopInput extends InputHandler{
|
||||
ui.showInfoFade("$schematic.saved");
|
||||
ui.schematics.showInfo(lastSchematic);
|
||||
});
|
||||
}).colspan(2).size(250f, 50f);
|
||||
}).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
|
||||
});
|
||||
}).margin(6f);
|
||||
});
|
||||
@@ -175,6 +175,7 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
if(mode != none){
|
||||
selectRequests.clear();
|
||||
lastSchematic = null;
|
||||
}
|
||||
|
||||
if(player.isShooting && !canShoot()){
|
||||
|
||||
@@ -194,6 +194,7 @@ public class SchematicsDialog extends FloatingDialog{
|
||||
t.addImageTextButton("$schematic.shareworkshop", Icon.wikiSmall, style,
|
||||
() -> platform.publish(s)).marginLeft(12f);
|
||||
t.row();
|
||||
dialog.hide();
|
||||
}
|
||||
t.addImageTextButton("$schematic.copy", Icon.copySmall, style, () -> {
|
||||
dialog.hide();
|
||||
|
||||
@@ -33,20 +33,20 @@ public interface Autotiler{
|
||||
}
|
||||
});
|
||||
|
||||
return buildBlending(req.tile(), req.rotation, directionals);
|
||||
return buildBlending(req.tile(), req.rotation, directionals, req.worldContext);
|
||||
}
|
||||
|
||||
default int[] buildBlending(Tile tile, int rotation, BuildRequest[] directional){
|
||||
default int[] buildBlending(Tile tile, int rotation, BuildRequest[] directional, boolean world){
|
||||
int[] blendresult = AutotilerHolder.blendresult;
|
||||
blendresult[0] = 0;
|
||||
blendresult[1] = blendresult[2] = 1;
|
||||
int num =
|
||||
(blends(tile, rotation, directional, 2) && blends(tile, rotation, directional, 1) && blends(tile, rotation, directional, 3)) ? 0 :
|
||||
(blends(tile, rotation, directional, 1) && blends(tile, rotation, directional, 3)) ? 1 :
|
||||
(blends(tile, rotation, directional, 1) && blends(tile, rotation, directional, 2)) ? 2 :
|
||||
(blends(tile, rotation, directional, 3) && blends(tile, rotation, directional, 2)) ? 3 :
|
||||
blends(tile, rotation, directional, 1) ? 4 :
|
||||
blends(tile, rotation, directional, 3) ? 5 :
|
||||
(blends(tile, rotation, directional, 2, world) && blends(tile, rotation, directional, 1, world) && blends(tile, rotation, directional, 3, world)) ? 0 :
|
||||
(blends(tile, rotation, directional, 1, world) && blends(tile, rotation, directional, 3, world)) ? 1 :
|
||||
(blends(tile, rotation, directional, 1, world) && blends(tile, rotation, directional, 2, world)) ? 2 :
|
||||
(blends(tile, rotation, directional, 3, world) && blends(tile, rotation, directional, 2, world)) ? 3 :
|
||||
blends(tile, rotation, directional, 1, world) ? 4 :
|
||||
blends(tile, rotation, directional, 3, world) ? 5 :
|
||||
-1;
|
||||
transformCase(num, blendresult);
|
||||
return blendresult;
|
||||
@@ -70,7 +70,7 @@ public interface Autotiler{
|
||||
}
|
||||
}
|
||||
|
||||
default boolean blends(Tile tile, int rotation, @Nullable BuildRequest[] directional, int direction){
|
||||
default boolean blends(Tile tile, int rotation, @Nullable BuildRequest[] directional, int direction, boolean checkWorld){
|
||||
int realDir = Mathf.mod(rotation - direction, 4);
|
||||
if(directional != null && directional[realDir] != null){
|
||||
BuildRequest req = directional[realDir];
|
||||
@@ -78,7 +78,7 @@ public interface Autotiler{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return blends(tile, rotation, direction);
|
||||
return checkWorld && blends(tile, rotation, direction);
|
||||
}
|
||||
|
||||
default boolean blends(Tile tile, int rotation, int direction){
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
super.onProximityUpdate(tile);
|
||||
|
||||
ConduitEntity entity = tile.entity();
|
||||
int[] bits = buildBlending(tile, tile.rotation(), null);
|
||||
int[] bits = buildBlending(tile, tile.rotation(), null, true);
|
||||
entity.blendbits = bits[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
super.onProximityUpdate(tile);
|
||||
|
||||
ConveyorEntity entity = tile.entity();
|
||||
int[] bits = buildBlending(tile, tile.rotation(), null);
|
||||
int[] bits = buildBlending(tile, tile.rotation(), null, true);
|
||||
entity.blendbits = bits[0];
|
||||
entity.blendsclx = bits[1];
|
||||
entity.blendscly = bits[2];
|
||||
|
||||
Reference in New Issue
Block a user