Merged Unit & Builder components / Cleanup
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
@Remote(variants = Variant.one)
|
||||
public static void removeQueueBlock(int x, int y, boolean breaking){
|
||||
player.builder().removeBuild(x, y, breaking);
|
||||
player.unit().removeBuild(x, y, breaking);
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.server)
|
||||
@@ -383,7 +383,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
public Eachable<BuildPlan> allRequests(){
|
||||
return cons -> {
|
||||
for(BuildPlan request : player.builder().plans()) cons.get(request);
|
||||
for(BuildPlan request : player.unit().plans()) cons.get(request);
|
||||
for(BuildPlan request : selectRequests) cons.get(request);
|
||||
for(BuildPlan request : lineRequests) cons.get(request);
|
||||
};
|
||||
@@ -401,7 +401,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
player.typing = ui.chatfrag.shown();
|
||||
|
||||
if(player.isBuilder()){
|
||||
player.builder().updateBuilding(isBuilding);
|
||||
player.unit().updateBuilding(isBuilding);
|
||||
}
|
||||
|
||||
if(player.shooting && !wasShooting && player.unit().hasWeapons() && state.rules.unitAmmo && player.unit().ammo <= 0){
|
||||
@@ -653,7 +653,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
return r2.overlaps(r1);
|
||||
};
|
||||
|
||||
for(BuildPlan req : player.builder().plans()){
|
||||
for(BuildPlan req : player.unit().plans()){
|
||||
if(test.get(req)) return req;
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
Draw.color(Pal.remove);
|
||||
Lines.stroke(1f);
|
||||
|
||||
for(BuildPlan req : player.builder().plans()){
|
||||
for(BuildPlan req : player.unit().plans()){
|
||||
if(req.breaking) continue;
|
||||
if(req.bounds(Tmp.r2).overlaps(Tmp.r1)){
|
||||
drawBreaking(req);
|
||||
@@ -740,7 +740,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
for(BuildPlan req : requests){
|
||||
if(req.block != null && validPlace(req.x, req.y, req.block, req.rotation)){
|
||||
BuildPlan copy = req.copy();
|
||||
player.builder().addBuild(copy);
|
||||
player.unit().addBuild(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -804,7 +804,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
//remove build requests
|
||||
Tmp.r1.set(result.x * tilesize, result.y * tilesize, (result.x2 - result.x) * tilesize, (result.y2 - result.y) * tilesize);
|
||||
|
||||
Iterator<BuildPlan> it = player.builder().plans().iterator();
|
||||
Iterator<BuildPlan> it = player.unit().plans().iterator();
|
||||
while(it.hasNext()){
|
||||
BuildPlan req = it.next();
|
||||
if(!req.breaking && req.bounds(Tmp.r2).overlaps(Tmp.r1)){
|
||||
@@ -1044,7 +1044,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
public boolean canShoot(){
|
||||
return block == null && !onConfigurable() && !isDroppingItem() && !player.builder().activelyBuilding() &&
|
||||
return block == null && !onConfigurable() && !isDroppingItem() && !player.unit().activelyBuilding() &&
|
||||
!(player.unit() instanceof Mechc && player.unit().isFlying());
|
||||
}
|
||||
|
||||
@@ -1090,7 +1090,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
public boolean validPlace(int x, int y, Block type, int rotation, BuildPlan ignore){
|
||||
for(BuildPlan req : player.builder().plans()){
|
||||
for(BuildPlan req : player.unit().plans()){
|
||||
if(req != ignore
|
||||
&& !req.breaking
|
||||
&& req.block.bounds(req.x, req.y, Tmp.r1).overlaps(type.bounds(x, y, Tmp.r2))
|
||||
@@ -1108,15 +1108,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
public void placeBlock(int x, int y, Block block, int rotation){
|
||||
BuildPlan req = getRequest(x, y);
|
||||
if(req != null){
|
||||
player.builder().plans().remove(req);
|
||||
player.unit().plans().remove(req);
|
||||
}
|
||||
player.builder().addBuild(new BuildPlan(x, y, rotation, block, block.nextConfig()));
|
||||
player.unit().addBuild(new BuildPlan(x, y, rotation, block, block.nextConfig()));
|
||||
}
|
||||
|
||||
public void breakBlock(int x, int y){
|
||||
Tile tile = world.tile(x, y);
|
||||
if(tile != null && tile.build != null) tile = tile.build.tile;
|
||||
player.builder().addBuild(new BuildPlan(tile.x, tile.y));
|
||||
player.unit().addBuild(new BuildPlan(tile.x, tile.y));
|
||||
}
|
||||
|
||||
public void drawArrow(Block block, int x, int y, int rotation){
|
||||
|
||||
@@ -114,7 +114,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
for(BuildPlan req : player.builder().plans()){
|
||||
for(BuildPlan req : player.unit().plans()){
|
||||
Tile other = world.tile(req.x, req.y);
|
||||
|
||||
if(other == null || req.breaking) continue;
|
||||
@@ -219,10 +219,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
BuildPlan copy = request.copy();
|
||||
|
||||
if(other == null){
|
||||
player.builder().addBuild(copy);
|
||||
player.unit().addBuild(copy);
|
||||
}else if(!other.breaking && other.x == request.x && other.y == request.y && other.block.size == request.block.size){
|
||||
player.builder().plans().remove(other);
|
||||
player.builder().addBuild(copy);
|
||||
player.unit().plans().remove(other);
|
||||
player.unit().addBuild(copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,10 +245,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Boolp schem = () -> lastSchematic != null && !selectRequests.isEmpty();
|
||||
|
||||
group.fill(t -> {
|
||||
t.visible(() -> (player.builder().isBuilding() || block != null || mode == breaking || !selectRequests.isEmpty()) && !schem.get());
|
||||
t.visible(() -> (player.unit().isBuilding() || block != null || mode == breaking || !selectRequests.isEmpty()) && !schem.get());
|
||||
t.bottom().left();
|
||||
t.button("@cancel", Icon.cancel, () -> {
|
||||
player.builder().clearBuilding();
|
||||
player.unit().clearBuilding();
|
||||
selectRequests.clear();
|
||||
mode = none;
|
||||
block = null;
|
||||
@@ -914,7 +914,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
|
||||
//update shooting if not building + not mining
|
||||
if(!player.builder().isBuilding() && player.unit().mineTile() == null){
|
||||
if(!player.unit().isBuilding() && player.unit().mineTile == null){
|
||||
|
||||
//autofire targeting
|
||||
if(manualShooting){
|
||||
|
||||
Reference in New Issue
Block a user