Batched building health update packet

This commit is contained in:
Anuken
2022-06-22 18:30:59 -04:00
parent 2de706cc6d
commit 1a98a66f23
11 changed files with 135 additions and 54 deletions

View File

@@ -285,9 +285,6 @@ public class Generators{
for(Block block : content.blocks()){
if(block.isAir() || block instanceof ConstructBlock || block instanceof OreBlock || block instanceof LegacyBlock) continue;
block.load();
block.loadIcon();
Seq<TextureRegion> toOutline = new Seq<>();
block.getRegionsToOutline(toOutline);
@@ -481,6 +478,37 @@ public class Generators{
}
});
MultiPacker packer = new MultiPacker(){
@Override
public void add(PageType type, String name, PixmapRegion region, int[] splits, int[] pads){
String prefix = type == PageType.main ? "" : "../" + type.name() + "/";
Log.info("@ | @x@", prefix + name, region.width, region.height);
//save(region.pixmap, prefix + name);
}
};
//TODO !!!!! currently just an experiment
if(false)
generate("all-icons", () -> {
for(Seq<Content> arr : content.getContentMap()){
for(Content cont : arr){
if(cont instanceof UnlockableContent && !(cont instanceof Planet)){
UnlockableContent unlock = (UnlockableContent)cont;
if(unlock.generateIcons){
try{
unlock.createIcons(packer);
}catch(IllegalArgumentException e){
Log.err(e);
Log.err("Skip: @", unlock.name);
}
}
}
}
}
});
generate("unit-icons", () -> content.units().each(type -> {
if(type.internal) return; //internal hidden units don't generate
@@ -488,9 +516,6 @@ public class Generators{
try{
Unit sample = type.constructor.get();
type.load();
type.loadIcon();
type.init();
Func<Pixmap, Pixmap> outline = i -> i.outline(type.outlineColor, 3);
Cons<TextureRegion> outliner = t -> {
@@ -703,7 +728,6 @@ public class Generators{
generate("ore-icons", () -> {
content.blocks().<OreBlock>each(b -> b instanceof OreBlock, ore -> {
ore.load();
int shadowColor = Color.rgba8888(0, 0, 0, 0.3f);
for(int i = 0; i < ore.variants; i++){

View File

@@ -79,6 +79,11 @@ public class ImagePacker{
return find(name);
}
@Override
public PixmapRegion getPixmap(AtlasRegion region){
return new PixmapRegion(get(region.name));
}
@Override
public boolean has(String s){
return cache.containsKey(s);
@@ -88,6 +93,7 @@ public class ImagePacker{
Draw.scl = 1f / Core.atlas.find("scale_marker").width;
Time.mark();
Vars.content.load();
Generators.run();
Log.info("&ly[Generator]&lc Total time to generate: &lg@&lcms", Time.elapsed());