canWithdraw() + changes to displayable() (#6902)

* `shouldDiplay()` + `canWithdraw()`

* Better implementation of `displayable()`
This commit is contained in:
MEEPofFaith 2022-06-08 06:17:30 -07:00 committed by GitHub
parent 968651d9ed
commit 5cc314672f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View File

@ -613,6 +613,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
Fx.unitDrop.at(unit); Fx.unitDrop.at(unit);
} }
public boolean canWithdraw(){
return true;
}
public boolean canUnload(){ public boolean canUnload(){
return block.unloadable; return block.unloadable;
} }
@ -1342,11 +1346,6 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
public ItemModule flowItems(){ public ItemModule flowItems(){
return items; return items;
} }
public boolean displayable(){
return true;
}
@Override @Override
public void display(Table table){ public void display(Table table){
//display the block stuff //display the block stuff

View File

@ -4,5 +4,9 @@ import arc.scene.ui.layout.*;
/** An interface for things that can be displayed when hovered over. */ /** An interface for things that can be displayed when hovered over. */
public interface Displayable{ public interface Displayable{
default boolean displayable(){
return true;
}
void display(Table table); void display(Table table);
} }

View File

@ -70,6 +70,8 @@ public class BlockInventoryFragment{
} }
private void takeItem(int requested){ private void takeItem(int requested){
if(!build.canWithdraw()) return;
//take everything //take everything
int amount = Math.min(requested, player.unit().maxAccepted(lastItem)); int amount = Math.min(requested, player.unit().maxAccepted(lastItem));

View File

@ -577,7 +577,7 @@ public class PlacementFragment{
if(Core.scene.hasMouse() || topTable.hit(v.x, v.y, false) != null) return null; if(Core.scene.hasMouse() || topTable.hit(v.x, v.y, false) != null) return null;
//check for a unit //check for a unit
Unit unit = Units.closestOverlap(player.team(), Core.input.mouseWorldX(), Core.input.mouseWorldY(), 5f, u -> !u.isLocal()); Unit unit = Units.closestOverlap(player.team(), Core.input.mouseWorldX(), Core.input.mouseWorldY(), 5f, u -> !u.isLocal() && u.displayable());
//if cursor has a unit, display it //if cursor has a unit, display it
if(unit != null) return unit; if(unit != null) return unit;