Merge branches '6.0' and 'splinterface-impl' of https://github.com/Anuken/Mindustry into splinterface-impl
# Conflicts: # core/assets/sprites/block_colors.png # core/assets/sprites/sprites.atlas # core/assets/sprites/sprites.png # core/assets/sprites/sprites3.png # core/assets/sprites/sprites5.png # core/src/mindustry/Vars.java # core/src/mindustry/entities/traits/SaveTrait.java # core/src/mindustry/maps/generators/MapGenerator.java # core/src/mindustry/ui/dialogs/DeployDialog.java # core/src/mindustry/world/blocks/Floor.java # desktop/src/mindustry/desktop/DesktopLauncher.java # gradle.properties
This commit is contained in:
@@ -35,17 +35,21 @@ public class Tile implements Position{
|
||||
block = floor = overlay = (Floor)Blocks.air;
|
||||
}
|
||||
|
||||
public Tile(int x, int y, int floor, int overlay, int wall){
|
||||
public Tile(int x, int y, Block floor, Block overlay, Block wall){
|
||||
this.x = (short)x;
|
||||
this.y = (short)y;
|
||||
this.floor = (Floor)content.block(floor);
|
||||
this.overlay = (Floor)content.block(overlay);
|
||||
this.block = content.block(wall);
|
||||
this.floor = (Floor)floor;
|
||||
this.overlay = (Floor)overlay;
|
||||
this.block = wall;
|
||||
|
||||
//update entity and create it if needed
|
||||
changed();
|
||||
}
|
||||
|
||||
public Tile(int x, int y, int floor, int overlay, int wall){
|
||||
this(x, y, content.block(floor), content.block(overlay), content.block(wall));
|
||||
}
|
||||
|
||||
/** Returns this tile's position as a {@link Pos}. */
|
||||
public int pos(){
|
||||
return Pos.get(x, y);
|
||||
|
||||
19
core/src/mindustry/world/TileGen.java
Normal file
19
core/src/mindustry/world/TileGen.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package mindustry.world;
|
||||
|
||||
import mindustry.content.*;
|
||||
|
||||
public class TileGen{
|
||||
public Block floor;
|
||||
public Block block ;
|
||||
public Block overlay;
|
||||
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
floor = Blocks.stone;
|
||||
block = Blocks.air;
|
||||
overlay = Blocks.air;
|
||||
}
|
||||
}
|
||||
93
core/src/mindustry/world/Tiles.java
Normal file
93
core/src/mindustry/world/Tiles.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package mindustry.world;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/** A tile container. */
|
||||
public class Tiles implements Iterable<Tile>{
|
||||
private final Tile[] array;
|
||||
private final int width, height;
|
||||
private final TileIterator iterator = new TileIterator();
|
||||
|
||||
public Tiles(int width, int height){
|
||||
this.array = new Tile[width * height];
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void each(Intc2 cons){
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
cons.get(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** fills this tile set with empty air tiles. */
|
||||
public void fill(){
|
||||
for(int i = 0; i < array.length; i++){
|
||||
array[i] = new Tile(i % width, i / width);
|
||||
}
|
||||
}
|
||||
|
||||
/** set a tile at a position; does not range-check. use with caution. */
|
||||
public void set(int x, int y, Tile tile){
|
||||
array[y*width + x] = tile;
|
||||
}
|
||||
|
||||
/** @return whether these coordinates are in bounds */
|
||||
public boolean in(int x, int y){
|
||||
return x >= 0 && x < width && y >= 0 && y < height;
|
||||
}
|
||||
|
||||
/** @return a tile at coordinates, or null if out of bounds */
|
||||
public @Nullable Tile get(int x, int y){
|
||||
return (x < 0 || x >= width || y < 0 || y >= height) ? null : array[y*width + x];
|
||||
}
|
||||
|
||||
/** @return a tile at coordinates; throws an exception if out of bounds */
|
||||
public @NonNull Tile getn(int x, int y){
|
||||
if(x < 0 || x >= width || y < 0 || y >= height) throw new IllegalArgumentException(x + ", " + y + " out of bounds: width=" + width + ", height=" + height);
|
||||
return array[y*width + x];
|
||||
}
|
||||
|
||||
/** @return a tile at an iteration index [0, width * height] */
|
||||
public @NonNull Tile geti(int idx){
|
||||
return array[idx];
|
||||
}
|
||||
|
||||
/** @return a tile at an int position (not equivalent to geti) */
|
||||
public @Nullable Tile getp(int pos){
|
||||
return get(Pos.x(pos), Pos.y(pos));
|
||||
}
|
||||
|
||||
public int width(){
|
||||
return width;
|
||||
}
|
||||
|
||||
public int height(){
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Tile> iterator(){
|
||||
iterator.index = 0;
|
||||
return iterator;
|
||||
}
|
||||
|
||||
private class TileIterator implements Iterator<Tile>{
|
||||
int index = 0;
|
||||
|
||||
@Override
|
||||
public boolean hasNext(){
|
||||
return index < array.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile next(){
|
||||
return array[index++];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import arc.graphics.g2d.*;
|
||||
import arc.graphics.g2d.TextureAtlas.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
@@ -35,13 +36,13 @@ public class Floor extends Block{
|
||||
/** Effect displayed when drowning on this floor. */
|
||||
public Effect drownUpdateEffect = Fx.bubble;
|
||||
/** Status effect applied when walking on. */
|
||||
public StatusEffect status = StatusEffects.none;
|
||||
public @NonNull StatusEffect status = StatusEffects.none;
|
||||
/** Intensity of applied status effect. */
|
||||
public float statusDuration = 60f;
|
||||
/** liquids that drop from this block, used for pumps */
|
||||
public Liquid liquidDrop = null;
|
||||
public @Nullable Liquid liquidDrop = null;
|
||||
/** item that drops from this block, used for drills */
|
||||
public Item itemDrop = null;
|
||||
public @Nullable Item itemDrop = null;
|
||||
/** whether this block can be drowned in */
|
||||
public boolean isLiquid;
|
||||
/** if true, this block cannot be mined by players. useful for annoying things like sand. */
|
||||
|
||||
Reference in New Issue
Block a user