Custom launch items

This commit is contained in:
Anuken
2020-06-28 13:33:53 -04:00
parent 6386cae19a
commit b3f29f100d
12 changed files with 85 additions and 36 deletions

View File

@@ -399,6 +399,13 @@ public class Schematics implements Loadable{
}
}
/** Places the last launch loadout at the coordinates and fills it with the launch resources. */
public static void placeLaunchLoadout(int x, int y){
placeLoadout(universe.getLastLoadout(), x, y);
if(world.tile(x, y).build == null) throw new RuntimeException("No core at loadout coordinates!");
world.tile(x, y).build.items.add(universe.getLaunchResources());
}
public static void placeLoadout(Schematic schem, int x, int y){
placeLoadout(schem, x, y, state.rules.defaultTeam, Blocks.oreCopper);
}

View File

@@ -20,7 +20,9 @@ public class Universe{
private float secondCounter;
private int turn;
private float turnCounter;
private Schematic lastLoadout = Loadouts.basicShard;
private Seq<ItemStack> lastLaunchResources = new Seq<>();
public Universe(){
load();
@@ -75,6 +77,16 @@ public class Universe{
}
}
public Seq<ItemStack> getLaunchResources(){
lastLaunchResources = Core.settings.getJson("launch-resources", Seq.class, ItemStack.class, Seq::new);
return lastLaunchResources;
}
public void updateLaunchResources(Seq<ItemStack> stacks){
this.lastLaunchResources = stacks;
Core.settings.putJson("launch-resources", ItemStack.class, lastLaunchResources);
}
/** Updates selected loadout for future deployment. */
public void updateLoadout(CoreBlock block, Schematic schem){
Core.settings.put("lastloadout-" + block.name, schem.file == null ? "" : schem.file.nameWithoutExtension());