mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-04 16:09:23 +07:00
More optimization
This commit is contained in:
parent
9a3245c23e
commit
621233a5b3
@ -125,7 +125,7 @@ public class Teams{
|
||||
}
|
||||
|
||||
private void updateEnemies(){
|
||||
if(!active.contains(get(state.rules.waveTeam))){
|
||||
if(state.rules.waves && !active.contains(get(state.rules.waveTeam))){
|
||||
active.add(get(state.rules.waveTeam));
|
||||
}
|
||||
|
||||
|
@ -274,8 +274,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
|
||||
/** Try offloading an item to a nearby container in its facing direction. Returns true if success. */
|
||||
public boolean offloadDir(Tile tile, Item item){
|
||||
Tile other = tile.getNearby(tile.rotation());
|
||||
if(other != null) other = other.link();
|
||||
Tile other = tile.front();
|
||||
if(other != null && other.getTeam() == tile.getTeam() && other.block().acceptItem(item, other, tile)){
|
||||
other.block().handleItem(item, other, tile);
|
||||
return true;
|
||||
|
@ -96,7 +96,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
|
||||
if(tile.front() != null && tile.front().entity != null){
|
||||
entity.next = tile.front().entity;
|
||||
entity.nextc = entity.next instanceof ConveyorEntity ? (ConveyorEntity)entity.next : null;
|
||||
entity.nextc = entity.next instanceof ConveyorEntity && entity.next.getTeam() == tile.getTeam() ? (ConveyorEntity)entity.next : null;
|
||||
entity.aligned = entity.nextc != null && tile.rotation() == entity.next.tile.rotation();
|
||||
}
|
||||
}
|
||||
@ -174,7 +174,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
e.mid = 0;
|
||||
|
||||
//skip updates if possible
|
||||
if(e.items.total() == 0){
|
||||
if(e.len == 0){
|
||||
e.clogHeat = 0f;
|
||||
e.sleep();
|
||||
return;
|
||||
@ -192,7 +192,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
if(e.ys[i] > 0.5 && i > 0) e.mid = i - 1;
|
||||
e.xs[i] = Mathf.approachDelta(e.xs[i], 0, 0.1f);
|
||||
|
||||
if(e.ys[i] >= 0.9999f && offloadDir(tile, e.ids[i])){
|
||||
if(e.ys[i] >= 1f && offloadDir(tile, e.ids[i])){
|
||||
//align X position if passing forwards
|
||||
if(e.nextc != null && e.aligned){
|
||||
e.nextc.xs[e.nextc.lastInserted] = e.xs[i];
|
||||
@ -205,7 +205,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
}
|
||||
|
||||
if(e.minitem < itemSpace){
|
||||
if(e.minitem < itemSpace + (e.blendbits == 1 ? 0.5f : 0f)){
|
||||
e.clogHeat = Mathf.lerpDelta(e.clogHeat, 1f, 0.02f);
|
||||
}else{
|
||||
e.clogHeat = 0f;
|
||||
@ -239,13 +239,14 @@ public class Conveyor extends Block implements Autotiler{
|
||||
for(int i = 0; i < e.len; i++){
|
||||
if(e.ids[i] == item){
|
||||
e.remove(i);
|
||||
e.items.remove(item, 1);
|
||||
removed ++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e.items.remove(item, removed);
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ public class ApplicationTests{
|
||||
|
||||
world.loadMap(testMap);
|
||||
state.set(State.playing);
|
||||
int length = 10;
|
||||
int length = 128;
|
||||
world.tile(0, 0).setBlock(Blocks.itemSource);
|
||||
world.tile(0, 0).configureAny(Items.copper.id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user