Fixed #3222 / Fixed #3218 / Fixed #3228 / Fixed #3217

This commit is contained in:
Anuken
2020-11-01 09:28:03 -05:00
parent 54ba4b31a1
commit 187cb79265
7 changed files with 33 additions and 9 deletions
+14
View File
@@ -418,13 +418,27 @@ public class Schematics implements Loadable{
}
public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource){
placeLoadout(schem, x, y, team, resource, true);
}
public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource, boolean check){
Stile coreTile = schem.tiles.find(s -> s.block instanceof CoreBlock);
Seq<Tile> seq = new Seq<>();
if(coreTile == null) throw new IllegalArgumentException("Loadout schematic has no core tile!");
int ox = x - coreTile.x, oy = y - coreTile.y;
schem.tiles.each(st -> {
Tile tile = world.tile(st.x + ox, st.y + oy);
if(tile == null) return;
//check for blocks that are in the way.
if(check && !(st.block instanceof CoreBlock)){
seq.clear();
tile.getLinkedTilesAs(st.block, seq);
if(seq.contains(t -> !t.block().alwaysReplace)){
return;
}
}
tile.setBlock(st.block, team, st.rotation);
Object config = st.config;
+10 -1
View File
@@ -21,7 +21,7 @@ public class Universe{
private int turn;
private float turnCounter;
private Schematic lastLoadout;
private @Nullable Schematic lastLoadout;
private ItemSeq lastLaunchResources = new ItemSeq();
public Universe(){
@@ -92,6 +92,15 @@ public class Universe{
}
}
public void clearLoadoutInfo(){
lastLoadout = null;
lastLaunchResources = new ItemSeq();
Core.settings.remove("launch-resources-seq");
Core.settings.remove("lastloadout-core-shard");
Core.settings.remove("lastloadout-core-nucleus");
Core.settings.remove("lastloadout-core-foundation");
}
public ItemSeq getLaunchResources(){
lastLaunchResources = Core.settings.getJson("launch-resources-seq", ItemSeq.class, ItemSeq::new);
return lastLaunchResources;