Auto-generate block paletted team regions for mods

This commit is contained in:
Anuken
2021-07-31 21:31:36 -04:00
parent 84b69a683a
commit fc80c23dde
3 changed files with 39 additions and 1 deletions

View File

@@ -886,6 +886,36 @@ public class Block extends UnlockableContent{
}
}
//generate paletted team regions
if(teamRegion.found()){
for(Team team : Team.all){
//if there's an override, don't generate anything
if(team.hasPalette && !Core.atlas.has(name + "-team-" + team.name)){
var base = Core.atlas.getPixmap(teamRegion);
Pixmap out = new Pixmap(base.width, base.height);
for(int x = 0; x < base.width; x++){
for(int y = 0; y < base.height; y++){
int color = base.get(x, y);
int index = color == 0xffffffff ? 0 : color == 0xdcc6c6ff ? 1 : color == 0x9d7f7fff ? 2 : -1;
out.setRaw(x, y, index == -1 ? base.get(x, y) : team.palettei[index]);
}
}
if(Core.settings.getBool("linear")){
Pixmaps.bleed(out);
}
packer.add(PageType.main, name + "-team-" + team.name, out);
}
}
teamRegions = new TextureRegion[Team.all.length];
for(Team team : Team.all){
teamRegions[team.id] = teamRegion.found() && team.hasPalette ? Core.atlas.find(name + "-team-" + team.name, teamRegion) : teamRegion;
}
}
Pixmap last = null;
var gen = icons();