Added support for export/import of all basic terrain as image
This commit is contained in:
@@ -39,10 +39,7 @@ public class ContentLoader{
|
||||
new TechTree(),
|
||||
new Weathers(),
|
||||
new Planets(),
|
||||
new Zones(),
|
||||
|
||||
//these are not really content classes, but this makes initialization easier
|
||||
new LegacyColorMapper(),
|
||||
new Zones()
|
||||
};
|
||||
|
||||
public ContentLoader(){
|
||||
@@ -134,13 +131,15 @@ public class ContentLoader{
|
||||
if(blocks().size > i){
|
||||
int color = pixmap.getPixel(i, 0);
|
||||
|
||||
if(color == 0) continue;
|
||||
if(color == 0 || color == 255) continue;
|
||||
|
||||
Block block = block(i);
|
||||
Color.rgba8888ToColor(block.color, color);
|
||||
Color.rgba8888ToColor(block.minimapColor, color);
|
||||
block.hasColor = true;
|
||||
}
|
||||
}
|
||||
pixmap.dispose();
|
||||
ColorMapper.load();
|
||||
}
|
||||
|
||||
public void dispose(){
|
||||
|
||||
@@ -2,11 +2,12 @@ package mindustry.core;
|
||||
|
||||
import arc.*;
|
||||
import arc.Input.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.serialization.*;
|
||||
import mindustry.mod.*;
|
||||
import mindustry.net.*;
|
||||
@@ -15,7 +16,7 @@ import mindustry.type.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
import static mindustry.Vars.mobile;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public interface Platform{
|
||||
|
||||
@@ -103,6 +104,32 @@ public interface Platform{
|
||||
default void shareFile(Fi file){
|
||||
}
|
||||
|
||||
default void export(String name, String extension, FileWriter writer){
|
||||
if(!ios){
|
||||
platform.showFileChooser(false, extension, file -> {
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
writer.write(file);
|
||||
}catch(Throwable e){
|
||||
ui.showException(e);
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
Fi result = Core.files.local(name+ "." + extension);
|
||||
writer.write(result);
|
||||
platform.shareFile(result);
|
||||
}catch(Throwable e){
|
||||
ui.showException(e);
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a file chooser.
|
||||
* @param cons Selection listener
|
||||
@@ -130,4 +157,8 @@ public interface Platform{
|
||||
/** Stops forcing the app into landscape orientation.*/
|
||||
default void endForceLandscape(){
|
||||
}
|
||||
|
||||
interface FileWriter{
|
||||
void write(Fi file) throws Throwable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class MapEditor{
|
||||
reset();
|
||||
|
||||
createTiles(pixmap.getWidth(), pixmap.getHeight());
|
||||
load(() -> MapIO.readPixmap(pixmap, tiles()));
|
||||
load(() -> MapIO.readImage(pixmap, tiles()));
|
||||
renderer.resize(width(), height());
|
||||
}
|
||||
|
||||
|
||||
@@ -87,62 +87,42 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
t.row();
|
||||
|
||||
t.addImageTextButton("$editor.import", Icon.download, () ->
|
||||
createDialog("$editor.import",
|
||||
"$editor.importmap", "$editor.importmap.description", Icon.download, (Runnable)loadDialog::show,
|
||||
"$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() ->
|
||||
platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> {
|
||||
maps.tryCatchMapError(() -> {
|
||||
if(MapIO.isImage(file)){
|
||||
ui.showInfo("$editor.errorimage");
|
||||
}else{
|
||||
editor.beginEdit(MapIO.createMap(file, true));
|
||||
}
|
||||
});
|
||||
})),
|
||||
|
||||
"$editor.importimage", "$editor.importimage.description", Icon.fileImage, (Runnable)() ->
|
||||
platform.showFileChooser(true, "png", file ->
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
Pixmap pixmap = new Pixmap(file);
|
||||
editor.beginEdit(pixmap);
|
||||
pixmap.dispose();
|
||||
}catch(Exception e){
|
||||
ui.showException("$editor.errorload", e);
|
||||
Log.err(e);
|
||||
}
|
||||
})))
|
||||
);
|
||||
|
||||
t.addImageTextButton("$editor.export", Icon.upload, () -> {
|
||||
if(!ios){
|
||||
platform.showFileChooser(false, mapExtension, file -> {
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
if(!editor.getTags().containsKey("name")){
|
||||
editor.getTags().put("name", file.nameWithoutExtension());
|
||||
}
|
||||
MapIO.writeMap(file, editor.createMap(file));
|
||||
}catch(Exception e){
|
||||
ui.showException("$editor.errorsave", e);
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
Fi result = Core.files.local(editor.getTags().get("name", "unknown") + "." + mapExtension);
|
||||
MapIO.writeMap(result, editor.createMap(result));
|
||||
platform.shareFile(result);
|
||||
}catch(Exception e){
|
||||
ui.showException("$editor.errorsave", e);
|
||||
Log.err(e);
|
||||
t.addImageTextButton("$editor.import", Icon.download, () -> createDialog("$editor.import",
|
||||
"$editor.importmap", "$editor.importmap.description", Icon.download, (Runnable)loadDialog::show,
|
||||
"$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() ->
|
||||
platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> {
|
||||
maps.tryCatchMapError(() -> {
|
||||
if(MapIO.isImage(file)){
|
||||
ui.showInfo("$editor.errorimage");
|
||||
}else{
|
||||
editor.beginEdit(MapIO.createMap(file, true));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
})),
|
||||
|
||||
"$editor.importimage", "$editor.importimage.description", Icon.fileImage, (Runnable)() ->
|
||||
platform.showFileChooser(true, "png", file ->
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
Pixmap pixmap = new Pixmap(file);
|
||||
editor.beginEdit(pixmap);
|
||||
pixmap.dispose();
|
||||
}catch(Exception e){
|
||||
ui.showException("$editor.errorload", e);
|
||||
Log.err(e);
|
||||
}
|
||||
})))
|
||||
);
|
||||
|
||||
t.addImageTextButton("$editor.export", Icon.upload, () -> createDialog("$editor.export",
|
||||
"$editor.exportfile", "$editor.exportfile.description", Icon.file,
|
||||
(Runnable)() -> platform.export(editor.getTags().get("name", "unknown"), mapExtension, file -> MapIO.writeMap(file, editor.createMap(file))),
|
||||
"$editor.exportimage", "$editor.exportimage.description", Icon.fileImage,
|
||||
(Runnable)() -> platform.export(editor.getTags().get("name", "unknown"), "png", file -> {
|
||||
Pixmap out = MapIO.writeImage(editor.tiles());
|
||||
file.writePNG(out);
|
||||
out.dispose();
|
||||
})));
|
||||
});
|
||||
|
||||
menu.cont.row();
|
||||
|
||||
@@ -66,7 +66,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
|
||||
if(isGrounded() && floor.isLiquid){
|
||||
if((splashTimer += Mathf.dst(deltaX(), deltaY())) >= 7f){
|
||||
floor.walkEffect.at(x, y, 0, floor.color);
|
||||
floor.walkEffect.at(x, y, 0, floor.minimapColor);
|
||||
splashTimer = 0f;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
drownTime += Time.delta() * 1f / floor.drownTime;
|
||||
drownTime = Mathf.clamp(drownTime);
|
||||
if(Mathf.chance(Time.delta() * 0.05f)){
|
||||
floor.drownUpdateEffect.at(x, y, 0f, floor.color);
|
||||
floor.drownUpdateEffect.at(x, y, 0f, floor.minimapColor);
|
||||
}
|
||||
|
||||
//TODO is the netClient check necessary?
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package mindustry.io;
|
||||
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.Pixmap.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.LegacyColorMapper.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
|
||||
import java.io.*;
|
||||
@@ -147,32 +147,43 @@ public class MapIO{
|
||||
if(wall.synthetic()){
|
||||
return team.color.rgba();
|
||||
}
|
||||
return Color.rgba8888(wall.solid ? wall.color : ore == Blocks.air ? floor.color : ore.color);
|
||||
return Color.rgba8888(wall.solid ? wall.minimapColor : ore == Blocks.air ? floor.minimapColor : ore.minimapColor);
|
||||
}
|
||||
|
||||
/** Reads a pixmap in the 3.5 pixmap format. */
|
||||
public static void readPixmap(Pixmap pixmap, Tiles tiles){
|
||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
||||
for(int y = 0; y < pixmap.getHeight(); y++){
|
||||
int color = pixmap.getPixel(x, pixmap.getHeight() - 1 - y);
|
||||
LegacyBlock block = LegacyColorMapper.get(color);
|
||||
Tile tile = tiles.getn(x, y);
|
||||
public static Pixmap writeImage(Tiles tiles){
|
||||
Pixmap pix = new Pixmap(tiles.width, tiles.height);
|
||||
for(Tile tile : tiles){
|
||||
int color = tile.block().hasColor && !tile.block().synthetic() ? tile.block().minimapColor.rgba() : tile.floor().minimapColor.rgba();
|
||||
pix.draw(tile.x, tiles.height - 1 - tile.y, color);
|
||||
}
|
||||
return pix;
|
||||
}
|
||||
|
||||
tile.setFloor(block.floor);
|
||||
tile.setBlock(block.wall);
|
||||
if(block.ore != null) tile.setOverlay(block.ore);
|
||||
public static void readImage(Pixmap pixmap, Tiles tiles){
|
||||
for(Tile tile : tiles){
|
||||
int color = pixmap.getPixel(tile.x, pixmap.getHeight() - 1 - tile.y);
|
||||
Block block = ColorMapper.get(color);
|
||||
|
||||
//place core
|
||||
if(color == Color.rgba8888(Color.green)){
|
||||
//actual core parts
|
||||
tile.setBlock(Blocks.coreShard);
|
||||
tile.setTeam(Team.sharded);
|
||||
if(block.isFloor()){
|
||||
tile.setFloor(block.asFloor());
|
||||
}else if(block.isMultiblock()){
|
||||
tile.set(block, Team.derelict);
|
||||
}else{
|
||||
tile.setBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
//guess at floors by grabbing a random adjacent floor
|
||||
for(Tile tile : tiles){
|
||||
if(tile.floor() == Blocks.air && tile.block() != Blocks.air){
|
||||
for(Point2 p : Geometry.d4){
|
||||
Tile other = tiles.get(tile.x + p.x, tile.y + p.y);
|
||||
if(other != null && other.floor() != Blocks.air){
|
||||
tile.setFloor(other.floor());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface TileProvider{
|
||||
Tile get(int x, int y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TestPlanetGenerator extends PlanetGenerator{
|
||||
public Color getColor(Vec3 position){
|
||||
Block block = getBlock(position);
|
||||
//replace salt with sand color
|
||||
return block == Blocks.salt ? Blocks.sand.color : block.color;
|
||||
return block == Blocks.salt ? Blocks.sand.minimapColor : block.minimapColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -231,7 +231,7 @@ public class UnitType extends UnlockableContent{
|
||||
Floor floor = unit.floorOn();
|
||||
|
||||
if(floor.isLiquid){
|
||||
Draw.color(Color.white, floor.color, 0.5f);
|
||||
Draw.color(Color.white, floor.minimapColor, 0.5f);
|
||||
}
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
@@ -242,7 +242,7 @@ public class UnitType extends UnlockableContent{
|
||||
}
|
||||
|
||||
if(floor.isLiquid){
|
||||
Draw.color(Color.white, floor.color, unit.drownTime() * 0.4f);
|
||||
Draw.color(Color.white, floor.minimapColor, unit.drownTime() * 0.4f);
|
||||
}else{
|
||||
Draw.color(Color.white);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ public class UnitType extends UnlockableContent{
|
||||
public void applyColor(Unitc unit){
|
||||
Draw.mixcol(Color.white, unit.hitTime());
|
||||
if(unit.drownTime() > 0 && unit.floorOn().isDeep()){
|
||||
Draw.mixcol(unit.floorOn().color, unit.drownTime() * 0.8f);
|
||||
Draw.mixcol(unit.floorOn().minimapColor, unit.drownTime() * 0.8f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.game.Saves.*;
|
||||
@@ -15,7 +14,6 @@ import mindustry.gen.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.io.SaveIO.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Styles;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -70,6 +68,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
|
||||
title.table(t -> {
|
||||
t.right();
|
||||
t.defaults().size(40f);
|
||||
|
||||
t.addImageButton(Icon.save, Styles.emptytogglei, () -> {
|
||||
slot.setAutosave(!slot.isAutosave());
|
||||
@@ -89,26 +88,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
});
|
||||
}).right();
|
||||
|
||||
t.addImageButton(Icon.save, Styles.emptyi, () -> {
|
||||
if(!ios){
|
||||
platform.showFileChooser(false, saveExtension, file -> {
|
||||
try{
|
||||
slot.exportFile(file);
|
||||
setup();
|
||||
}catch(IOException e){
|
||||
ui.showException("save.export.fail", e);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
try{
|
||||
Fi file = Core.files.local("save-" + slot.getName() + "." + saveExtension);
|
||||
slot.exportFile(file);
|
||||
platform.shareFile(file);
|
||||
}catch(Exception e){
|
||||
ui.showException("save.export.fail", e);
|
||||
}
|
||||
}
|
||||
}).right();
|
||||
t.addImageButton(Icon.export, Styles.emptyi, () -> platform.export("save-" + slot.getName(), saveExtension, slot::exportFile)).right();
|
||||
|
||||
}).padRight(-10).growX();
|
||||
}).growX().colspan(2);
|
||||
|
||||
@@ -162,11 +162,6 @@ public class PlanetDialog extends FloatingDialog{
|
||||
|
||||
if(true)
|
||||
Draw.batch(projector, () -> {
|
||||
if(hovered != null){
|
||||
setPlane(hovered);
|
||||
Fonts.outline.draw("" + hovered.id, 0, 0, Align.center);
|
||||
}
|
||||
|
||||
if(selected != null){
|
||||
setPlane(selected);
|
||||
stable.draw();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.files.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.Texture.*;
|
||||
import arc.graphics.g2d.*;
|
||||
@@ -216,25 +215,8 @@ public class SchematicsDialog extends FloatingDialog{
|
||||
}).marginLeft(12f);
|
||||
t.row();
|
||||
t.addImageTextButton("$schematic.exportfile", Icon.export, style, () -> {
|
||||
if(!ios){
|
||||
platform.showFileChooser(false, schematicExtension, file -> {
|
||||
dialog.hide();
|
||||
try{
|
||||
Schematics.write(s, file);
|
||||
}catch(Throwable e){
|
||||
ui.showException(e);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
dialog.hide();
|
||||
try{
|
||||
Fi file = Core.files.local(s.name() + "." + schematicExtension);
|
||||
Schematics.write(s, file);
|
||||
platform.shareFile(file);
|
||||
}catch(Throwable e){
|
||||
ui.showException(e);
|
||||
}
|
||||
}
|
||||
dialog.hide();
|
||||
platform.export(s.name(), schematicExtension, file -> Schematics.write(s, file));
|
||||
}).marginLeft(12f);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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