Tar shader / Spritesheet split / Font cleanup
8
core/assets-raw/sprites/blocks/environment/pack.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
duplicatePadding: true,
|
||||||
|
combineSubdirectories: true,
|
||||||
|
flattenPaths: true,
|
||||||
|
maxWidth: 2048,
|
||||||
|
maxHeight: 2048,
|
||||||
|
fast: true,
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 195 B |
|
Before Width: | Height: | Size: 578 B After Width: | Height: | Size: 578 B |
|
After Width: | Height: | Size: 1.0 KiB |
BIN
core/assets-raw/sprites_replacement/editor/clear-editor.png
Normal file
|
After Width: | Height: | Size: 871 B |
8
core/assets-raw/sprites_replacement/editor/pack.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
duplicatePadding: true,
|
||||||
|
combineSubdirectories: true,
|
||||||
|
flattenPaths: true,
|
||||||
|
maxWidth: 2048,
|
||||||
|
maxHeight: 2048,
|
||||||
|
fast: true,
|
||||||
|
}
|
||||||
79
core/assets/shaders/tar.fragment
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
precision mediump int;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define s1 vec4(63.0, 63.0, 63.0, 255.0) / 255.0
|
||||||
|
|
||||||
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
|
uniform vec2 camerapos;
|
||||||
|
uniform vec2 screensize;
|
||||||
|
uniform float time;
|
||||||
|
|
||||||
|
varying vec4 v_color;
|
||||||
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); }
|
||||||
|
|
||||||
|
float snoise(vec2 v){
|
||||||
|
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
|
||||||
|
-0.577350269189626, 0.024390243902439);
|
||||||
|
vec2 i = floor(v + dot(v, C.yy) );
|
||||||
|
vec2 x0 = v - i + dot(i, C.xx);
|
||||||
|
vec2 i1;
|
||||||
|
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
||||||
|
vec4 x12 = x0.xyxy + C.xxzz;
|
||||||
|
x12.xy -= i1;
|
||||||
|
i = mod(i, 289.0);
|
||||||
|
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
|
||||||
|
+ i.x + vec3(0.0, i1.x, 1.0 ));
|
||||||
|
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy),
|
||||||
|
dot(x12.zw,x12.zw)), 0.0);
|
||||||
|
m = m*m ;
|
||||||
|
m = m*m ;
|
||||||
|
vec3 x = 2.0 * fract(p * C.www) - 1.0;
|
||||||
|
vec3 h = abs(x) - 0.5;
|
||||||
|
vec3 ox = floor(x + 0.5);
|
||||||
|
vec3 a0 = x - ox;
|
||||||
|
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
|
||||||
|
vec3 g;
|
||||||
|
g.x = a0.x * x0.x + h.x * x0.y;
|
||||||
|
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
||||||
|
return 130.0 * dot(m, g);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
|
||||||
|
vec2 c = v_texCoord.xy;
|
||||||
|
vec4 color = texture2D(u_texture, c);
|
||||||
|
|
||||||
|
vec2 v = vec2(1.0/screensize.x, 1.0/screensize.y);
|
||||||
|
vec2 coords = vec2(c.x / v.x + camerapos.x, c.y / v.y + camerapos.y);
|
||||||
|
|
||||||
|
float stime = time / 5.0;
|
||||||
|
|
||||||
|
float mscl = 30.0;
|
||||||
|
float mth = 5.0;
|
||||||
|
|
||||||
|
vec4 old = color;
|
||||||
|
color = texture2D(u_texture, c + vec2(sin(stime/3.0 + coords.y/0.75) * v.x, 0.0)) * vec4(0.9, 0.9, 1, 1.0);
|
||||||
|
color.a = 1.0;
|
||||||
|
|
||||||
|
if(color.r < 0.01){
|
||||||
|
color = old;
|
||||||
|
}
|
||||||
|
|
||||||
|
float n1 = snoise(coords / 22.0 + vec2(-time) / 540.0);
|
||||||
|
float n2 = snoise((coords + vec2(632.0)) / 8.0 + vec2(0.0, time) / 510.0);
|
||||||
|
|
||||||
|
float r = (n1 + n2) / 2.0;
|
||||||
|
|
||||||
|
if(r < -0.3 && r > -0.6){
|
||||||
|
color *= 1.4;
|
||||||
|
color.a = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gl_FragColor = color;
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 208 B |
|
Before Width: | Height: | Size: 510 B After Width: | Height: | Size: 509 B |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.1 MiB |
BIN
core/assets/sprites/sprites2.png
Normal file
|
After Width: | Height: | Size: 217 KiB |
BIN
core/assets/sprites/sprites3.png
Normal file
|
After Width: | Height: | Size: 216 KiB |
@@ -36,7 +36,7 @@ public class Blocks implements ContentList{
|
|||||||
//environment
|
//environment
|
||||||
air, part, spawn, deepwater, water, tar, stone, craters, charr, sand, ice, snow,
|
air, part, spawn, deepwater, water, tar, stone, craters, charr, sand, ice, snow,
|
||||||
holostone, rocks, icerocks, cliffs, pine, whiteTree, whiteTreeDead, sporeCluster,
|
holostone, rocks, icerocks, cliffs, pine, whiteTree, whiteTreeDead, sporeCluster,
|
||||||
iceSnow, sandWater, duneRocks, sandRocks, stainedRocks, stainedStone, stainedRocksRed, stainedStoneRed, stainedRocksYellow, stainedStoneYellow, stainedBoulder,
|
iceSnow, sandWater, duneRocks, sandRocks, stainedRocks, stainedStone, stainedRocksRed, stainedStoneRed, stainedRocksYellow, stainedStoneYellow, stainedBoulder, grass,
|
||||||
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks,
|
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks,
|
||||||
|
|
||||||
//crafting
|
//crafting
|
||||||
@@ -141,7 +141,7 @@ public class Blocks implements ContentList{
|
|||||||
variants = 0;
|
variants = 0;
|
||||||
liquidDrop = Liquids.oil;
|
liquidDrop = Liquids.oil;
|
||||||
isLiquid = true;
|
isLiquid = true;
|
||||||
cacheLayer = CacheLayer.oil;
|
cacheLayer = CacheLayer.tar;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
stone = new Floor("stone"){{
|
stone = new Floor("stone"){{
|
||||||
@@ -179,6 +179,10 @@ public class Blocks implements ContentList{
|
|||||||
edgeStyle = "blocky";
|
edgeStyle = "blocky";
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
grass = new Floor("grass"){{
|
||||||
|
|
||||||
|
}};
|
||||||
|
|
||||||
iceSnow = new Floor("ice-snow"){{
|
iceSnow = new Floor("ice-snow"){{
|
||||||
variants = 3;
|
variants = 3;
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -63,10 +63,11 @@ public class Control implements ApplicationListener{
|
|||||||
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
|
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
|
||||||
content.initialize(Content::load);
|
content.initialize(Content::load);
|
||||||
|
|
||||||
|
/*
|
||||||
if(Core.atlas.getTextures().size != 1){
|
if(Core.atlas.getTextures().size != 1){
|
||||||
throw new IllegalStateException("Atlas must be exactly one texture. " +
|
throw new IllegalStateException("Atlas must be exactly one texture. " +
|
||||||
"If more textures are used, the map editor will not display them correctly.");
|
"If more textures are used, the map editor will not display them correctly.");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
data.load();
|
data.load();
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,6 @@ public class UI implements ApplicationListener{
|
|||||||
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/font.ttf"));
|
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/font.ttf"));
|
||||||
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
||||||
param.size = (int)(9*2 * Math.max(Unit.dp.scl(1f), 0.5f));
|
param.size = (int)(9*2 * Math.max(Unit.dp.scl(1f), 0.5f));
|
||||||
//param.size = (int)(14*2 * Math.max(Unit.dp.scl(1f), 0.5f));
|
|
||||||
param.shadowColor = Color.DARK_GRAY;
|
param.shadowColor = Color.DARK_GRAY;
|
||||||
param.shadowOffsetY = 2;
|
param.shadowOffsetY = 2;
|
||||||
param.incremental = true;
|
param.incremental = true;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import io.anuke.arc.Core;
|
|||||||
import io.anuke.arc.collection.IntSet;
|
import io.anuke.arc.collection.IntSet;
|
||||||
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
|
import io.anuke.arc.graphics.Texture;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
@@ -14,7 +15,6 @@ import io.anuke.mindustry.game.Team;
|
|||||||
import io.anuke.mindustry.graphics.IndexedRenderer;
|
import io.anuke.mindustry.graphics.IndexedRenderer;
|
||||||
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Block.Icon;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
@@ -26,9 +26,11 @@ public class MapRenderer implements Disposable{
|
|||||||
private IntSet delayedUpdates = new IntSet();
|
private IntSet delayedUpdates = new IntSet();
|
||||||
private MapEditor editor;
|
private MapEditor editor;
|
||||||
private int width, height;
|
private int width, height;
|
||||||
|
private Texture texture;
|
||||||
|
|
||||||
public MapRenderer(MapEditor editor){
|
public MapRenderer(MapEditor editor){
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
|
texture = Core.atlas.find("clear-editor").getTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resize(int width, int height){
|
public void resize(int width, int height){
|
||||||
@@ -52,7 +54,6 @@ public class MapRenderer implements Disposable{
|
|||||||
updateAll();
|
updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void draw(float tx, float ty, float tw, float th){
|
public void draw(float tx, float ty, float tw, float th){
|
||||||
Draw.flush();
|
Draw.flush();
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ public class MapRenderer implements Disposable{
|
|||||||
mesh.getTransformMatrix().setToTranslation(tx, ty).scale(tw / (width * tilesize), th / (height * tilesize));
|
mesh.getTransformMatrix().setToTranslation(tx, ty).scale(tw / (width * tilesize), th / (height * tilesize));
|
||||||
mesh.setProjectionMatrix(Draw.proj());
|
mesh.setProjectionMatrix(Draw.proj());
|
||||||
|
|
||||||
mesh.render(Core.atlas.getTextures().first());
|
mesh.render(texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +117,7 @@ public class MapRenderer implements Disposable{
|
|||||||
int idxDecal = (wx % chunksize) + (wy % chunksize) * chunksize + chunksize * chunksize;
|
int idxDecal = (wx % chunksize) + (wy % chunksize) * chunksize + chunksize * chunksize;
|
||||||
|
|
||||||
if(bw != 0 && (wall.synthetic() || wall == Blocks.part)){
|
if(bw != 0 && (wall.synthetic() || wall == Blocks.part)){
|
||||||
region = wall.icon(Icon.full) == Core.atlas.find("____") ? Core.atlas.find("clear") : wall.icon(Icon.full);
|
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
|
||||||
|
|
||||||
if(wall.rotate){
|
if(wall.rotate){
|
||||||
mesh.draw(idxWall, region,
|
mesh.draw(idxWall, region,
|
||||||
@@ -129,7 +130,7 @@ public class MapRenderer implements Disposable{
|
|||||||
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
|
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
region = floor.variantRegions()[Mathf.randomSeed(idxWall, 0, floor.variantRegions().length-1)];
|
region = floor.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, floor.editorVariantRegions().length-1)];
|
||||||
|
|
||||||
mesh.draw(idxWall, region, wx * tilesize, wy * tilesize, 8, 8);
|
mesh.draw(idxWall, region, wx * tilesize, wy * tilesize, 8, 8);
|
||||||
}
|
}
|
||||||
@@ -138,13 +139,13 @@ public class MapRenderer implements Disposable{
|
|||||||
|
|
||||||
if(wall.update || wall.destructible){
|
if(wall.update || wall.destructible){
|
||||||
mesh.setColor(team.color);
|
mesh.setColor(team.color);
|
||||||
region = Core.atlas.find("block-border");
|
region = Core.atlas.find("block-border-editor");
|
||||||
}else if(!wall.synthetic() && bw != 0){
|
}else if(!wall.synthetic() && bw != 0){
|
||||||
region = wall.icon(Icon.full) == Core.atlas.find("____") ? Core.atlas.find("clear") : wall.icon(Icon.full);
|
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
|
||||||
offsetX = tilesize/2f - region.getWidth()/2f * Draw.scl;
|
offsetX = tilesize/2f - region.getWidth()/2f * Draw.scl;
|
||||||
offsetY = tilesize/2f - region.getHeight()/2f * Draw.scl;
|
offsetY = tilesize/2f - region.getHeight()/2f * Draw.scl;
|
||||||
}else{
|
}else{
|
||||||
region = Core.atlas.find("clear");
|
region = Core.atlas.find("clear-editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh.draw(idxDecal, region,
|
mesh.draw(idxDecal, region,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry.graphics;
|
|||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.graphics.glutils.Shader;
|
||||||
|
|
||||||
import static io.anuke.arc.Core.camera;
|
import static io.anuke.arc.Core.camera;
|
||||||
import static io.anuke.mindustry.Vars.renderer;
|
import static io.anuke.mindustry.Vars.renderer;
|
||||||
@@ -11,31 +12,25 @@ public enum CacheLayer{
|
|||||||
water{
|
water{
|
||||||
@Override
|
@Override
|
||||||
public void begin(){
|
public void begin(){
|
||||||
if(!Core.settings.getBool("animatedwater")) return;
|
beginShader();
|
||||||
|
|
||||||
renderer.blocks.floor.endc();
|
|
||||||
renderer.shieldBuffer.begin();
|
|
||||||
Core.graphics.clear(Color.CLEAR);
|
|
||||||
renderer.blocks.floor.beginc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void end(){
|
public void end(){
|
||||||
if(!Core.settings.getBool("animatedwater")) return;
|
endShader(Shaders.water);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tar{
|
||||||
|
@Override
|
||||||
|
public void begin(){
|
||||||
|
beginShader();
|
||||||
|
}
|
||||||
|
|
||||||
renderer.blocks.floor.endc();
|
@Override
|
||||||
renderer.shieldBuffer.end();
|
public void end(){
|
||||||
|
endShader(Shaders.tar);
|
||||||
Draw.shader(Shaders.water);
|
|
||||||
Draw.rect(Draw.wrap(renderer.shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
|
||||||
Draw.shader();
|
|
||||||
|
|
||||||
renderer.blocks.floor.beginc();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lava,
|
|
||||||
oil,
|
|
||||||
space,
|
|
||||||
normal,
|
normal,
|
||||||
walls;
|
walls;
|
||||||
|
|
||||||
@@ -46,4 +41,26 @@ public enum CacheLayer{
|
|||||||
public void end(){
|
public void end(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void beginShader(){
|
||||||
|
if(!Core.settings.getBool("animatedwater")) return;
|
||||||
|
|
||||||
|
renderer.blocks.floor.endc();
|
||||||
|
renderer.shieldBuffer.begin();
|
||||||
|
Core.graphics.clear(Color.CLEAR);
|
||||||
|
renderer.blocks.floor.beginc();
|
||||||
|
}
|
||||||
|
|
||||||
|
void endShader(Shader shader){
|
||||||
|
if(!Core.settings.getBool("animatedwater")) return;
|
||||||
|
|
||||||
|
renderer.blocks.floor.endc();
|
||||||
|
renderer.shieldBuffer.end();
|
||||||
|
|
||||||
|
Draw.shader(shader);
|
||||||
|
Draw.rect(Draw.wrap(renderer.shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
|
||||||
|
Draw.shader();
|
||||||
|
|
||||||
|
renderer.blocks.floor.beginc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class Shaders{
|
|||||||
public static UnitBuild build;
|
public static UnitBuild build;
|
||||||
public static FogShader fog;
|
public static FogShader fog;
|
||||||
public static MenuShader menu;
|
public static MenuShader menu;
|
||||||
public static SurfaceShader water;
|
public static SurfaceShader water, tar;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
shadow = new Shadow();
|
shadow = new Shadow();
|
||||||
@@ -24,6 +24,7 @@ public class Shaders{
|
|||||||
fog = new FogShader();
|
fog = new FogShader();
|
||||||
menu = new MenuShader();
|
menu = new MenuShader();
|
||||||
water = new SurfaceShader("water");
|
water = new SurfaceShader("water");
|
||||||
|
tar = new SurfaceShader("tar");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MenuShader extends LoadShader{
|
public static class MenuShader extends LoadShader{
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class DeployDialog extends FloatingDialog{
|
|||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).size(200f).get();
|
}).size(230f).get();
|
||||||
b[0] = button;
|
b[0] = button;
|
||||||
|
|
||||||
String color = "[lightgray]";
|
String color = "[lightgray]";
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import io.anuke.arc.function.Function;
|
|||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
import io.anuke.arc.graphics.g2d.Lines;
|
||||||
|
import io.anuke.arc.graphics.g2d.TextureAtlas.AtlasRegion;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
@@ -110,8 +111,8 @@ public class Block extends BlockStorage{
|
|||||||
protected Array<Tile> tempTiles = new Array<>();
|
protected Array<Tile> tempTiles = new Array<>();
|
||||||
protected TextureRegion[] icons = new TextureRegion[Icon.values().length];
|
protected TextureRegion[] icons = new TextureRegion[Icon.values().length];
|
||||||
protected TextureRegion[] generatedIcons;
|
protected TextureRegion[] generatedIcons;
|
||||||
protected TextureRegion[] variantRegions;
|
protected TextureRegion[] variantRegions, editorVariantRegions;
|
||||||
protected TextureRegion region;
|
protected TextureRegion region, editorIcon;
|
||||||
|
|
||||||
public Block(String name){
|
public Block(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -513,6 +514,24 @@ public class Block extends BlockStorage{
|
|||||||
return icons[icon.ordinal()];
|
return icons[icon.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**Never use outside of the editor!*/
|
||||||
|
public TextureRegion editorIcon(){
|
||||||
|
if(editorIcon == null) editorIcon = Core.atlas.find(name + "-icon-editor");
|
||||||
|
return editorIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Never use outside of the editor!*/
|
||||||
|
public TextureRegion[] editorVariantRegions(){
|
||||||
|
if(editorVariantRegions == null){
|
||||||
|
editorVariantRegions = new TextureRegion[variantRegions.length];
|
||||||
|
for(int i = 0; i < variantRegions.length; i ++){
|
||||||
|
AtlasRegion region = (AtlasRegion)variantRegions[i];
|
||||||
|
editorVariantRegions[i] = Core.atlas.find("editor-" + region.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return editorVariantRegions;
|
||||||
|
}
|
||||||
|
|
||||||
protected TextureRegion[] generateIcons(){
|
protected TextureRegion[] generateIcons(){
|
||||||
return new TextureRegion[]{Core.atlas.find(name)};
|
return new TextureRegion[]{Core.atlas.find(name)};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import io.anuke.arc.graphics.g2d.Draw;
|
|||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
|
|
||||||
public class Rock extends Block{
|
public class Rock extends Block{
|
||||||
protected TextureRegion[] regions;
|
|
||||||
protected int variants;
|
protected int variants;
|
||||||
|
|
||||||
public Rock(String name){
|
public Rock(String name){
|
||||||
@@ -20,17 +19,12 @@ public class Rock extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
if(variants > 0){
|
if(variants > 0){
|
||||||
Draw.rect(regions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, regions.length - 1))], tile.worldx(), tile.worldy());
|
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
||||||
}else{
|
}else{
|
||||||
Draw.rect(region, tile.worldx(), tile.worldy());
|
Draw.rect(region, tile.worldx(), tile.worldy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureRegion[] variantRegions(){
|
|
||||||
return regions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextureRegion[] generateIcons(){
|
public TextureRegion[] generateIcons(){
|
||||||
return variants == 0 ? super.generateIcons() : new TextureRegion[]{Core.atlas.find(name + "1")};
|
return variants == 0 ? super.generateIcons() : new TextureRegion[]{Core.atlas.find(name + "1")};
|
||||||
@@ -41,10 +35,10 @@ public class Rock extends Block{
|
|||||||
super.load();
|
super.load();
|
||||||
|
|
||||||
if(variants > 0){
|
if(variants > 0){
|
||||||
regions = new TextureRegion[variants];
|
variantRegions = new TextureRegion[variants];
|
||||||
|
|
||||||
for(int i = 0; i < variants; i++){
|
for(int i = 0; i < variants; i++){
|
||||||
regions[i] = Core.atlas.find(name + (i + 1));
|
variantRegions[i] = Core.atlas.find(name + (i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class StaticWall extends Rock{
|
|||||||
Draw.rect(large, tile.worldx() + tilesize/2f, tile.worldy() + tilesize/2f);
|
Draw.rect(large, tile.worldx() + tilesize/2f, tile.worldy() + tilesize/2f);
|
||||||
}
|
}
|
||||||
}else if(variants > 0){
|
}else if(variants > 0){
|
||||||
Draw.rect(regions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, regions.length - 1))], tile.worldx(), tile.worldy());
|
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
||||||
}else{
|
}else{
|
||||||
Draw.rect(region, tile.worldx(), tile.worldy());
|
Draw.rect(region, tile.worldx(), tile.worldy());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.awt.image.BufferedImage
|
|||||||
|
|
||||||
def outFolder = "../core/assets-raw/sprites_out/"
|
def outFolder = "../core/assets-raw/sprites_out/"
|
||||||
def genFolder = "../core/assets-raw/sprites_out/generated/"
|
def genFolder = "../core/assets-raw/sprites_out/generated/"
|
||||||
|
def packFile = "../core/assets-raw/sprites/pack.json"
|
||||||
def doAntialias = !project.hasProperty("disableAntialias")
|
def doAntialias = !project.hasProperty("disableAntialias")
|
||||||
|
|
||||||
def antialias = {File file ->
|
def antialias = {File file ->
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import io.anuke.mindustry.world.blocks.OreBlock;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Vars.content;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
@@ -26,11 +27,24 @@ public class Generators {
|
|||||||
|
|
||||||
ImagePacker.generate("block-icons", () -> {
|
ImagePacker.generate("block-icons", () -> {
|
||||||
Image colors = new Image(256, 1);
|
Image colors = new Image(256, 1);
|
||||||
Color outlineColor = new Color(0, 0, 0, 0.2f);
|
Color outlineColor = new Color(0, 0, 0, 0.3f);
|
||||||
|
|
||||||
for(Block block : content.blocks()){
|
for(Block block : content.blocks()){
|
||||||
TextureRegion[] regions = block.getGeneratedIcons();
|
TextureRegion[] regions = block.getGeneratedIcons();
|
||||||
|
|
||||||
|
try{
|
||||||
|
if(block instanceof Floor){
|
||||||
|
block.load();
|
||||||
|
for(TextureRegion region : block.variantRegions()){
|
||||||
|
GenRegion gen = (GenRegion)region;
|
||||||
|
if(gen.path == null) continue;
|
||||||
|
Files.copy(gen.path, Paths.get("../editor/editor-" + gen.path.getFileName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(IOException e){
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
if(regions.length == 0){
|
if(regions.length == 0){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -91,6 +105,8 @@ public class Generators {
|
|||||||
image.save(block.name + "-icon-full");
|
image.save(block.name + "-icon-full");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
image.save("../editor/" + block.name + "-icon-editor");
|
||||||
|
|
||||||
for(Icon icon : Icon.values()){
|
for(Icon icon : Icon.values()){
|
||||||
if(icon.size == 0 || (icon.size == image.width() && icon.size == image.height())) continue;
|
if(icon.size == 0 || (icon.size == image.width() && icon.size == image.height())) continue;
|
||||||
Image scaled = new Image(icon.size, icon.size);
|
Image scaled = new Image(icon.size, icon.size);
|
||||||
@@ -212,7 +228,7 @@ public class Generators {
|
|||||||
}
|
}
|
||||||
|
|
||||||
image.draw(ImagePacker.get(item.name + (i+1)));
|
image.draw(ImagePacker.get(item.name + (i+1)));
|
||||||
image.save("ore-" + item.name + "-" + base.name + (i+1));
|
image.save("../blocks/environment/ore-" + item.name + "-" + base.name + (i+1));
|
||||||
|
|
||||||
//save icons
|
//save icons
|
||||||
image.save(block.name + "-icon-full");
|
image.save(block.name + "-icon-full");
|
||||||
@@ -247,7 +263,7 @@ public class Generators {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.save(floor.name + "-edge");
|
result.save("../blocks/environment/" + floor.name + "-edge");
|
||||||
|
|
||||||
}catch(Exception ignored){}
|
}catch(Exception ignored){}
|
||||||
}
|
}
|
||||||
|
|||||||