Merged Unit & Builder components / Cleanup

This commit is contained in:
Anuken 2020-11-17 19:40:18 -05:00
parent 8280166485
commit 527be41e32
38 changed files with 152 additions and 125 deletions

View file

@ -59,7 +59,7 @@ public class DesktopInput extends InputHandler{
group.fill(t -> {
t.bottom();
t.visible(() -> {
t.color.a = Mathf.lerpDelta(t.color.a, player.builder().isBuilding() ? 1f : 0f, 0.15f);
t.color.a = Mathf.lerpDelta(t.color.a, player.unit().isBuilding() ? 1f : 0f, 0.15f);
return ui.hudfrag.shown && Core.settings.getBool("hints") && selectRequests.isEmpty() && t.color.a > 0.01f;
});
@ -290,7 +290,7 @@ public class DesktopInput extends InputHandler{
cursorType = cursor.build.getCursor();
}
if(isPlacing() || !selectRequests.isEmpty()){
if((isPlacing() && player.isBuilder()) || !selectRequests.isEmpty()){
cursorType = SystemCursor.hand;
}
@ -366,7 +366,7 @@ public class DesktopInput extends InputHandler{
int rawCursorX = World.toTile(Core.input.mouseWorld().x), rawCursorY = World.toTile(Core.input.mouseWorld().y);
// automatically pause building if the current build queue is empty
if(Core.settings.getBool("buildautopause") && isBuilding && !player.builder().isBuilding()){
if(Core.settings.getBool("buildautopause") && isBuilding && !player.unit().isBuilding()){
isBuilding = false;
buildWasAutoPaused = true;
}
@ -388,7 +388,7 @@ public class DesktopInput extends InputHandler{
}
if(Core.input.keyTap(Binding.clear_building)){
player.builder().clearBuilding();
player.unit().clearBuilding();
}
if(Core.input.keyTap(Binding.schematic_select) && !Core.scene.hasKeyboard() && mode != breaking){
@ -480,8 +480,8 @@ public class DesktopInput extends InputHandler{
deleting = true;
}else if(selected != null){
//only begin shooting if there's no cursor event
if(!tileTapped(selected.build) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && !player.builder().activelyBuilding() && !droppingItem &&
!tryBeginMine(selected) && player.unit().mineTile() == null && !Core.scene.hasKeyboard()){
if(!tileTapped(selected.build) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && !player.unit().activelyBuilding() && !droppingItem &&
!tryBeginMine(selected) && player.unit().mineTile == null && !Core.scene.hasKeyboard()){
player.shooting = shouldShoot;
}
}else if(!Core.scene.hasKeyboard()){ //if it's out of bounds, shooting is just fine
@ -506,7 +506,7 @@ public class DesktopInput extends InputHandler{
if(Core.input.keyDown(Binding.select) && mode == none && !isPlacing() && deleting){
BuildPlan req = getRequest(cursorX, cursorY);
if(req != null && req.breaking){
player.builder().plans().remove(req);
player.unit().plans().remove(req);
}
}else{
deleting = false;
@ -547,7 +547,7 @@ public class DesktopInput extends InputHandler{
if(sreq != null){
if(getRequest(sreq.x, sreq.y, sreq.block.size, sreq) != null){
player.builder().plans().remove(sreq, true);
player.unit().plans().remove(sreq, true);
}
sreq = null;
}