No erekir launch schems / Tech tree fix

This commit is contained in:
Anuken
2022-01-28 15:52:06 -05:00
parent 98f17e15ae
commit 0579c9e6c9
6 changed files with 46 additions and 26 deletions

View File

@@ -58,6 +58,7 @@ public class Schematics implements Loadable{
private OrderedMap<Schematic, FrameBuffer> previews = new OrderedMap<>();
private ObjectSet<Schematic> errored = new ObjectSet<>();
private ObjectMap<CoreBlock, Seq<Schematic>> loadouts = new ObjectMap<>();
private ObjectMap<CoreBlock, Schematic> defaultLoadouts = new ObjectMap<>();
private FrameBuffer shadowBuffer;
private Texture errorTexture;
private long lastClearTime;
@@ -288,19 +289,28 @@ public class Schematics implements Loadable{
return loadouts;
}
public @Nullable Schematic getDefaultLoadout(CoreBlock block){
return defaultLoadouts.get(block);
}
/** Checks a schematic for deployment validity and adds it to the cache. */
private void checkLoadout(Schematic s, boolean validate){
private void checkLoadout(Schematic s, boolean customSchem){
Stile core = s.tiles.find(t -> t.block instanceof CoreBlock);
if(core == null) return;
int cores = s.tiles.count(t -> t.block instanceof CoreBlock);
int maxSize = getMaxLaunchSize(core.block);
//make sure a core exists, and that the schematic is small enough.
if((validate && (s.width > maxSize || s.height > maxSize
if((customSchem && (s.width > maxSize || s.height > maxSize
|| s.tiles.contains(t -> t.block.buildVisibility == BuildVisibility.sandboxOnly || !t.block.unlocked()) || cores > 1))) return;
//place in the cache
loadouts.get((CoreBlock)core.block, Seq::new).add(s);
//save non-custom loadout
if(!customSchem){
defaultLoadouts.put((CoreBlock)core.block, s);
}
}
public int getMaxLaunchSize(Block block){