1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-22 05:47:44 +03:00

Sleeping system changes

This commit is contained in:
Anuken 2018-07-19 18:10:29 -04:00
parent bcf72b894d
commit 882790d133
4 changed files with 16 additions and 3 deletions

View File

@ -103,6 +103,17 @@ public class TileEntity extends BaseEntity implements TargetTrait{
* If the entity was sleeping, this enables it. This also resets the sleep timer.
*/
public void wakeUp(){
noSleep();
for(Tile tile : proximity){
if(tile.entity.isSleeping()){
tile.entity.wakeUp();
}
}
}
/**Call when this entity is updating. This wakes it up.*/
public void noSleep(){
sleepTime = 0f;
if(sleeping){
add();

View File

@ -72,7 +72,7 @@ public abstract class BaseBlock{
}
public void onProximityUpdate(Tile tile){
if(tile.entity != null) tile.entity.wakeUp();
if(tile.entity != null) tile.entity.noSleep();
}
public void handleItem(Item item, Tile tile, Tile source){

View File

@ -105,7 +105,7 @@ public class Conduit extends LiquidBlock{
if(tile.entity.liquids.total() > 0.001f && tile.entity.timer.get(timerFlow, 1)){
tryMoveLiquid(tile, tile.getNearby(tile.getRotation()), true, tile.entity.liquids.current());
entity.wakeUp();
entity.noSleep();
}else{
entity.sleep();
}

View File

@ -176,7 +176,7 @@ public class Conveyor extends Block{
public void unitOn(Tile tile, Unit unit){
ConveyorEntity entity = tile.entity();
entity.wakeUp();
entity.noSleep();
float speed = this.speed * tilesize / 2.3f;
float centerSpeed = 0.1f;
@ -267,6 +267,8 @@ public class Conveyor extends Block{
if(totalMoved/Timers.delta() <= 0.0001f){
entity.sleep();
}else{
entity.noSleep();
}
if(minremove != Integer.MAX_VALUE) entity.convey.truncate(minremove);