Basic crater map / Spray tool / Crater floor / canProduce()
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/environment/craters1.png
Normal file
BIN
core/assets-raw/sprites/blocks/environment/craters1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets-raw/sprites/blocks/environment/craters2.png
Normal file
BIN
core/assets-raw/sprites/blocks/environment/craters2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets-raw/sprites/blocks/environment/craters3.png
Normal file
BIN
core/assets-raw/sprites/blocks/environment/craters3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets-raw/sprites/ui/icons/icon-spray.png
Normal file
BIN
core/assets-raw/sprites/ui/icons/icon-spray.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 920 B |
BIN
core/assets/maps/craters.mmap
Normal file
BIN
core/assets/maps/craters.mmap
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 989 KiB After Width: | Height: | Size: 992 KiB |
@@ -32,7 +32,7 @@ public class Blocks implements ContentList{
|
|||||||
public static Block
|
public static Block
|
||||||
|
|
||||||
//environment
|
//environment
|
||||||
air, blockpart, spawn, space, metalfloor, deepwater, water, tar, stone, blackstone, dirt, sand, ice, snow,
|
air, blockpart, spawn, space, metalfloor, deepwater, water, tar, stone, craters, blackstone, dirt, sand, ice, snow,
|
||||||
grass, shrub, rock, icerock, blackrock, rocks,
|
grass, shrub, rock, icerock, blackrock, rocks,
|
||||||
|
|
||||||
//crafting
|
//crafting
|
||||||
@@ -76,9 +76,7 @@ public class Blocks implements ContentList{
|
|||||||
public void load(){
|
public void load(){
|
||||||
//region environment
|
//region environment
|
||||||
|
|
||||||
air = new Floor("air"){
|
air = new Floor("air"){{
|
||||||
{
|
|
||||||
blend = false;
|
|
||||||
alwaysReplace = true;
|
alwaysReplace = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +102,6 @@ public class Blocks implements ContentList{
|
|||||||
variants = 0;
|
variants = 0;
|
||||||
cacheLayer = CacheLayer.space;
|
cacheLayer = CacheLayer.space;
|
||||||
solid = true;
|
solid = true;
|
||||||
blend = false;
|
|
||||||
minimapColor = Color.valueOf("000001");
|
minimapColor = Color.valueOf("000001");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@@ -152,9 +149,11 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
stone = new Floor("stone"){{
|
stone = new Floor("stone"){{
|
||||||
hasOres = true;
|
hasOres = true;
|
||||||
blends = block -> block != this && !(block instanceof OreBlock);
|
|
||||||
minimapColor = Color.valueOf("323232");
|
minimapColor = Color.valueOf("323232");
|
||||||
playerUnmineable = true;
|
}};
|
||||||
|
|
||||||
|
craters = new Floor("craters"){{
|
||||||
|
minimapColor = Color.valueOf("323232");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
blackstone = new Floor("blackstone"){{
|
blackstone = new Floor("blackstone"){{
|
||||||
@@ -828,7 +827,6 @@ public class Blocks implements ContentList{
|
|||||||
launchThreshold = 500;
|
launchThreshold = 500;
|
||||||
launchTime = 60f * 10;
|
launchTime = 60f * 10;
|
||||||
launchChunkSize = 100;
|
launchChunkSize = 100;
|
||||||
alwaysUnlocked = true;
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
vault = new Vault("vault"){{
|
vault = new Vault("vault"){{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class Zones implements ContentList{
|
|||||||
}};
|
}};
|
||||||
}};
|
}};
|
||||||
|
|
||||||
craters = new Zone("craters", new MapGenerator("groundZero", 1)){{ //TODO implement
|
craters = new Zone("craters", new MapGenerator("craters", 1){{ distortion = 1.44f; }}){{ //TODO implement
|
||||||
deployCost = ItemStack.with(Items.copper, 300);
|
deployCost = ItemStack.with(Items.copper, 300);
|
||||||
startingItems = ItemStack.with(Items.copper, 200);
|
startingItems = ItemStack.with(Items.copper, 200);
|
||||||
conditionWave = 15;
|
conditionWave = 15;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public enum EditorTool{
|
|||||||
editor.draw(x, y, Blocks.air);
|
editor.draw(x, y, Blocks.air);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
elevation{
|
spray{
|
||||||
{
|
{
|
||||||
edit = true;
|
edit = true;
|
||||||
draggable = true;
|
draggable = true;
|
||||||
@@ -65,7 +65,7 @@ public enum EditorTool{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void touched(MapEditor editor, int x, int y){
|
public void touched(MapEditor editor, int x, int y){
|
||||||
editor.elevate(x, y);
|
editor.draw(x, y, editor.getDrawBlock(), 0.012);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
line{
|
line{
|
||||||
@@ -99,7 +99,6 @@ public enum EditorTool{
|
|||||||
|
|
||||||
byte bf = data.read(x, y, DataPosition.floor);
|
byte bf = data.read(x, y, DataPosition.floor);
|
||||||
byte bw = data.read(x, y, DataPosition.wall);
|
byte bw = data.read(x, y, DataPosition.wall);
|
||||||
be = data.read(x, y, DataPosition.elevation);
|
|
||||||
boolean synth = editor.getDrawBlock().synthetic();
|
boolean synth = editor.getDrawBlock().synthetic();
|
||||||
byte brt = Pack.byteByte((byte) editor.getDrawRotation(), (byte) editor.getDrawTeam().ordinal());
|
byte brt = Pack.byteByte((byte) editor.getDrawRotation(), (byte) editor.getDrawTeam().ordinal());
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,13 @@ import io.anuke.mindustry.world.blocks.Floor;
|
|||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public class MapEditor{
|
public class MapEditor{
|
||||||
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15};
|
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15, 20};
|
||||||
|
|
||||||
private MapTileData map;
|
private MapTileData map;
|
||||||
private ObjectMap<String, String> tags = new ObjectMap<>();
|
private ObjectMap<String, String> tags = new ObjectMap<>();
|
||||||
private MapRenderer renderer = new MapRenderer(this);
|
private MapRenderer renderer = new MapRenderer(this);
|
||||||
|
|
||||||
private int brushSize = 1;
|
private int brushSize = 1;
|
||||||
private byte elevation;
|
|
||||||
private int rotation;
|
private int rotation;
|
||||||
private Block drawBlock = Blocks.stone;
|
private Block drawBlock = Blocks.stone;
|
||||||
private Team drawTeam = Team.blue;
|
private Team drawTeam = Team.blue;
|
||||||
@@ -54,14 +53,6 @@ public class MapEditor{
|
|||||||
renderer.resize(map.width(), map.height());
|
renderer.resize(map.width(), map.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getDrawElevation(){
|
|
||||||
return elevation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDrawElevation(int elevation){
|
|
||||||
this.elevation = (byte) elevation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDrawRotation(){
|
public int getDrawRotation(){
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
@@ -99,7 +90,10 @@ public class MapEditor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(int x, int y, Block drawBlock){
|
public void draw(int x, int y, Block drawBlock){
|
||||||
|
draw(x, y, drawBlock, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(int x, int y, Block drawBlock, double chance){
|
||||||
byte writeID = drawBlock.id;
|
byte writeID = drawBlock.id;
|
||||||
byte partID = Blocks.blockpart.id;
|
byte partID = Blocks.blockpart.id;
|
||||||
byte rotationTeam = Pack.byteByte(drawBlock.rotate ? (byte)rotation : 0, drawBlock.synthetic() ? (byte)drawTeam.ordinal() : 0);
|
byte rotationTeam = Pack.byteByte(drawBlock.rotate ? (byte)rotation : 0, drawBlock.synthetic() ? (byte)drawTeam.ordinal() : 0);
|
||||||
@@ -151,10 +145,9 @@ public class MapEditor{
|
|||||||
|
|
||||||
onWrite(x, y, prev);
|
onWrite(x, y, prev);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
for(int rx = -brushSize; rx <= brushSize; rx++){
|
for(int rx = -brushSize; rx <= brushSize; rx++){
|
||||||
for(int ry = -brushSize; ry <= brushSize; ry++){
|
for(int ry = -brushSize; ry <= brushSize; ry++){
|
||||||
if(Mathf.dst(rx, ry) <= brushSize - 0.5f){
|
if(Mathf.dst(rx, ry) <= brushSize - 0.5f && (chance >= 0.999 || Mathf.chance(chance))){
|
||||||
int wx = x + rx, wy = y + ry;
|
int wx = x + rx, wy = y + ry;
|
||||||
|
|
||||||
if(wx < 0 || wy < 0 || wx >= map.width() || wy >= map.height()){
|
if(wx < 0 || wy < 0 || wx >= map.width() || wy >= map.height()){
|
||||||
@@ -175,7 +168,6 @@ public class MapEditor{
|
|||||||
|
|
||||||
if(isfloor){
|
if(isfloor){
|
||||||
map.write(wx, wy, DataPosition.floor, writeID);
|
map.write(wx, wy, DataPosition.floor, writeID);
|
||||||
map.write(wx, wy, DataPosition.elevation, elevation);
|
|
||||||
}else{
|
}else{
|
||||||
map.write(wx, wy, DataPosition.wall, writeID);
|
map.write(wx, wy, DataPosition.wall, writeID);
|
||||||
map.write(wx, wy, DataPosition.link, (byte) 0);
|
map.write(wx, wy, DataPosition.link, (byte) 0);
|
||||||
@@ -189,30 +181,6 @@ public class MapEditor{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void elevate(int x, int y){
|
|
||||||
if(x < 0 || y < 0 || x >= map.width() || y >= map.height()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int rx = -brushSize; rx <= brushSize; rx++){
|
|
||||||
for(int ry = -brushSize; ry <= brushSize; ry++){
|
|
||||||
if(Mathf.dst(rx, ry) <= brushSize - 0.5f){
|
|
||||||
int wx = x + rx, wy = y + ry;
|
|
||||||
|
|
||||||
if(wx < 0 || wy < 0 || wx >= map.width() || wy >= map.height()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TileDataMarker prev = getPrev(wx, wy, true);
|
|
||||||
|
|
||||||
map.write(wx, wy, DataPosition.elevation, elevation);
|
|
||||||
|
|
||||||
onWrite(x + rx, y + ry, prev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeLinked(int x, int y){
|
private void removeLinked(int x, int y){
|
||||||
Block block = content.block(map.read(x, y, DataPosition.wall));
|
Block block = content.block(map.read(x, y, DataPosition.wall));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.editor;
|
package io.anuke.mindustry.editor;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.collection.ObjectMap;
|
import io.anuke.arc.collection.ObjectMap;
|
||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.files.FileHandle;
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.Consumer;
|
||||||
@@ -27,6 +28,7 @@ import io.anuke.mindustry.maps.MapTileData;
|
|||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Block.Icon;
|
import io.anuke.mindustry.world.Block.Icon;
|
||||||
|
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -43,6 +45,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
private FloatingDialog menu;
|
private FloatingDialog menu;
|
||||||
private boolean saved = false;
|
private boolean saved = false;
|
||||||
private boolean shownWithMap = false;
|
private boolean shownWithMap = false;
|
||||||
|
private Array<Block> blocksOut = new Array<>();
|
||||||
|
|
||||||
private ButtonGroup<ImageButton> blockgroup;
|
private ButtonGroup<ImageButton> blockgroup;
|
||||||
|
|
||||||
@@ -387,7 +390,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
tools.row();
|
tools.row();
|
||||||
|
|
||||||
addTool.accept(EditorTool.fill);
|
addTool.accept(EditorTool.fill);
|
||||||
addTool.accept(EditorTool.elevation);
|
addTool.accept(EditorTool.spray);
|
||||||
|
|
||||||
ImageButton rotate = tools.addImageButton("icon-arrow-16", "clear", 16 * 2f, () -> editor.setDrawRotation((editor.getDrawRotation() + 1) % 4)).get();
|
ImageButton rotate = tools.addImageButton("icon-arrow-16", "clear", 16 * 2f, () -> editor.setDrawRotation((editor.getDrawRotation() + 1) % 4)).get();
|
||||||
rotate.getImage().update(() -> {
|
rotate.getImage().update(() -> {
|
||||||
@@ -498,7 +501,13 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for(Block block : Vars.content.blocks()){
|
blocksOut.clear();
|
||||||
|
blocksOut.addAll(Vars.content.blocks());
|
||||||
|
blocksOut.sort((b1, b2) -> b1.synthetic() && !b2.synthetic() ? 1 : b2.synthetic() && !b1.synthetic() ? -1 :
|
||||||
|
b1 instanceof OreBlock && !(b2 instanceof OreBlock) ? 1 : !(b1 instanceof OreBlock) && b2 instanceof OreBlock ? -1 :
|
||||||
|
Integer.compare(b1.id, b2.id));
|
||||||
|
|
||||||
|
for(Block block : blocksOut){
|
||||||
TextureRegion region = block.icon(Icon.medium);
|
TextureRegion region = block.icon(Icon.medium);
|
||||||
|
|
||||||
if(region == Core.atlas.find("jjfgj")) continue;
|
if(region == Core.atlas.find("jjfgj")) continue;
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ 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 Color tmpColor = Color.WHITE.cpy();
|
|
||||||
|
|
||||||
public MapRenderer(MapEditor editor){
|
public MapRenderer(MapEditor editor){
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class MapView extends Element implements GestureListener{
|
|||||||
|
|
||||||
Point2 p = project(x, y);
|
Point2 p = project(x, y);
|
||||||
|
|
||||||
if(drawing && tool.draggable){
|
if(drawing && tool.draggable && !(p.x == lastx && p.y == lasty)){
|
||||||
ui.editor.resetSaved();
|
ui.editor.resetSaved();
|
||||||
Array<Point2> points = br.line(lastx, lasty, p.x, p.y);
|
Array<Point2> points = br.line(lastx, lasty, p.x, p.y);
|
||||||
for(Point2 point : points){
|
for(Point2 point : points){
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class IndexedRenderer implements Disposable{
|
|||||||
program.setUniformMatrix4("u_projTrans", BatchShader.copyTransform(combined));
|
program.setUniformMatrix4("u_projTrans", BatchShader.copyTransform(combined));
|
||||||
program.setUniformi("u_texture", 0);
|
program.setUniformi("u_texture", 0);
|
||||||
|
|
||||||
mesh.render(program, GL20.GL_TRIANGLES, 0, vertices.length / 5);
|
mesh.render(program, GL20.GL_TRIANGLES, 0, vertices.length / vsize);
|
||||||
|
|
||||||
program.end();
|
program.end();
|
||||||
}
|
}
|
||||||
@@ -187,14 +187,6 @@ public class IndexedRenderer implements Disposable{
|
|||||||
return transMatrix;
|
return transMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransformMatrix(Matrix3 matrix){
|
|
||||||
transMatrix = matrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Matrix3 getProjectionMatrix(){
|
|
||||||
return projMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProjectionMatrix(Matrix3 matrix){
|
public void setProjectionMatrix(Matrix3 matrix){
|
||||||
projMatrix = matrix;
|
projMatrix = matrix;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ public class MapIO{
|
|||||||
for(int y = 0; y < data.height(); y++){
|
for(int y = 0; y < data.height(); y++){
|
||||||
for(int x = 0; x < data.width(); x++){
|
for(int x = 0; x < data.width(); x++){
|
||||||
data.read(marker);
|
data.read(marker);
|
||||||
byte elev = y >= data.height() - 1 ? 0 : data.read(x, y + 1, DataPosition.elevation);
|
|
||||||
Block floor = content.block(marker.floor);
|
Block floor = content.block(marker.floor);
|
||||||
Block wall = content.block(marker.wall);
|
Block wall = content.block(marker.wall);
|
||||||
int color = ColorMapper.colorFor(floor, wall, Team.all[marker.team]);
|
int color = ColorMapper.colorFor(floor, wall, Team.all[marker.team]);
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ public class MapTileData{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum DataPosition{
|
public enum DataPosition{
|
||||||
floor, wall, link, rotationTeam, elevation
|
floor, wall, link, rotationTeam,
|
||||||
|
@Deprecated elevation
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TileDataMarker{
|
public class TileDataMarker{
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public class MapGenerator extends Generator{
|
|||||||
private Map map;
|
private Map map;
|
||||||
private String mapName;
|
private String mapName;
|
||||||
|
|
||||||
|
/**How much the landscape is randomly distorted.*/
|
||||||
|
public float distortion = 3;
|
||||||
|
|
||||||
/**The amount of final enemy spawns used. -1 to use everything in the map.
|
/**The amount of final enemy spawns used. -1 to use everything in the map.
|
||||||
* This amount of enemy spawns is selected randomly from the map.*/
|
* This amount of enemy spawns is selected randomly from the map.*/
|
||||||
public int enemySpawns = -1;
|
public int enemySpawns = -1;
|
||||||
@@ -70,9 +73,8 @@ public class MapGenerator extends Generator{
|
|||||||
for(int x = 0; x < data.width(); x++){
|
for(int x = 0; x < data.width(); x++){
|
||||||
for(int y = 0; y < data.height(); y++){
|
for(int y = 0; y < data.height(); y++){
|
||||||
final double scl = 10;
|
final double scl = 10;
|
||||||
final int mag = 3;
|
int newX = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x, y) * distortion + x), 0, data.width()-1);
|
||||||
int newX = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x, y) * mag + x), 0, data.width()-1);
|
int newY = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x + 9999, y + 9999) * distortion + y), 0, data.height()-1);
|
||||||
int newY = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x + 9999, y + 9999) * mag + y), 0, data.height()-1);
|
|
||||||
if(tiles[newX][newY].block() != Blocks.spawn && !tiles[x][y].block().synthetic()&& !tiles[newX][newY].block().synthetic()){
|
if(tiles[newX][newY].block() != Blocks.spawn && !tiles[x][y].block().synthetic()&& !tiles[newX][newY].block().synthetic()){
|
||||||
tiles[x][y].setBlock(tiles[newX][newY].block());
|
tiles[x][y].setBlock(tiles[newX][newY].block());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,4 +271,9 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns whether this block's inventory has space and is ready for production.*/
|
||||||
|
public boolean canProduce(Tile tile){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,10 @@ package io.anuke.mindustry.world.blocks;
|
|||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.entities.Effects.Effect;
|
import io.anuke.arc.entities.Effects.Effect;
|
||||||
import io.anuke.arc.function.Predicate;
|
|
||||||
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.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Geometry;
|
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
|
||||||
import io.anuke.mindustry.content.Fx;
|
import io.anuke.mindustry.content.Fx;
|
||||||
import io.anuke.mindustry.content.StatusEffects;
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
@@ -17,8 +14,6 @@ import io.anuke.mindustry.type.StatusEffect;
|
|||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
|
||||||
|
|
||||||
public class Floor extends Block{
|
public class Floor extends Block{
|
||||||
/** number of different variant regions to use */
|
/** number of different variant regions to use */
|
||||||
public int variants;
|
public int variants;
|
||||||
@@ -52,12 +47,7 @@ public class Floor extends Block{
|
|||||||
public boolean isLiquid;
|
public boolean isLiquid;
|
||||||
/** if true, this block cannot be mined by players. useful for annoying things like sand. */
|
/** if true, this block cannot be mined by players. useful for annoying things like sand. */
|
||||||
public boolean playerUnmineable = false;
|
public boolean playerUnmineable = false;
|
||||||
protected TextureRegion edgeRegion;
|
|
||||||
protected TextureRegion[] edgeRegions;
|
|
||||||
protected TextureRegion[] variantRegions;
|
protected TextureRegion[] variantRegions;
|
||||||
protected Vector2[] offsets;
|
|
||||||
protected Predicate<Floor> blends = block -> block != this && !block.blendOverride(this);
|
|
||||||
protected boolean blend = true;
|
|
||||||
|
|
||||||
public Floor(String name){
|
public Floor(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -68,36 +58,6 @@ public class Floor extends Block{
|
|||||||
public void load(){
|
public void load(){
|
||||||
super.load();
|
super.load();
|
||||||
|
|
||||||
if(blend){
|
|
||||||
edgeRegion = Core.atlas.has(name + "edge") ? Core.atlas.find(name + "edge") : Core.atlas.find(edge + "edge");
|
|
||||||
edgeRegions = new TextureRegion[8];
|
|
||||||
offsets = new Vector2[8];
|
|
||||||
|
|
||||||
for(int i = 0; i < 8; i++){
|
|
||||||
int dx = Geometry.d8[i].x, dy = Geometry.d8[i].y;
|
|
||||||
|
|
||||||
TextureRegion result = new TextureRegion();
|
|
||||||
|
|
||||||
int padSize = (int)(tilesize/Draw.scl/2);
|
|
||||||
int texSize = (int)(tilesize/Draw.scl);
|
|
||||||
int totSize = padSize + texSize;
|
|
||||||
|
|
||||||
int sx = -dx * texSize + padSize/2, sy = -dy * texSize + padSize/2;
|
|
||||||
int x = Mathf.clamp(sx, 0, totSize);
|
|
||||||
int y = Mathf.clamp(sy, 0, totSize);
|
|
||||||
int w = Mathf.clamp(sx + texSize, 0, totSize) - x, h = Mathf.clamp(sy + texSize, 0, totSize) - y;
|
|
||||||
|
|
||||||
float rx = Mathf.clamp(dx * texSize, 0, texSize - w);
|
|
||||||
float ry = Mathf.clamp(dy * texSize, 0, texSize - h);
|
|
||||||
|
|
||||||
result.setTexture(edgeRegion.getTexture());
|
|
||||||
result.set(edgeRegion.getX() + x, edgeRegion.getY() + y + h, w, -h);
|
|
||||||
|
|
||||||
edgeRegions[i] = result;
|
|
||||||
offsets[i] = new Vector2(-padSize + rx, -padSize + ry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//load variant regions for drawing
|
//load variant regions for drawing
|
||||||
if(variants > 0){
|
if(variants > 0){
|
||||||
variantRegions = new TextureRegion[variants];
|
variantRegions = new TextureRegion[variants];
|
||||||
@@ -127,8 +87,6 @@ public class Floor extends Block{
|
|||||||
Mathf.random.setSeed(tile.pos());
|
Mathf.random.setSeed(tile.pos());
|
||||||
|
|
||||||
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
||||||
|
|
||||||
//drawEdges(tile, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -136,8 +94,4 @@ public class Floor extends Block{
|
|||||||
return new TextureRegion[]{Core.atlas.find(Core.atlas.has(name) ? name : name + "1")};
|
return new TextureRegion[]{Core.atlas.find(Core.atlas.has(name) ? name : name + "1")};
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean blendOverride(Block block){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -117,6 +117,11 @@ public class Drill extends Block{
|
|||||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator"), Core.atlas.find(name + "-top")};
|
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator"), Core.atlas.find(name + "-top")};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProduce(Tile tile){
|
||||||
|
return tile.entity.items.total() < itemCapacity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStats(){
|
public void setStats(){
|
||||||
super.setStats();
|
super.setStats();
|
||||||
|
|||||||
@@ -60,6 +60,17 @@ public class PowerCrafter extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProduce(Tile tile){
|
||||||
|
if(outputItem != null && tile.entity.items.get(outputItem) >= itemCapacity){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(outputLiquid != null && tile.entity.liquids.get(outputLiquid) >= liquidCapacity - 0.01f){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
GenericCrafterEntity entity = tile.entity();
|
GenericCrafterEntity entity = tile.entity();
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class ConsumeModule extends BlockModule{
|
public class ConsumeModule extends BlockModule{
|
||||||
private boolean valid;
|
private boolean valid;
|
||||||
|
private TileEntity entity;
|
||||||
|
|
||||||
public void update(TileEntity entity){
|
public void update(TileEntity entity){
|
||||||
boolean prevValid = valid;
|
this.entity = entity;
|
||||||
|
boolean prevValid = valid();
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
for(Consume cons : entity.tile.block().consumes.all()){
|
for(Consume cons : entity.tile.block().consumes.all()){
|
||||||
@@ -26,7 +28,7 @@ public class ConsumeModule extends BlockModule{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean valid(){
|
public boolean valid(){
|
||||||
return valid;
|
return valid && (entity == null || entity.tile.block().canProduce(entity.tile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user