@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user