mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-13 00:05:23 +07:00
Sleeping system changes
This commit is contained in:
parent
bcf72b894d
commit
882790d133
@ -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();
|
||||
|
@ -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){
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user