This commit is contained in:
Anuken
2020-03-13 22:33:37 -04:00
parent 06e94b1800
commit 808615a77c
19 changed files with 102 additions and 27 deletions

View File

@@ -173,6 +173,8 @@ public class Tile implements Position{
if(block.isMultiblock()){
int offsetx = -(block.size - 1) / 2;
int offsety = -(block.size - 1) / 2;
Tilec entity = this.entity;
Block block = this.block;
//two passes: first one clears, second one sets
for(int pass = 0; pass < 2; pass++){
@@ -198,6 +200,9 @@ public class Tile implements Position{
}
}
}
this.entity = entity;
this.block = block;
}
}

View File

@@ -65,8 +65,18 @@ public class Tiles implements Iterable<Tile>{
return get(Point2.x(pos), Point2.y(pos));
}
public void each(Cons<Tile> cons){
for(Tile tile : array){
cons.get(tile);
}
}
@Override
public Iterator<Tile> iterator(){
if(iterator.index != 0 && iterator.index != array.length){
iterator.index = 0;
throw new IllegalArgumentException("Double iteration. " + iterator.index + " != " + array.length);
}
iterator.index = 0;
return iterator;
}

View File

@@ -3,7 +3,7 @@ package mindustry.world;
public interface WorldContext{
/** Return a tile in the tile array.*/
Tile tile(int x, int y);
Tile tile(int index);
/** Create the tile array.*/
void resize(int width, int height);

View File

@@ -118,11 +118,15 @@ public class Conveyor extends Block implements Autotiler{
int blendbits;
int blendsclx, blendscly;
boolean everupdated = false;
float clogHeat = 0f;
@Override
public void draw(){
if(!everupdated){
Log.info("--DID NOT UPDATE {0}", tile);
}
byte rotation = tile.rotation();
int frame = clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * timeScale())) % 4) : 0;
Draw.rect(regions[Mathf.clamp(blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], x, y,
@@ -142,6 +146,7 @@ public class Conveyor extends Block implements Autotiler{
blendbits = bits[0];
blendsclx = bits[1];
blendscly = bits[2];
everupdated = true;
if(tile.front() != null && tile.front() != null){
next = tile.front();

View File

@@ -0,0 +1,11 @@
package mindustry.world.blocks.legacy;
import mindustry.world.*;
/** Any subclass of this will be removed upon world load. */
public class LegacyBlock extends Block{
public LegacyBlock(String name){
super(name);
}
}

View File

@@ -0,0 +1,25 @@
package mindustry.world.blocks.legacy;
import arc.util.io.*;
import mindustry.gen.*;
import mindustry.world.*;
public class LegacyMechPad extends Block{
public LegacyMechPad(String name){
super(name);
update = true;
}
public class LegacyMechPadEntity extends TileEntity{
@Override
public void read(Reads read, byte revision){
super.read(read, revision);
//read 3 floats for pad data, and discard them
read.f();
read.f();
read.f();
}
}
}

View File

@@ -204,7 +204,7 @@ public class Drill extends Block{
float progress;
int index;
float warmup;
float drillTime;
float timeDrilled;
float lastDrillSpeed;
int dominantItems;
@@ -249,7 +249,7 @@ public class Drill extends Block{
dump(dominantItem);
}
drillTime += warmup * delta();
timeDrilled += warmup * delta();
if(items.total() < itemCapacity && dominantItems > 0 && consValid()){
@@ -263,8 +263,7 @@ public class Drill extends Block{
lastDrillSpeed = (speed * dominantItems * warmup) / (drillTime + hardnessDrillMultiplier * dominantItem.hardness);
warmup = Mathf.lerpDelta(warmup, speed, warmupSpeed);
progress += delta()
* dominantItems * speed * warmup;
progress += delta() * dominantItems * speed * warmup;
if(Mathf.chance(Time.delta() * updateEffectChance * warmup))
updateEffect.at(getX() + Mathf.range(size * 2f), getY() + Mathf.range(size * 2f));
@@ -305,7 +304,7 @@ public class Drill extends Block{
Draw.color();
}
Draw.rect(rotatorRegion, x, y, drillTime * rotateSpeed);
Draw.rect(rotatorRegion, x, y, timeDrilled * rotateSpeed);
Draw.rect(topRegion, x, y);