mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-15 18:27:36 +07:00
Auto-generate block paletted team regions for mods
This commit is contained in:
@ -17,6 +17,7 @@ public class Team implements Comparable<Team>{
|
|||||||
public final int id;
|
public final int id;
|
||||||
public final Color color;
|
public final Color color;
|
||||||
public final Color[] palette;
|
public final Color[] palette;
|
||||||
|
public final int[] palettei = new int[3];
|
||||||
public String emoji = "";
|
public String emoji = "";
|
||||||
public boolean hasPalette;
|
public boolean hasPalette;
|
||||||
public String name;
|
public String name;
|
||||||
@ -61,6 +62,10 @@ public class Team implements Comparable<Team>{
|
|||||||
palette[0] = color;
|
palette[0] = color;
|
||||||
palette[1] = color.cpy().mul(0.75f);
|
palette[1] = color.cpy().mul(0.75f);
|
||||||
palette[2] = color.cpy().mul(0.5f);
|
palette[2] = color.cpy().mul(0.5f);
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++){
|
||||||
|
palettei[i] = palette[i].rgba();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Specifies a 3-color team palette. */
|
/** Specifies a 3-color team palette. */
|
||||||
@ -70,6 +75,9 @@ public class Team implements Comparable<Team>{
|
|||||||
palette[0] = pal1;
|
palette[0] = pal1;
|
||||||
palette[1] = pal2;
|
palette[1] = pal2;
|
||||||
palette[2] = pal3;
|
palette[2] = pal3;
|
||||||
|
for(int i = 0; i < 3; i++){
|
||||||
|
palettei[i] = palette[i].rgba();
|
||||||
|
}
|
||||||
hasPalette = true;
|
hasPalette = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
Pixmap last = null;
|
||||||
|
|
||||||
var gen = icons();
|
var gen = icons();
|
||||||
|
@ -244,7 +244,7 @@ public class Generators{
|
|||||||
teamr.each((x, y) -> {
|
teamr.each((x, y) -> {
|
||||||
int color = teamr.getRaw(x, y);
|
int color = teamr.getRaw(x, y);
|
||||||
int index = color == 0xffffffff ? 0 : color == 0xdcc6c6ff ? 1 : color == 0x9d7f7fff ? 2 : -1;
|
int index = color == 0xffffffff ? 0 : color == 0xdcc6c6ff ? 1 : color == 0x9d7f7fff ? 2 : -1;
|
||||||
out.setRaw(x, y, index == -1 ? teamr.getRaw(x, y) : team.palette[index].rgba());
|
out.setRaw(x, y, index == -1 ? teamr.getRaw(x, y) : team.palettei[index]);
|
||||||
});
|
});
|
||||||
save(out, block.name + "-team-" + team.name);
|
save(out, block.name + "-team-" + team.name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user