More logic commands
This commit is contained in:
@@ -208,7 +208,7 @@ abstract class BuilderComp implements Unitc{
|
||||
BuildPlan plan = buildPlan();
|
||||
Tile tile = world.tile(plan.x, plan.y);
|
||||
|
||||
if(dst(tile) > buildingRange && !state.isEditor()){
|
||||
if((dst(tile) > buildingRange && !state.isEditor()) || !plan.initialized){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1247,7 +1247,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return switch(sensor){
|
||||
case type -> block;
|
||||
case firstItem -> items == null ? null : items.first();
|
||||
case name -> block.name;
|
||||
case config -> block.configurations.containsKey(Item.class) || block.configurations.containsKey(Liquid.class) ? config() : null;
|
||||
default -> noSensed;
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{
|
||||
return mineTile != null && !(((Object)this) instanceof Builderc && ((Builderc)(Object)this).activelyBuilding());
|
||||
}
|
||||
|
||||
public boolean validMine(Tile tile){
|
||||
return !(tile == null || tile.block() != Blocks.air || !within(tile.worldx(), tile.worldy(), miningRange)
|
||||
|| tile.drop() == null || !canMine(tile.drop()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
Building core = closestCore();
|
||||
@@ -49,8 +54,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{
|
||||
}
|
||||
}
|
||||
|
||||
if(mineTile == null || core == null || mineTile.block() != Blocks.air || dst(mineTile.worldx(), mineTile.worldy()) > miningRange
|
||||
|| mineTile.drop() == null || !canMine(mineTile.drop())){
|
||||
if(core == null || !validMine(mineTile)){
|
||||
mineTile = null;
|
||||
mineTimer = 0f;
|
||||
}else if(mining()){
|
||||
|
||||
@@ -104,7 +104,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
public Object senseObject(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case type -> type;
|
||||
case name -> controller instanceof Player p ? p.name : type.name;
|
||||
case name -> controller instanceof Player p ? p.name : null;
|
||||
case firstItem -> stack().amount == 0 ? null : item();
|
||||
default -> noSensed;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user