Added support for export/import of all basic terrain as image
This commit is contained in:
@@ -102,7 +102,9 @@ public class Block extends BlockStorage{
|
||||
* The color of this block when displayed on the minimap or map preview.
|
||||
* Do not set manually! This is overriden when loading for most blocks.
|
||||
*/
|
||||
public Color color = new Color(0, 0, 0, 1);
|
||||
public Color minimapColor = new Color(0, 0, 0, 1);
|
||||
/** Whether this block has a minimap color. */
|
||||
public boolean hasColor = false;
|
||||
/** Whether units target this block. */
|
||||
public boolean targetable = true;
|
||||
/** Whether the overdrive core has any effect on this block. */
|
||||
@@ -763,7 +765,7 @@ public class Block extends BlockStorage{
|
||||
|
||||
if(!synthetic()){
|
||||
PixmapRegion image = Core.atlas.getPixmap((AtlasRegion)icon(Cicon.full));
|
||||
color.set(image.getPixel(image.width/2, image.height/2));
|
||||
minimapColor.set(image.getPixel(image.width/2, image.height/2));
|
||||
}
|
||||
|
||||
getGeneratedIcons();
|
||||
|
||||
24
core/src/mindustry/world/ColorMapper.java
Normal file
24
core/src/mindustry/world/ColorMapper.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package mindustry.world;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
|
||||
public class ColorMapper{
|
||||
private static final IntMap<Block> color2block = new IntMap<>();
|
||||
|
||||
public static Block get(int color){
|
||||
return color2block.get(color, Blocks.air);
|
||||
}
|
||||
|
||||
public static void load(){
|
||||
color2block.clear();
|
||||
|
||||
for(Block block : Vars.content.blocks()){
|
||||
color2block.put(block.minimapColor.rgba(), block);
|
||||
}
|
||||
|
||||
color2block.put(Color.rgba8888(0, 0, 0, 1), Blocks.air);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package mindustry.world;
|
||||
|
||||
import arc.struct.IntMap;
|
||||
import arc.graphics.Color;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.world.blocks.Floor;
|
||||
|
||||
public class LegacyColorMapper implements ContentList{
|
||||
private static IntMap<LegacyBlock> blockMap = new IntMap<>();
|
||||
private static LegacyBlock defaultValue;
|
||||
|
||||
public static LegacyBlock get(int color){
|
||||
return blockMap.get(color, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
defaultValue = new LegacyBlock(Blocks.stone, Blocks.air);
|
||||
|
||||
map("ff0000", Blocks.stone, Blocks.air, Blocks.spawn);
|
||||
map("00ff00", Blocks.stone);
|
||||
map("323232", Blocks.stone);
|
||||
map("646464", Blocks.stone, Blocks.rocks);
|
||||
map("50965a", Blocks.grass);
|
||||
map("5ab464", Blocks.grass, Blocks.pine);
|
||||
map("506eb4", Blocks.water);
|
||||
map("465a96", Blocks.deepwater);
|
||||
map("252525", Blocks.ignarock);
|
||||
map("575757", Blocks.ignarock, Blocks.duneRocks);
|
||||
map("988a67", Blocks.sand);
|
||||
map("e5d8bb", Blocks.sand, Blocks.duneRocks);
|
||||
map("c2d1d2", Blocks.snow);
|
||||
map("c4e3e7", Blocks.ice);
|
||||
map("f7feff", Blocks.snow, Blocks.snowrocks);
|
||||
map("6e501e", Blocks.holostone);
|
||||
map("ed5334", Blocks.magmarock);
|
||||
map("292929", Blocks.tar);
|
||||
map("c3a490", Blocks.stone, Blocks.air, Blocks.oreCopper);
|
||||
map("161616", Blocks.stone, Blocks.air, Blocks.oreCoal);
|
||||
map("6277bc", Blocks.stone, Blocks.air, Blocks.oreTitanium);
|
||||
map("83bc58", Blocks.stone, Blocks.air, Blocks.oreThorium);
|
||||
}
|
||||
|
||||
private void map(String color, Block block, Block wall, Block ore){
|
||||
blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall, ore));
|
||||
}
|
||||
|
||||
private void map(String color, Block block, Block wall){
|
||||
blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall));
|
||||
}
|
||||
|
||||
private void map(String color, Block block){
|
||||
blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, Blocks.air));
|
||||
}
|
||||
|
||||
public static class LegacyBlock{
|
||||
public final Floor floor;
|
||||
public final Block wall;
|
||||
public final Block ore;
|
||||
|
||||
public LegacyBlock(Block floor, Block wall){
|
||||
this(floor, wall, Blocks.air);
|
||||
}
|
||||
|
||||
public LegacyBlock(Block floor, Block wall, Block ore){
|
||||
this.floor = (Floor)floor;
|
||||
this.wall = wall;
|
||||
this.ore = ore;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class Cliff extends Block{
|
||||
int r = tile.rotation();
|
||||
for(int i = 0; i < 8; i++){
|
||||
if((r & (1 << i)) != 0){
|
||||
Draw.color(Tmp.c1.set(tile.floor().color).mul(1.3f + (i >= 4 ? -0.4f : 0.3f)));
|
||||
Draw.color(Tmp.c1.set(tile.floor().minimapColor).mul(1.3f + (i >= 4 ? -0.4f : 0.3f)));
|
||||
Draw.rect(region, tile.worldx(), tile.worldy(), 11f, 11f, i * 45f);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,6 @@ public class Cliff extends Block{
|
||||
|
||||
@Override
|
||||
public int minimapColor(Tile tile){
|
||||
return Tmp.c1.set(tile.floor().color).mul(1.2f).rgba();
|
||||
return Tmp.c1.set(tile.floor().minimapColor).mul(1.2f).rgba();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class Floor extends Block{
|
||||
if(wall == null) wall = Blocks.air;
|
||||
|
||||
if(decoration == Blocks.air){
|
||||
decoration = content.blocks().min(b -> b instanceof Rock && b.breakable ? color.diff(b.color) : Float.POSITIVE_INFINITY);
|
||||
decoration = content.blocks().min(b -> b instanceof Rock && b.breakable ? minimapColor.diff(b.minimapColor) : Float.POSITIVE_INFINITY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class Floor extends Block{
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tile other = tile.getNearby(i);
|
||||
if(other != null && doEdge(other.floor(), sameLayer)){
|
||||
Color color = other.floor().color;
|
||||
Color color = other.floor().minimapColor;
|
||||
Draw.color(color.r, color.g, color.b, 1f);
|
||||
Draw.rect(edgeRegion, tile.worldx(), tile.worldy(), i*90);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class OreBlock extends OverlayFloor{
|
||||
this.localizedName = ore.localizedName;
|
||||
this.itemDrop = ore;
|
||||
this.variants = 3;
|
||||
this.color.set(ore.color);
|
||||
this.minimapColor.set(ore.color);
|
||||
}
|
||||
|
||||
/** For mod use only!*/
|
||||
@@ -31,7 +31,7 @@ public class OreBlock extends OverlayFloor{
|
||||
public void setup(Item ore){
|
||||
this.localizedName = ore.localizedName;
|
||||
this.itemDrop = ore;
|
||||
this.color.set(ore.color);
|
||||
this.minimapColor.set(ore.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user