Updated build.gradle, changed scroll dialog, UI tweaks

This commit is contained in:
Anuken
2017-11-27 22:23:47 -05:00
parent 0c6578c229
commit c0d28eca65
29 changed files with 385 additions and 306 deletions

View File

@@ -81,10 +81,9 @@ public class Pathfind{
}
public void update(){
for(SpawnPoint point : Vars.control.getSpawnPoints()){
if(!point.request.pathFound){
if(point.finder.search(point.request, ms)){
if(point.finder.search(point.request, ms * 2)){
smoother.smoothPath(point.path);
point.pathTiles = point.path.nodes.toArray(Tile.class);
}

View File

@@ -447,7 +447,8 @@ public class Renderer extends RendererModule{
drawHealth(entity);
}
drawHealth(player);
if(!Vars.android)
drawHealth(player);
}
void drawHealth(DestructibleEntity dest){

View File

@@ -77,7 +77,7 @@ public class Tutorial{
if(stage.showBlock){
Tile tile = world.tile(control.core.x + stage.blockPlaceX, control.core.y + stage.blockPlaceY);
if(tile.block() == stage.targetBlock && (tile.rotation == stage.blockRotation || stage.blockRotation == -1)){
if(tile.block() == stage.targetBlock && (tile.getRotation() == stage.blockRotation || stage.blockRotation == -1)){
move(true);
}
}

View File

@@ -32,6 +32,7 @@ import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.Window.WindowStyle;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Profiler;
public class UI extends SceneModule{
Table loadingtable, desctable, configtable;
@@ -132,7 +133,8 @@ public class UI extends SceneModule{
@Override
public void update(){
Profiler.begin("ui");
if(nplay.visible()){
scene.getBatch().getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
scene.getBatch().begin();
@@ -143,6 +145,8 @@ public class UI extends SceneModule{
}
super.update();
Profiler.end("ui");
}
@Override

View File

@@ -68,9 +68,9 @@ import io.anuke.ucore.entities.Entities;
* Amount of tiles (int)
* (tile list)
* Tile position, as a single integer, in the format x+y*width
* Tile link - byte
* Tile link - (byte)
* Tile type (boolean)- whether the block has a tile entity attached
* Block ID - the block ID
* Block ID - the block ID (byte)
* (the following only applies to tile entity blocks)
* Block rotation (byte)
* Block health (int)
@@ -263,7 +263,7 @@ public class SaveIO{
stream.writeInt(tile.block().id); //block ID
if(tile.entity != null){
stream.writeByte(tile.rotation); //rotation
stream.writeByte(tile.getRotation()); //rotation
stream.writeInt(tile.entity.health); //health
stream.writeByte(tile.entity.items.size); //amount of items
@@ -413,7 +413,7 @@ public class SaveIO{
int items = stream.readByte();
tile.entity.health = health;
tile.rotation = rotation;
tile.setRotation(rotation);
for(int j = 0; j < items; j ++){
int itemid = stream.readByte();

View File

@@ -29,6 +29,7 @@ public class LevelDialog extends FloatingDialog{
addCloseButton();
Table maps = new Table();
ScrollPane pane = new ScrollPane(maps);
pane.setFadeScrollBars(false);
int maxwidth = 4;
@@ -75,6 +76,8 @@ public class LevelDialog extends FloatingDialog{
});
image.getImageCell().size(images).units(Unit.dp);
maps.add(image).width(170).pad(4f).units(Unit.dp);
maps.padRight(Unit.dp.inPixels(26));
}
content().add(pane).uniformX();

View File

@@ -156,7 +156,7 @@ public class HudFragment implements Fragment{
atop();
aleft();
new label((StringSupplier)()->Profiler.formatDisplayTimes());
}}.width(400f).end();
}}.width(400f).units(Unit.dp).end();
}}.end();
}
}

View File

@@ -127,8 +127,8 @@ public class Block{
* Tries to put this item into a nearby container, if there are no available
* containers, it gets added to the block's inventory.*/
protected void offloadNear(Tile tile, Item item){
int i = tile.dump;
int pdump = tile.dump;
byte i = tile.getDump();
byte pdump = tile.getDump();
Tile[] tiles = tile.getNearby();
@@ -136,16 +136,16 @@ public class Block{
Tile other = tiles[i];
if(other != null && other.block().acceptItem(item, other, tile)
//don't output to things facing this thing
&& !(other.block().rotate && (other.rotation + 2) % 4 == i)){
&& !(other.block().rotate && (other.getRotation() + 2) % 4 == i)){
other.block().handleItem(item, other, tile);
tile.dump = (byte)((i+1)%4);
tile.setDump((byte)((i+1)%4));
return;
}
i++;
i %= 4;
}
tile.dump = (byte)pdump;
tile.setDump((byte)pdump);
handleItem(item, tile, tile);
}
@@ -158,7 +158,7 @@ public class Block{
* Try dumping any item near the tile. -1 = any direction
*/
protected boolean tryDump(Tile tile, int direction, Item todump){
int i = tile.dump;
int i = tile.getDump();
Tile[] tiles = tile.getNearby();
@@ -172,10 +172,10 @@ public class Block{
if(tile.entity.hasItem(item) && other != null && other.block().acceptItem(item, other, tile) &&
//don't output to things facing this thing
!(other.block().rotate && (other.rotation + 2) % 4 == i)){
!(other.block().rotate && (other.getRotation() + 2) % 4 == i)){
other.block().handleItem(item, other, tile);
tile.entity.removeItem(item, 1);
tile.dump = (byte)((i+1)%4);
tile.setDump((byte)((i+1)%4));
return true;
}
}
@@ -190,7 +190,7 @@ public class Block{
* Try offloading an item to a nearby container. Returns true if success.
*/
protected boolean offloadDir(Tile tile, Item item){
Tile other = tile.getNearby()[tile.rotation];
Tile other = tile.getNearby()[tile.getRotation()];
if(other != null && other.block().acceptItem(item, other, tile)){
other.block().handleItem(item, other, tile);
//other.entity.addCovey(item, ch == 1 ? 0.5f : ch ==2 ? 1f : 0f);
@@ -207,7 +207,7 @@ public class Block{
//note: multiblocks do not support rotation
if(!isMultiblock()){
Draw.rect(variants > 0 ? (name() + Mathf.randomSeed(tile.id(), 1, variants)) : name(),
tile.worldx(), tile.worldy(), rotate ? tile.rotation * 90 : 0);
tile.worldx(), tile.worldy(), rotate ? tile.getRotation() * 90 : 0);
}else{
//if multiblock, make sure to draw even block sizes offset, since the core block is at the BOTTOM LEFT
Vector2 offset = getPlaceOffset();

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.world;
public enum Map{
delta("Starting map."),
pit("Eck."),
canyon("the canyon"),
maze("it's okay."),
volcano("desc"),
tutorial(false),

View File

@@ -15,14 +15,15 @@ import io.anuke.ucore.util.Mathf;
public class Tile{
private static final Array<Tile> tmpArray = new Array<>();
private Block floor = Blocks.air;
private Block block = Blocks.air;
/**Packed block data. Left is floor, right is block.*/
private short blocks;
/**Packed data. Left is rotation, right is dump.*/
private short data;
/**The coordinates of the core tile this is linked to, in the form of two bytes packed into one.
* This is relative to the block it is linked to; negate coords to find the link.*/
public byte link = 0;
public TileEntity entity;
public short x, y;
public byte rotation, dump;
public TileEntity entity;
public Tile(int x, int y){
this.x = (short)x;
@@ -31,7 +32,25 @@ public class Tile{
public Tile(int x, int y, Block floor){
this(x, y);
this.floor = floor;
iSetFloor(floor);
}
private void iSetFloor(Block floor){
byte id = (byte)floor.id;
blocks = Bits.packShort(id, getWallID());
}
private void iSetBlock(Block wall){
byte id = (byte)wall.id;
blocks = Bits.packShort(getFloorID(), id);
}
public byte getWallID(){
return Bits.getRightByte(blocks);
}
public byte getFloorID(){
return Bits.getLeftByte(blocks);
}
public int relativeTo(int cx, int cy){
@@ -74,46 +93,68 @@ public class Tile{
}
public Block floor(){
return floor;
return Block.getByID(getFloorID());
}
public Block block(){
return block;
return Block.getByID(getWallID());
}
/**Returns the breaktime of the block, <i>or</i> the breaktime of the linked block, if this tile is linked.*/
public float getBreakTime(){
return link == 0 ? block.breaktime : getLinked().block.breaktime;
Block block = block();
return link == 0 ? block.breaktime : getLinked().block().breaktime;
}
public void setBlock(Block type, int rotation){
if(rotation < 0) rotation = (-rotation + 2);
rotation %= 4;
this.block = type;
this.rotation = (byte)rotation;
iSetBlock(type);
setRotation((byte)rotation);
this.link = 0;
changed();
}
public void setBlock(Block type){
this.block = type;
iSetBlock(type);
this.link = 0;
changed();
}
public void setFloor(Block type){
this.floor = type;
iSetFloor(type);
}
public void setRotation(byte rotation){
data = Bits.packShort(rotation, getDump());
}
public void setDump(byte dump){
data = Bits.packShort(getRotation(), dump);
}
public byte getRotation(){
return Bits.getLeftByte(data);
}
public byte getDump(){
return Bits.getRightByte(data);
}
public boolean passable(){
Block block = block();
Block floor = floor();
return isLinked() || !(floor.solid || (block.solid && (!block.destructible && !block.update)));
}
public boolean solid(){
Block block = block();
Block floor = floor();
return block.solid || floor.solid;
}
public boolean breakable(){
Block block = block();
if(link == 0){
return (block.destructible || block.breakable || block.update);
}else{
@@ -134,6 +175,7 @@ public class Tile{
/**Returns the list of all tiles linked to this multiblock, or an empty array if it's not a multiblock.
* This array contains all linked tiles, including this tile itself.*/
public Array<Tile> getLinkedTiles(){
Block block = block();
tmpArray.clear();
if(!(block.width == 1 && block.height == 1)){
int offsetx = -(block.width-1)/2;
@@ -169,6 +211,8 @@ public class Tile{
entity = null;
}
Block block = block();
if(block.destructible || block.update){
entity = block.getEntity().init(this, block.update);
}
@@ -176,6 +220,9 @@ public class Tile{
@Override
public String toString(){
Block block = block();
Block floor = floor();
return floor.name() + ":" + block.name() +
(link != 0 ? " link=[" + (Bits.getLeftByte(link) - 8) + ", " + (Bits.getRightByte(link) - 8) + "]" : "");
}

View File

@@ -20,6 +20,7 @@ import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.entities.SolidEntity;
import io.anuke.ucore.modules.Module;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Profiler;
import io.anuke.ucore.util.Tmp;
public class World extends Module{
@@ -38,7 +39,9 @@ public class World extends Module{
@Override
public void update(){
Profiler.begin("pathfind");
pathfind.update();
Profiler.end("pathfind");
}
@Override
@@ -223,8 +226,7 @@ public class World extends Module{
if(tile == null)
return;
tile.setBlock(result);
tile.rotation = (byte)rotation;
tile.setBlock(result, rotation);
if(result.isMultiblock()){
int offsetx = -(result.width-1)/2;

View File

@@ -55,7 +55,7 @@ public class Blocks{
Effects.effect(Fx.lava, tile.worldx() + Mathf.range(5f), tile.worldy() + Mathf.range(5f));
}
if(Mathf.chance(0.003 * Timers.delta())){
if(Mathf.chance(0.002 * Timers.delta())){
Effects.effect(Fx.lavabubble, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
}
}
@@ -70,7 +70,7 @@ public class Blocks{
@Override
public void update(Tile tile){
if(Mathf.chance(0.0025 * Timers.delta())){
if(Mathf.chance(0.0022 * Timers.delta())){
Effects.effect(Fx.oilbubble, tile.worldx() + Mathf.range(2f), tile.worldy() + Mathf.range(2f));
}
}

View File

@@ -12,6 +12,7 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf;
public class LiquidBlock extends Block implements LiquidAcceptor{
protected float liquidCapacity = 10f;
@@ -34,16 +35,16 @@ public class LiquidBlock extends Block implements LiquidAcceptor{
public void draw(Tile tile){
LiquidEntity entity = tile.entity();
Draw.rect(name() + "bottom", tile.worldx(), tile.worldy(), tile.rotation * 90);
Draw.rect(name() + "bottom", tile.worldx(), tile.worldy(), tile.getRotation() * 90);
if(entity.liquid != null && entity.liquidAmount > 0.01f){
Draw.color(entity.liquid.color);
Draw.alpha(entity.liquidAmount / liquidCapacity);
Draw.rect("conduitliquid", tile.worldx(), tile.worldy(), tile.rotation * 90);
Draw.rect("conduitliquid", tile.worldx(), tile.worldy(), tile.getRotation() * 90);
Draw.color();
}
Draw.rect(name() + "top", tile.worldx(), tile.worldy(), tile.rotation * 90);
Draw.rect(name() + "top", tile.worldx(), tile.worldy(), tile.getRotation() * 90);
}
@@ -57,7 +58,7 @@ public class LiquidBlock extends Block implements LiquidAcceptor{
LiquidEntity entity = tile.entity();
if(entity.liquidAmount > 0.01f && Timers.get(entity, "flow", 3)){
tryMoveLiquid(tile, tile.getNearby()[tile.rotation]);
tryMoveLiquid(tile, tile.getNearby()[tile.getRotation()]);
}
}
@@ -66,9 +67,8 @@ public class LiquidBlock extends Block implements LiquidAcceptor{
LiquidEntity entity = tile.entity();
if(entity.liquidAmount > 0.01f){
tryMoveLiquid(tile, tile.getNearby()[tile.dump]);
tile.dump ++;
tile.dump %= 4;
tryMoveLiquid(tile, tile.getNearby()[tile.getDump()]);
tile.setDump((byte)Mathf.mod(tile.getDump() + 1, 4));
}
}

View File

@@ -47,14 +47,16 @@ public class Conveyor extends Block{
public void draw(Tile tile){
ConveyorEntity entity = tile.entity();
byte rotation = tile.getRotation();
Draw.rect(name() +
(Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed && acceptItem(Item.stone, tile, null) ? "" : "move"), tile.worldx(), tile.worldy(), tile.rotation * 90);
(Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed && acceptItem(Item.stone, tile, null) ? "" : "move"), tile.worldx(), tile.worldy(), rotation * 90);
for(int i = 0; i < entity.convey.size; i ++){
ItemPos pos = pos1.set(entity.convey.get(i));
Tmp.v1.set(tilesize, 0).rotate(tile.rotation * 90);
Tmp.v2.set(-tilesize / 2, pos.x*tilesize/2).rotate(tile.rotation * 90);
Tmp.v1.set(tilesize, 0).rotate(rotation * 90);
Tmp.v2.set(-tilesize / 2, pos.x*tilesize/2).rotate(rotation * 90);
Draw.rect("icon-" + pos.item.name(),
tile.x * tilesize + Tmp.v1.x * pos.y + Tmp.v2.x,
@@ -115,7 +117,7 @@ public class Conveyor extends Block{
@Override
public boolean acceptItem(Item item, Tile dest, Tile source){
int direction = source == null ? 0 : Math.abs(source.relativeTo(dest.x, dest.y) - dest.rotation);
int direction = source == null ? 0 : Math.abs(source.relativeTo(dest.x, dest.y) - dest.getRotation());
float minitem = dest.<ConveyorEntity>entity().minitem;
return ((direction == 0) && minitem > 0.05f) ||
((direction %2 == 1) && minitem > 0.5f);
@@ -123,8 +125,10 @@ public class Conveyor extends Block{
@Override
public void handleItem(Item item, Tile tile, Tile source){
int ch = Math.abs(source.relativeTo(tile.x, tile.y) - tile.rotation);
int ang = ((source.relativeTo(tile.x, tile.y) - tile.rotation));
byte rotation = tile.getRotation();
int ch = Math.abs(source.relativeTo(tile.x, tile.y) - rotation);
int ang = ((source.relativeTo(tile.x, tile.y) - rotation));
float pos = ch == 0 ? 0 : ch % 2 == 1 ? 0.5f : 1f;

View File

@@ -16,7 +16,7 @@ public class LiquidItemJunction extends LiquidBlock{
@Override
public void draw(Tile tile){
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.rotation * 90);
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.getRotation() * 90);
}
@Override

View File

@@ -22,12 +22,11 @@ public class LiquidRouter extends LiquidBlock{
LiquidEntity entity = tile.entity();
if(Timers.get(tile, "dump", 2) && entity.liquidAmount > 0){
if(lastmap.get(tile, (byte)-1) != tile.rotation){
tryMoveLiquid(tile, tile.getNearby()[tile.rotation]);
if(lastmap.get(tile, (byte)-1) != tile.getRotation()){
tryMoveLiquid(tile, tile.getNearby()[tile.getRotation()]);
}
tile.rotation ++;
tile.rotation %= 4;
tile.setRotation((byte)((tile.getRotation() + 1) % 4));
}
}

View File

@@ -35,13 +35,12 @@ public class Router extends Block{
@Override
public void update(Tile tile){
if(Timers.get(tile, "dump", 2) && tile.entity.totalItems() > 0){
if(lastmap.get(tile, (byte)-1) != tile.rotation
if(lastmap.get(tile, (byte)-1) != tile.getRotation()
|| Mathf.chance(0.3)){ //sometimes dump backwards at a 1/4 chance... this somehow works?
tryDump(tile, tile.rotation, null);
tryDump(tile, tile.getRotation(), null);
}
tile.rotation ++;
tile.rotation %= 4;
tile.setRotation((byte)((tile.getRotation() + 1) % 4));
}
}

View File

@@ -73,14 +73,14 @@ public class Sorter extends Junction implements Configurable{
}else if(bc && !ac){
to = b;
}else{
if(dest.dump == 0){
if(dest.getDump() == 0){
to = a;
if(flip)
dest.dump = 1;
dest.setDump((byte)1);
}else{
to = b;
if(flip)
dest.dump = 0;
dest.setDump((byte)0);
}
}
}

View File

@@ -86,7 +86,7 @@ public class Generator extends PowerBlock{
}
for(int i = 0; i < laserDirections; i++){
drawLaserTo(tile, (tile.rotation + i) - laserDirections/2);
drawLaserTo(tile, (tile.getRotation() + i) - laserDirections/2);
}
}
@@ -99,7 +99,7 @@ public class Generator extends PowerBlock{
PowerEntity entity = tile.entity();
for(int i = 0; i < laserDirections; i++){
Tile target = laserTarget(tile, (tile.rotation + i) - laserDirections/2);
Tile target = laserTarget(tile, (tile.getRotation() + i) - laserDirections/2);
if(target == null) continue;