Added conveyor autotiling / Fixed autotile update bug
This commit is contained in:
@@ -57,7 +57,6 @@ public class UI extends SceneModule{
|
||||
public BansDialog bans;
|
||||
public AdminsDialog admins;
|
||||
public TraceDialog traces;
|
||||
public RollbackDialog rollback;
|
||||
public ChangelogDialog changelog;
|
||||
public LocalPlayerDialog localplayers;
|
||||
public UnlocksDialog unlocks;
|
||||
@@ -164,7 +163,6 @@ public class UI extends SceneModule{
|
||||
bans = new BansDialog();
|
||||
admins = new AdminsDialog();
|
||||
traces = new TraceDialog();
|
||||
rollback = new RollbackDialog();
|
||||
maps = new MapsDialog();
|
||||
localplayers = new LocalPlayerDialog();
|
||||
unlocks = new UnlocksDialog();
|
||||
|
||||
@@ -665,9 +665,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
team = (team == Team.blue ? Team.red : Team.blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all values of the player.
|
||||
*/
|
||||
/** Resets all values of the player.*/
|
||||
public void reset(){
|
||||
status.clear();
|
||||
team = Team.blue;
|
||||
|
||||
@@ -38,9 +38,7 @@ import static io.anuke.mindustry.Vars.world;
|
||||
public class TileEntity extends BaseEntity implements TargetTrait{
|
||||
public static final float timeToSleep = 60f * 4; //4 seconds to fall asleep
|
||||
private static final ObjectSet<Tile> tmpTiles = new ObjectSet<>();
|
||||
/**
|
||||
* This value is only used for debugging.
|
||||
*/
|
||||
/**This value is only used for debugging.*/
|
||||
public static int sleepingEntities = 0;
|
||||
public Tile tile;
|
||||
public Timer timer;
|
||||
|
||||
@@ -305,6 +305,10 @@ public class DesktopInput extends InputHandler{
|
||||
public void updateController(){
|
||||
boolean mousemove = Gdx.input.getDeltaX() > 1 || Gdx.input.getDeltaY() > 1;
|
||||
|
||||
if(state.is(State.menu)){
|
||||
droppingItem = false;
|
||||
}
|
||||
|
||||
if(KeyBinds.getSection(section).device.type == DeviceType.controller && (!mousemove || player.playerIndex > 0)){
|
||||
if(player.playerIndex > 0){
|
||||
controlling = true;
|
||||
|
||||
@@ -33,18 +33,12 @@ import io.anuke.ucore.util.Translator;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public abstract class InputHandler extends InputAdapter{
|
||||
/**
|
||||
* Used for dropping items.
|
||||
*/
|
||||
/**Used for dropping items.*/
|
||||
final static float playerSelectRange = mobile ? 17f : 11f;
|
||||
/**
|
||||
* Maximum line length.
|
||||
*/
|
||||
/**Maximum line length.*/
|
||||
final static int maxLength = 100;
|
||||
final static Translator stackTrns = new Translator();
|
||||
/**
|
||||
* Distance on the back from where items originate.
|
||||
*/
|
||||
/**Distance on the back from where items originate.*/
|
||||
final static float backTrns = 3f;
|
||||
|
||||
public final Player player;
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.gwt;
|
||||
|
||||
public class RollbackDialog extends FloatingDialog{
|
||||
|
||||
public RollbackDialog(){
|
||||
super("$text.server.rollback");
|
||||
|
||||
setup();
|
||||
shown(this::setup);
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
content().clear();
|
||||
buttons().clear();
|
||||
|
||||
if(gwt) return;
|
||||
|
||||
content().row();
|
||||
content().add("$text.server.rollback.numberfield");
|
||||
|
||||
TextField field = content().addField("", t -> {
|
||||
}).size(200f, 48f).get();
|
||||
field.setTextFieldFilter((f, c) -> field.getText().length() < 4);
|
||||
|
||||
content().row();
|
||||
buttons().defaults().size(200f, 50f).left().pad(2f);
|
||||
buttons().addButton("$text.cancel", this::hide);
|
||||
|
||||
buttons().addButton("$text.ok", () -> {
|
||||
//NetEvents.handleRollbackRequest(Integer.valueOf(field.getText()));
|
||||
hide();
|
||||
}).disabled(b -> field.getText().isEmpty() || !Strings.canParsePostiveInt(field.getText()));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
public class SectorsDialog{
|
||||
public class SectorsDialog extends FloatingDialog{
|
||||
|
||||
public SectorsDialog(){
|
||||
super("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,6 +402,15 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
if(block.hasLiquids) entity.liquids = new LiquidModule();
|
||||
if(block.hasPower) entity.power = new PowerModule();
|
||||
entity.updateProximity();
|
||||
}else{
|
||||
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
|
||||
for(GridPoint2 p : Geometry.d4){
|
||||
Tile tile = world.tile(x + p.x, y + p.y);
|
||||
if(tile != null){
|
||||
tile = tile.target();
|
||||
tile.block().onProximityUpdate(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateOcclusion();
|
||||
|
||||
@@ -36,20 +36,21 @@ public class Conduit extends LiquidBlock{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityUpdate(Tile tile){
|
||||
ConduitEntity entity = tile.entity();
|
||||
entity.blendbits = 0;
|
||||
|
||||
if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)){
|
||||
entity.blendbits = 3;
|
||||
}else if(blends(tile, 1) && blends(tile, 3)){
|
||||
entity.blendbits = 6;
|
||||
}else if(blends(tile, 1) && blends(tile, 2)){
|
||||
entity.blendbits = 2;
|
||||
}else if(blends(tile, 3) && blends(tile, 2)){
|
||||
entity.blendbits = 4;
|
||||
}else if(blends(tile, 0)){
|
||||
if(blends(tile, 1) && blends(tile, 3)){
|
||||
entity.blendbits = 6;
|
||||
}else if(blends(tile, 1)){
|
||||
if(blends(tile, 1)){
|
||||
entity.blendbits = 5;
|
||||
}else if(blends(tile, 3)){
|
||||
entity.blendbits = 1;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.LongArray;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
@@ -33,8 +32,7 @@ public class Conveyor extends Block{
|
||||
private static ItemPos pos2 = new ItemPos();
|
||||
private final Translator tr1 = new Translator();
|
||||
private final Translator tr2 = new Translator();
|
||||
private final TextureRegion region1 = new TextureRegion();
|
||||
private final TextureRegion region2 = new TextureRegion();
|
||||
private final TextureRegion[][] regions = new TextureRegion[7][4];
|
||||
|
||||
protected float speed = 0f;
|
||||
protected float carryCapacity = 8f;
|
||||
@@ -47,7 +45,7 @@ public class Conveyor extends Block{
|
||||
group = BlockGroup.transportation;
|
||||
hasItems = true;
|
||||
autoSleep = true;
|
||||
itemCapacity = Math.round(tilesize / itemSpace);
|
||||
itemCapacity = 4;
|
||||
}
|
||||
|
||||
private static int compareItems(Long a, Long b){
|
||||
@@ -57,8 +55,7 @@ public class Conveyor extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
}
|
||||
public void setBars(){}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
@@ -66,35 +63,71 @@ public class Conveyor extends Block{
|
||||
stats.add(BlockStat.itemSpeed, speed * 60, StatUnit.pixelsSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
for(int i = 0; i < regions.length; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
regions[i][j] = Draw.region(name + "-" + i + "-" + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
ConveyorEntity entity = tile.entity();
|
||||
byte rotation = tile.getRotation();
|
||||
|
||||
GridPoint2 point = Geometry.d4[rotation];
|
||||
int frame = entity.clogHeat <= 0.5f ? (int) ((Timers.time() / 4f) % 4) : 0;
|
||||
Draw.rect(regions[entity.blendbits][frame], tile.drawx(), tile.drawy(), tilesize * entity.blendsclx, tilesize * entity.blendscly, rotation*90);
|
||||
}
|
||||
|
||||
int offset = entity.clogHeat <= 0.5f ? (int) ((Timers.time() / 4f) % 8) : 0;
|
||||
TextureRegion region = Draw.region(name);
|
||||
@Override
|
||||
public void onProximityUpdate(Tile tile){
|
||||
ConveyorEntity entity = tile.entity();
|
||||
entity.blendbits = 0;
|
||||
entity.blendsclx = entity.blendscly = 1;
|
||||
|
||||
region1.setRegion(region, 0, 0, region.getRegionWidth() - offset, region.getRegionHeight());
|
||||
region2.setRegion(region, region.getRegionWidth() - offset, 0, offset, region.getRegionHeight());
|
||||
|
||||
float x = tile.drawx(), y = tile.drawy();
|
||||
|
||||
if(offset % 2 == 1){
|
||||
if(point.x < 0) x += 0.75f;
|
||||
if(point.y < 0)
|
||||
y += 0.5f;
|
||||
else if(point.y > 0)
|
||||
y -= 0.5f;
|
||||
if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)){
|
||||
entity.blendbits = 3;
|
||||
}else if(blends(tile, 1) && blends(tile, 3)){
|
||||
entity.blendbits = 4;
|
||||
}else if(blends(tile, 1) && blends(tile, 2)){
|
||||
entity.blendbits = 2;
|
||||
}else if(blends(tile, 3) && blends(tile, 2)){
|
||||
entity.blendbits = 2;
|
||||
entity.blendscly = -1;
|
||||
}else if(blends(tile, 0)){
|
||||
if(blends(tile, 1)){
|
||||
entity.blendbits = 1;
|
||||
entity.blendscly = -1;
|
||||
}else if(blends(tile, 3)){
|
||||
entity.blendbits = 1;
|
||||
}
|
||||
}else if(blends(tile, 1)){
|
||||
entity.blendbits = 1;
|
||||
entity.blendscly = -1;
|
||||
}else if(blends(tile, 3)){
|
||||
entity.blendbits = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Draw.rect(region1,
|
||||
x + (point.x * (tilesize / 2f - region1.getRegionWidth() / 2f)),
|
||||
y + (point.y * (tilesize / 2f - region1.getRegionWidth() / 2f)), rotation * 90);
|
||||
Draw.rect(region2,
|
||||
x - (point.x * (tilesize / 2f - region2.getRegionWidth() / 2f)),
|
||||
y - (point.y * (tilesize / 2f - region2.getRegionWidth() / 2f)), rotation * 90);
|
||||
private boolean blends(Tile tile, int direction){
|
||||
Tile other = tile.getNearby(Mathf.mod(tile.getRotation() - direction, 4));
|
||||
if(other != null) other = other.target();
|
||||
|
||||
if(other == null || !(other.block().hasItems) /*|| !(other.block().outputsLiquid)*/) return false;
|
||||
return (tile.getNearby(tile.getRotation()) == other)
|
||||
|| (!other.block().rotate || other.getNearby(other.getRotation()) == tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] getIcon(){
|
||||
if(icon == null){
|
||||
icon = new TextureRegion[]{Draw.region(name + "-0-0")};
|
||||
}
|
||||
return super.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -331,6 +364,8 @@ public class Conveyor extends Block{
|
||||
float minitem = 1;
|
||||
float carrying;
|
||||
float minCarry = 2f;
|
||||
int blendbits;
|
||||
int blendsclx, blendscly;
|
||||
|
||||
float clogHeat = 0f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user