Logic sensor (#10795)
* Add `selectedBlock` logic sensor * Add `buildX`/`buildY`/`building` logic sensors * Change `building` from boolean to the building * `breaking` * Make `breaking`/`building` more consistent * Allow blocks/content to be null * Change `selectedBlock` from air to null * Change `selectedBlock` from air to null * Make `selectedBlock` SyncLocal * Add `selectedRotation`
This commit is contained in:
@@ -212,8 +212,19 @@ public class ConstructBlock extends Block{
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.progress) return Mathf.clamp(progress);
|
||||
return super.sense(sensor);
|
||||
return switch(sensor){
|
||||
case progress -> Mathf.clamp(progress);
|
||||
case breaking -> activeDeconstruct ? 1 : 0;
|
||||
default -> super.sense(sensor);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object senseObject(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case building -> current;
|
||||
default -> super.senseObject(sensor);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.ConstructBlock.*;
|
||||
@@ -264,5 +265,21 @@ public class BuildTurret extends BaseTurret{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case buildX, buildY -> unit.sense(sensor);
|
||||
default -> super.sense(sensor);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object senseObject(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case building, breaking -> unit.senseObject(sensor);
|
||||
default -> super.senseObject(sensor);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user