Added new 'space' tile with shader / Added additional teleporter FX
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 198 B |
BIN
core/assets-raw/sprites/blocks/environment/space.png
Normal file
After Width: | Height: | Size: 156 B |
BIN
core/assets-raw/sprites/blocks/environment/spaceedge.png
Normal file
After Width: | Height: | Size: 198 B |
BIN
core/assets-raw/sprites/blocks/power/teleporter-top.png
Normal file
After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 622 B |
BIN
core/assets/maps/hole.mmap
Normal file
BIN
core/assets/maps/space.mmap
Normal file
77
core/assets/shaders/space.fragment
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#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 u_center;
|
||||||
|
uniform vec2 camerapos;
|
||||||
|
uniform vec2 screensize;
|
||||||
|
uniform float time;
|
||||||
|
|
||||||
|
varying vec4 v_color;
|
||||||
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
float round(float num, float f){
|
||||||
|
return float(int(num / f)) * f;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
ivec2 icoords = ivec2(int(c.x / v.x + camerapos.x), int(c.y / v.y + camerapos.y));
|
||||||
|
vec2 coords = vec2(float(icoords.x), float(icoords.y));
|
||||||
|
|
||||||
|
float stime = time / 5.0;
|
||||||
|
|
||||||
|
float mscl = 30.0;
|
||||||
|
float mth = 5.0;
|
||||||
|
|
||||||
|
//if there's something actually there
|
||||||
|
if(color.a > 0.01){
|
||||||
|
vec2 diff = camerapos + screensize/2.0 - u_center;
|
||||||
|
|
||||||
|
float dst = mod((distance(coords, camerapos + screensize/2.0 - diff/5.0) + time * 2.0 + snoise(coords / 100.0) * 10.0), 150.0);
|
||||||
|
|
||||||
|
if(dst < 40.0){
|
||||||
|
color = vec4(vec3(0.2), 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_FragColor = color;
|
||||||
|
}
|
89
core/assets/shaders/space2.fragment
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
precision mediump int;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
|
uniform vec2 u_center;
|
||||||
|
uniform vec2 camerapos;
|
||||||
|
uniform vec2 screensize;
|
||||||
|
uniform float time;
|
||||||
|
|
||||||
|
varying vec4 v_color;
|
||||||
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
const float tau = 6.28318530717958647692;
|
||||||
|
const float tscl = 0.5;
|
||||||
|
|
||||||
|
// Gamma correction
|
||||||
|
#define GAMMA (2.2)
|
||||||
|
|
||||||
|
vec3 ToLinear(vec3 col ){
|
||||||
|
// simulate a monitor, converting colour values into light values
|
||||||
|
return pow( col, vec3(GAMMA) );
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 ToGamma(vec3 col ){
|
||||||
|
// convert back into colour values, so the correct light will come out of the monitor
|
||||||
|
return pow( col, vec3(1.0/GAMMA) );
|
||||||
|
}
|
||||||
|
|
||||||
|
float srand(vec2 co){
|
||||||
|
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 Noise(ivec2 x ){
|
||||||
|
vec2 uv = (vec2(x)+0.5)/256.0;
|
||||||
|
return vec4(srand(uv), srand(uv + vec2(10.0, 0.0)), srand(uv + vec2(10.0, 0.0)), srand(uv + vec2(10.0, 10.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
vec4 resultc = texture2D(u_texture, v_texCoord.xy);
|
||||||
|
|
||||||
|
if(resultc.a > 0.0){
|
||||||
|
|
||||||
|
vec2 coords = v_texCoord.xy*screensize;
|
||||||
|
|
||||||
|
vec3 ray;
|
||||||
|
ray.xy = 2.0*(coords-screensize.xy*.5)/screensize.x;
|
||||||
|
ray.z = 1.0;
|
||||||
|
|
||||||
|
float literallyzero = 0.000000000001;
|
||||||
|
|
||||||
|
float offset = time/60.0*.5 * tscl + camerapos.x * u_center.x * resultc.r * literallyzero;
|
||||||
|
float speed2 = 0.3;
|
||||||
|
float speed = speed2+.1;
|
||||||
|
offset += .1;
|
||||||
|
offset *= 2.0;
|
||||||
|
|
||||||
|
vec3 col = vec3(0.0);
|
||||||
|
|
||||||
|
vec3 stp = ray/max(abs(ray.x),abs(ray.y));
|
||||||
|
|
||||||
|
vec3 pos = 2.0*stp+.5;
|
||||||
|
for ( int i=0; i < 20; i++){
|
||||||
|
float z = Noise(ivec2(pos.xy)).x;
|
||||||
|
z = fract(z-offset);
|
||||||
|
float d = 50.0*z-pos.z;
|
||||||
|
float w = pow(max(0.0,1.0-8.0*length(fract(pos.xy)-.5)),2.0);
|
||||||
|
vec3 c = max(vec3(0),vec3(1.0-abs(d+speed2*.5)/speed,1.0-abs(d)/speed,1.0-abs(d-speed2*.5)/speed));
|
||||||
|
col += 1.5*(1.0-z)*c*w;
|
||||||
|
pos += stp;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 color = ToGamma(col);
|
||||||
|
|
||||||
|
if(color.r > 0.3 && color.b > 0.3){
|
||||||
|
color = vec3(240.0, 245.0, 255.0) / 255.0;
|
||||||
|
}else{
|
||||||
|
color = vec3(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_FragColor = vec4(color,1.0);
|
||||||
|
}else{
|
||||||
|
gl_FragColor = vec4(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |
@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Fri Apr 06 16:57:38 EDT 2018
|
#Fri Apr 06 21:25:35 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=857
|
androidBuildCode=864
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
@ -21,6 +21,11 @@ public class Blocks {
|
|||||||
|
|
||||||
blockpart = new BlockPart(),
|
blockpart = new BlockPart(),
|
||||||
|
|
||||||
|
space = new Floor("space") {{
|
||||||
|
variants = 0;
|
||||||
|
drawLayer = DrawLayer.space;
|
||||||
|
}},
|
||||||
|
|
||||||
deepwater = new Floor("deepwater") {{
|
deepwater = new Floor("deepwater") {{
|
||||||
variants = 0;
|
variants = 0;
|
||||||
solid = true;
|
solid = true;
|
||||||
|
@ -5,7 +5,6 @@ import com.badlogic.gdx.math.MathUtils;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.content.blocks.ProductionBlocks;
|
|
||||||
import io.anuke.mindustry.io.Map;
|
import io.anuke.mindustry.io.Map;
|
||||||
import io.anuke.mindustry.io.MapIO;
|
import io.anuke.mindustry.io.MapIO;
|
||||||
import io.anuke.mindustry.io.Maps;
|
import io.anuke.mindustry.io.Maps;
|
||||||
@ -166,7 +165,7 @@ public class World extends Module{
|
|||||||
|
|
||||||
Entities.resizeTree(0, 0, width * tilesize, height * tilesize);
|
Entities.resizeTree(0, 0, width * tilesize, height * tilesize);
|
||||||
|
|
||||||
WorldGenerator.generate(tiles, MapIO.readTileData(map));
|
WorldGenerator.generate(tiles, MapIO.readTileData(map, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSeed(){
|
public int getSeed(){
|
||||||
|
@ -79,7 +79,7 @@ public class MapEditorDialog extends Dialog{
|
|||||||
ui.loadfrag.show();
|
ui.loadfrag.show();
|
||||||
Timers.run(3f, () -> {
|
Timers.run(3f, () -> {
|
||||||
try{
|
try{
|
||||||
MapTileData data = MapIO.readTileData(new DataInputStream(file.read()));
|
MapTileData data = MapIO.readTileData(new DataInputStream(file.read()), false);
|
||||||
|
|
||||||
editor.beginEdit(data);
|
editor.beginEdit(data);
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
|
@ -43,6 +43,17 @@ public enum DrawLayer {
|
|||||||
endShader(batch, Shaders.oil);
|
endShader(batch, Shaders.oil);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
space{
|
||||||
|
@Override
|
||||||
|
public void begin(CacheBatch batch){
|
||||||
|
beginShader(batch);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void end(CacheBatch batch){
|
||||||
|
endShader(batch, Shaders.space);
|
||||||
|
}
|
||||||
|
},
|
||||||
normal,
|
normal,
|
||||||
walls;
|
walls;
|
||||||
|
|
||||||
|
@ -19,4 +19,8 @@ public class Palette {
|
|||||||
public static final Color lancerLaser = Color.valueOf("a9d8ff");
|
public static final Color lancerLaser = Color.valueOf("a9d8ff");
|
||||||
|
|
||||||
public static final Color stoneGray = Color.valueOf("8f8f8f");
|
public static final Color stoneGray = Color.valueOf("8f8f8f");
|
||||||
|
|
||||||
|
public static final Color portalLight = Color.valueOf("9054ea");
|
||||||
|
public static final Color portal = Color.valueOf("6344d7");
|
||||||
|
public static final Color portalDark = Color.valueOf("3f3dac");
|
||||||
}
|
}
|
||||||
|
@ -10,17 +10,34 @@ import io.anuke.ucore.core.Timers;
|
|||||||
import io.anuke.ucore.graphics.Shader;
|
import io.anuke.ucore.graphics.Shader;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public class Shaders{
|
public class Shaders{
|
||||||
public static final Outline outline = new Outline();
|
public static final Outline outline = new Outline();
|
||||||
public static final Shield shield = new Shield();
|
public static final Shield shield = new Shield();
|
||||||
public static final SurfaceShader water = new SurfaceShader("water");
|
public static final SurfaceShader water = new SurfaceShader("water");
|
||||||
public static final SurfaceShader lava = new SurfaceShader("lava");
|
public static final SurfaceShader lava = new SurfaceShader("lava");
|
||||||
public static final SurfaceShader oil = new SurfaceShader("oil");
|
public static final SurfaceShader oil = new SurfaceShader("oil");
|
||||||
|
public static final Space space = new Space();
|
||||||
public static final UnitBuild build = new UnitBuild();
|
public static final UnitBuild build = new UnitBuild();
|
||||||
public static final Shader hit = new Shader("hit", "default");
|
public static final Shader hit = new Shader("hit", "default");
|
||||||
|
|
||||||
private static final Vector2 vec = new Vector2();
|
private static final Vector2 vec = new Vector2();
|
||||||
|
|
||||||
|
public static class Space extends SurfaceShader{
|
||||||
|
|
||||||
|
public Space(){
|
||||||
|
super("space2");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(){
|
||||||
|
super.apply();
|
||||||
|
shader.setUniformf("u_center", world.width() * tilesize/2f, world.height() * tilesize/2f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class UnitBuild extends Shader{
|
public static class UnitBuild extends Shader{
|
||||||
public float progress, time;
|
public float progress, time;
|
||||||
public Color color = new Color();
|
public Color color = new Color();
|
||||||
|
@ -90,20 +90,20 @@ public class MapIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**Reads tile data, skipping meta.*/
|
/**Reads tile data, skipping meta.*/
|
||||||
public static MapTileData readTileData(DataInputStream stream) throws IOException {
|
public static MapTileData readTileData(DataInputStream stream, boolean readOnly) throws IOException {
|
||||||
MapMeta meta = readMapMeta(stream);
|
MapMeta meta = readMapMeta(stream);
|
||||||
return readTileData(stream, meta);
|
return readTileData(stream, meta, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Does not skip meta. Call after reading meta.*/
|
/**Does not skip meta. Call after reading meta.*/
|
||||||
public static MapTileData readTileData(DataInputStream stream, MapMeta meta) throws IOException {
|
public static MapTileData readTileData(DataInputStream stream, MapMeta meta, boolean readOnly) throws IOException {
|
||||||
byte[] bytes = new byte[stream.available()];
|
byte[] bytes = new byte[stream.available()];
|
||||||
stream.read(bytes);
|
stream.read(bytes);
|
||||||
return new MapTileData(bytes, meta.width, meta.height, meta.blockMap);
|
return new MapTileData(bytes, meta.width, meta.height, meta.blockMap, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Reads tile data, skipping meta tags.*/
|
/**Reads tile data, skipping meta tags.*/
|
||||||
public static MapTileData readTileData(Map map){
|
public static MapTileData readTileData(Map map, boolean readOnly){
|
||||||
try {
|
try {
|
||||||
InputStream stream;
|
InputStream stream;
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public class MapIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataInputStream ds = new DataInputStream(stream);
|
DataInputStream ds = new DataInputStream(stream);
|
||||||
MapTileData data = MapIO.readTileData(ds);
|
MapTileData data = MapIO.readTileData(ds, readOnly);
|
||||||
ds.close();
|
ds.close();
|
||||||
return data;
|
return data;
|
||||||
}catch (IOException e){
|
}catch (IOException e){
|
||||||
|
@ -15,21 +15,34 @@ public class MapTileData {
|
|||||||
private final ByteBuffer buffer;
|
private final ByteBuffer buffer;
|
||||||
private final TileDataMarker tile = new TileDataMarker();
|
private final TileDataMarker tile = new TileDataMarker();
|
||||||
private final int width, height;
|
private final int width, height;
|
||||||
|
private final boolean readOnly;
|
||||||
|
|
||||||
private final IntIntMap map;
|
private IntIntMap map;
|
||||||
|
|
||||||
public MapTileData(int width, int height){
|
public MapTileData(int width, int height){
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.map = null;
|
this.map = null;
|
||||||
|
this.readOnly = false;
|
||||||
buffer = ByteBuffer.allocate(width * height * TILE_SIZE);
|
buffer = ByteBuffer.allocate(width * height * TILE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapTileData(byte[] bytes, int width, int height, IntIntMap mapping){
|
public MapTileData(byte[] bytes, int width, int height, IntIntMap mapping, boolean readOnly){
|
||||||
buffer = ByteBuffer.wrap(bytes);
|
buffer = ByteBuffer.wrap(bytes);
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.map = mapping;
|
this.map = mapping;
|
||||||
|
this.readOnly = readOnly;
|
||||||
|
|
||||||
|
if(mapping != null && !readOnly){
|
||||||
|
for(int i = 0; i < width * height; i ++){
|
||||||
|
read();
|
||||||
|
buffer.position(i * TILE_SIZE);
|
||||||
|
write();
|
||||||
|
}
|
||||||
|
buffer.position(0);
|
||||||
|
this.map = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] toArray(){
|
public byte[] toArray(){
|
||||||
@ -96,6 +109,7 @@ public class MapTileData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void write(ByteBuffer buffer){
|
public void write(ByteBuffer buffer){
|
||||||
|
if(readOnly) throw new IllegalArgumentException("This data is read-only.");
|
||||||
buffer.put(floor);
|
buffer.put(floor);
|
||||||
buffer.put(wall);
|
buffer.put(wall);
|
||||||
byte rt = Bits.packByte(rotation, team);
|
byte rt = Bits.packByte(rotation, team);
|
||||||
|
@ -17,7 +17,7 @@ import static io.anuke.mindustry.Vars.mapExtension;
|
|||||||
|
|
||||||
public class Maps implements Disposable{
|
public class Maps implements Disposable{
|
||||||
/**List of all built-in maps.*/
|
/**List of all built-in maps.*/
|
||||||
private static final String[] defaultMapNames = {"test"};
|
private static final String[] defaultMapNames = {"test", "space", "hole"};
|
||||||
/**Tile format version.*/
|
/**Tile format version.*/
|
||||||
private static final int version = 0;
|
private static final int version = 0;
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class Maps implements Disposable{
|
|||||||
DataInputStream ds = new DataInputStream(file.read());
|
DataInputStream ds = new DataInputStream(file.read());
|
||||||
MapMeta meta = MapIO.readMapMeta(ds);
|
MapMeta meta = MapIO.readMapMeta(ds);
|
||||||
Map map = new Map(file.nameWithoutExtension(), meta, custom);
|
Map map = new Map(file.nameWithoutExtension(), meta, custom);
|
||||||
if(!headless) map.texture = new Texture(MapIO.generatePixmap(MapIO.readTileData(ds, meta)));
|
if(!headless) map.texture = new Texture(MapIO.generatePixmap(MapIO.readTileData(ds, meta, true)));
|
||||||
|
|
||||||
maps.put(map.name, map);
|
maps.put(map.name, map);
|
||||||
allMaps.add(map);
|
allMaps.add(map);
|
||||||
|
@ -5,40 +5,36 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import com.badlogic.gdx.utils.ObjectSet;
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
import io.anuke.mindustry.content.fx.Fx;
|
import io.anuke.mindustry.content.fx.Fx;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.net.Net;
|
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.BarType;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.PowerBlock;
|
import io.anuke.mindustry.world.blocks.types.PowerBlock;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Fill;
|
import io.anuke.ucore.graphics.Fill;
|
||||||
|
import io.anuke.ucore.graphics.Hue;
|
||||||
import io.anuke.ucore.graphics.Lines;
|
import io.anuke.ucore.graphics.Lines;
|
||||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Strings;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.syncBlockState;
|
|
||||||
|
|
||||||
public class Teleporter extends PowerBlock{
|
public class Teleporter extends PowerBlock{
|
||||||
public static final Color[] colorArray = {Color.ROYAL, Color.ORANGE, Color.SCARLET, Color.FOREST,
|
public static final Color[] colorArray = {Color.ROYAL, Color.ORANGE, Color.SCARLET, Color.LIME,
|
||||||
Color.PURPLE, Color.GOLD, Color.PINK, Color.BLACK};
|
Color.PURPLE, Color.GOLD, Color.PINK, Color.LIGHT_GRAY};
|
||||||
public static final int colors = colorArray.length;
|
public static final int colors = colorArray.length;
|
||||||
|
|
||||||
private static ObjectSet<Tile>[] teleporters = new ObjectSet[colors];
|
private static ObjectSet<Tile>[] teleporters = new ObjectSet[colors];
|
||||||
|
private static Color color = new Color();
|
||||||
private static byte lastColor = 0;
|
private static byte lastColor = 0;
|
||||||
|
|
||||||
private Array<Tile> removal = new Array<>();
|
private Array<Tile> removal = new Array<>();
|
||||||
private Array<Tile> returns = new Array<>();
|
private Array<Tile> returns = new Array<>();
|
||||||
|
|
||||||
protected float powerPerItem = 5f;
|
|
||||||
protected float warmupTime = 80f;
|
protected float warmupTime = 80f;
|
||||||
protected Effect teleportEffect = Fx.none;
|
protected Effect teleportEffect = Fx.none;
|
||||||
|
|
||||||
@ -55,6 +51,7 @@ public class Teleporter extends PowerBlock{
|
|||||||
health = 80;
|
health = 80;
|
||||||
powerCapacity = 30f;
|
powerCapacity = 30f;
|
||||||
size = 3;
|
size = 3;
|
||||||
|
itemCapacity = 150;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,16 +63,9 @@ public class Teleporter extends PowerBlock{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBars(){
|
|
||||||
super.setBars();
|
|
||||||
bars.remove(BarType.inventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStats(){
|
public void setStats(){
|
||||||
super.setStats();
|
super.setStats();
|
||||||
stats.add("poweritem", Strings.toFixed(powerPerItem, 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,16 +79,37 @@ public class Teleporter extends PowerBlock{
|
|||||||
TeleporterEntity entity = tile.entity();
|
TeleporterEntity entity = tile.entity();
|
||||||
|
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
Draw.color(colorArray[entity.color]);
|
Color target = colorArray[entity.color];
|
||||||
|
float ss = 0.5f;
|
||||||
|
float bs = 0.2f;
|
||||||
|
|
||||||
|
Draw.color(Hue.shift(Hue.multiply(color.set(target), 1, ss), 2, 0));
|
||||||
Draw.rect("teleporter-top", tile.drawx(), tile.drawy());
|
Draw.rect("teleporter-top", tile.drawx(), tile.drawy());
|
||||||
Draw.reset();
|
|
||||||
|
|
||||||
Draw.color(Color.WHITE);
|
//Draw.color(Palette.portal);
|
||||||
|
Draw.color(Hue.shift(Hue.multiply(color.set(target), 1, ss), 2, 0));
|
||||||
|
|
||||||
Fill.circle(tile.drawx(), tile.drawy(), 7f);
|
Fill.circle(tile.drawx(), tile.drawy(), 7f + Mathf.absin(Timers.time()+55, 8f, 1f));
|
||||||
|
|
||||||
Draw.color(Color.PURPLE);
|
//Draw.color(Palette.portalDark);
|
||||||
|
Draw.color(Hue.shift(Hue.multiply(color.set(target), 1, ss), 2, -bs));
|
||||||
|
|
||||||
|
Fill.circle(tile.drawx(), tile.drawy(), 2f + Mathf.absin(Timers.time(), 7f, 3f));
|
||||||
|
|
||||||
|
for(int i = 0; i < 11; i ++){
|
||||||
|
Lines.swirl(tile.drawx(), tile.drawy(),
|
||||||
|
2f + i/3f + Mathf.sin(Timers.time() - i *75, 20f + i, 3f),
|
||||||
|
0.3f + Mathf.sin(Timers.time() + i *33, 10f + i, 0.1f),
|
||||||
|
Timers.time() * (1f + Mathf.randomSeedRange(i + 1, 1f)) + Mathf.randomSeedRange(i, 360f));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw.color(Palette.portalLight);
|
||||||
|
Draw.color(Hue.shift(Hue.multiply(color.set(target), 1, ss), 2, bs));
|
||||||
|
|
||||||
|
Lines.stroke(2f);
|
||||||
|
Lines.circle(tile.drawx(), tile.drawy(), 7f + Mathf.absin(Timers.time()+55, 8f, 1f));
|
||||||
|
Lines.stroke(1f);
|
||||||
|
|
||||||
for(int i = 0; i < 11; i ++){
|
for(int i = 0; i < 11; i ++){
|
||||||
Lines.swirl(tile.drawx(), tile.drawy(),
|
Lines.swirl(tile.drawx(), tile.drawy(),
|
||||||
@ -119,6 +130,10 @@ public class Teleporter extends PowerBlock{
|
|||||||
if(entity.inventory.totalItems() > 0){
|
if(entity.inventory.totalItems() > 0){
|
||||||
tryDump(tile);
|
tryDump(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(entity.inventory.totalItems() == itemCapacity && entity.power.amount >= powerCapacity){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -135,7 +150,7 @@ public class Teleporter extends PowerBlock{
|
|||||||
cont.margin(4);
|
cont.margin(4);
|
||||||
cont.marginBottom(5);
|
cont.marginBottom(5);
|
||||||
|
|
||||||
cont.add().colspan(4).height(105f);
|
cont.add().colspan(4).height(145f);
|
||||||
cont.row();
|
cont.row();
|
||||||
|
|
||||||
for(int i = 0; i < colors; i ++){
|
for(int i = 0; i < colors; i ++){
|
||||||
@ -155,26 +170,10 @@ public class Teleporter extends PowerBlock{
|
|||||||
table.add(cont);
|
table.add(cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleItem(Item item, Tile tile, Tile source){
|
|
||||||
TeleporterEntity entity = tile.entity();
|
|
||||||
|
|
||||||
Array<Tile> links = findLinks(tile);
|
|
||||||
|
|
||||||
if(links.size > 0){
|
|
||||||
if(!syncBlockState || Net.server() || !Net.active()){
|
|
||||||
Tile target = links.random();
|
|
||||||
target.entity.inventory.addItem(item, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.power.amount -= powerPerItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
TeleporterEntity entity = tile.entity();
|
TeleporterEntity entity = tile.entity();
|
||||||
return !(source.block() instanceof Teleporter) && entity.power.amount >= powerPerItem && findLinks(tile).size > 0;
|
return entity.inventory.totalItems() < itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|