Added conveyor autotiling / Fixed autotile update bug

This commit is contained in:
Anuken
2018-07-15 22:33:14 -04:00
parent 6a7ff13859
commit d552f37daf
54 changed files with 556 additions and 280 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 134 KiB

View File

@@ -57,7 +57,6 @@ public class UI extends SceneModule{
public BansDialog bans; public BansDialog bans;
public AdminsDialog admins; public AdminsDialog admins;
public TraceDialog traces; public TraceDialog traces;
public RollbackDialog rollback;
public ChangelogDialog changelog; public ChangelogDialog changelog;
public LocalPlayerDialog localplayers; public LocalPlayerDialog localplayers;
public UnlocksDialog unlocks; public UnlocksDialog unlocks;
@@ -164,7 +163,6 @@ public class UI extends SceneModule{
bans = new BansDialog(); bans = new BansDialog();
admins = new AdminsDialog(); admins = new AdminsDialog();
traces = new TraceDialog(); traces = new TraceDialog();
rollback = new RollbackDialog();
maps = new MapsDialog(); maps = new MapsDialog();
localplayers = new LocalPlayerDialog(); localplayers = new LocalPlayerDialog();
unlocks = new UnlocksDialog(); unlocks = new UnlocksDialog();

View File

@@ -665,9 +665,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
team = (team == Team.blue ? Team.red : Team.blue); team = (team == Team.blue ? Team.red : Team.blue);
} }
/** /** Resets all values of the player.*/
* Resets all values of the player.
*/
public void reset(){ public void reset(){
status.clear(); status.clear();
team = Team.blue; team = Team.blue;

View File

@@ -38,9 +38,7 @@ import static io.anuke.mindustry.Vars.world;
public class TileEntity extends BaseEntity implements TargetTrait{ public class TileEntity extends BaseEntity implements TargetTrait{
public static final float timeToSleep = 60f * 4; //4 seconds to fall asleep public static final float timeToSleep = 60f * 4; //4 seconds to fall asleep
private static final ObjectSet<Tile> tmpTiles = new ObjectSet<>(); 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 static int sleepingEntities = 0;
public Tile tile; public Tile tile;
public Timer timer; public Timer timer;

View File

@@ -305,6 +305,10 @@ public class DesktopInput extends InputHandler{
public void updateController(){ public void updateController(){
boolean mousemove = Gdx.input.getDeltaX() > 1 || Gdx.input.getDeltaY() > 1; 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(KeyBinds.getSection(section).device.type == DeviceType.controller && (!mousemove || player.playerIndex > 0)){
if(player.playerIndex > 0){ if(player.playerIndex > 0){
controlling = true; controlling = true;

View File

@@ -33,18 +33,12 @@ import io.anuke.ucore.util.Translator;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
public abstract class InputHandler extends InputAdapter{ public abstract class InputHandler extends InputAdapter{
/** /**Used for dropping items.*/
* Used for dropping items.
*/
final static float playerSelectRange = mobile ? 17f : 11f; final static float playerSelectRange = mobile ? 17f : 11f;
/** /**Maximum line length.*/
* Maximum line length.
*/
final static int maxLength = 100; final static int maxLength = 100;
final static Translator stackTrns = new Translator(); 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; final static float backTrns = 3f;
public final Player player; public final Player player;

View File

@@ -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()));
}
}

View File

@@ -1,4 +1,8 @@
package io.anuke.mindustry.ui.dialogs; package io.anuke.mindustry.ui.dialogs;
public class SectorsDialog{ public class SectorsDialog extends FloatingDialog{
public SectorsDialog(){
super("");
}
} }

View File

@@ -402,6 +402,15 @@ public class Tile implements PosTrait, TargetTrait{
if(block.hasLiquids) entity.liquids = new LiquidModule(); if(block.hasLiquids) entity.liquids = new LiquidModule();
if(block.hasPower) entity.power = new PowerModule(); if(block.hasPower) entity.power = new PowerModule();
entity.updateProximity(); 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(); updateOcclusion();

View File

@@ -36,20 +36,21 @@ public class Conduit extends LiquidBlock{
} }
} }
@Override
public void onProximityUpdate(Tile tile){ public void onProximityUpdate(Tile tile){
ConduitEntity entity = tile.entity(); ConduitEntity entity = tile.entity();
entity.blendbits = 0; entity.blendbits = 0;
if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)){ if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)){
entity.blendbits = 3; entity.blendbits = 3;
}else if(blends(tile, 1) && blends(tile, 3)){
entity.blendbits = 6;
}else if(blends(tile, 1) && blends(tile, 2)){ }else if(blends(tile, 1) && blends(tile, 2)){
entity.blendbits = 2; entity.blendbits = 2;
}else if(blends(tile, 3) && blends(tile, 2)){ }else if(blends(tile, 3) && blends(tile, 2)){
entity.blendbits = 4; entity.blendbits = 4;
}else if(blends(tile, 0)){ }else if(blends(tile, 0)){
if(blends(tile, 1) && blends(tile, 3)){ if(blends(tile, 1)){
entity.blendbits = 6;
}else if(blends(tile, 1)){
entity.blendbits = 5; entity.blendbits = 5;
}else if(blends(tile, 3)){ }else if(blends(tile, 3)){
entity.blendbits = 1; entity.blendbits = 1;

View File

@@ -1,7 +1,6 @@
package io.anuke.mindustry.world.blocks.distribution; package io.anuke.mindustry.world.blocks.distribution;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.LongArray; import com.badlogic.gdx.utils.LongArray;
import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.TileEntity;
@@ -33,8 +32,7 @@ public class Conveyor extends Block{
private static ItemPos pos2 = new ItemPos(); private static ItemPos pos2 = new ItemPos();
private final Translator tr1 = new Translator(); private final Translator tr1 = new Translator();
private final Translator tr2 = new Translator(); private final Translator tr2 = new Translator();
private final TextureRegion region1 = new TextureRegion(); private final TextureRegion[][] regions = new TextureRegion[7][4];
private final TextureRegion region2 = new TextureRegion();
protected float speed = 0f; protected float speed = 0f;
protected float carryCapacity = 8f; protected float carryCapacity = 8f;
@@ -47,7 +45,7 @@ public class Conveyor extends Block{
group = BlockGroup.transportation; group = BlockGroup.transportation;
hasItems = true; hasItems = true;
autoSleep = true; autoSleep = true;
itemCapacity = Math.round(tilesize / itemSpace); itemCapacity = 4;
} }
private static int compareItems(Long a, Long b){ private static int compareItems(Long a, Long b){
@@ -57,8 +55,7 @@ public class Conveyor extends Block{
} }
@Override @Override
public void setBars(){ public void setBars(){}
}
@Override @Override
public void setStats(){ public void setStats(){
@@ -66,35 +63,71 @@ public class Conveyor extends Block{
stats.add(BlockStat.itemSpeed, speed * 60, StatUnit.pixelsSecond); 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 @Override
public void draw(Tile tile){ public void draw(Tile tile){
ConveyorEntity entity = tile.entity(); ConveyorEntity entity = tile.entity();
byte rotation = tile.getRotation(); 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; @Override
TextureRegion region = Draw.region(name); 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()); if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)){
region2.setRegion(region, region.getRegionWidth() - offset, 0, offset, region.getRegionHeight()); entity.blendbits = 3;
}else if(blends(tile, 1) && blends(tile, 3)){
float x = tile.drawx(), y = tile.drawy(); entity.blendbits = 4;
}else if(blends(tile, 1) && blends(tile, 2)){
if(offset % 2 == 1){ entity.blendbits = 2;
if(point.x < 0) x += 0.75f; }else if(blends(tile, 3) && blends(tile, 2)){
if(point.y < 0) entity.blendbits = 2;
y += 0.5f; entity.blendscly = -1;
else if(point.y > 0) }else if(blends(tile, 0)){
y -= 0.5f; 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, private boolean blends(Tile tile, int direction){
x + (point.x * (tilesize / 2f - region1.getRegionWidth() / 2f)), Tile other = tile.getNearby(Mathf.mod(tile.getRotation() - direction, 4));
y + (point.y * (tilesize / 2f - region1.getRegionWidth() / 2f)), rotation * 90); if(other != null) other = other.target();
Draw.rect(region2,
x - (point.x * (tilesize / 2f - region2.getRegionWidth() / 2f)), if(other == null || !(other.block().hasItems) /*|| !(other.block().outputsLiquid)*/) return false;
y - (point.y * (tilesize / 2f - region2.getRegionWidth() / 2f)), rotation * 90); 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 @Override
@@ -331,6 +364,8 @@ public class Conveyor extends Block{
float minitem = 1; float minitem = 1;
float carrying; float carrying;
float minCarry = 2f; float minCarry = 2f;
int blendbits;
int blendsclx, blendscly;
float clogHeat = 0f; float clogHeat = 0f;

View File

@@ -131,6 +131,7 @@ public class ServerControl extends Module{
handler.register("version", "Displays server version info.", arg -> { handler.register("version", "Displays server version info.", arg -> {
info("&lmVersion: &lyMindustry {0} {1} / {2}", Version.code, Version.type, Version.buildName); info("&lmVersion: &lyMindustry {0} {1} / {2}", Version.code, Version.type, Version.buildName);
info("&lmJava Version: &ly{0}", System.getProperty("java.version"));
}); });
handler.register("exit", "Exit the server application.", arg -> { handler.register("exit", "Exit the server application.", arg -> {