Delete old requests, pause building

This commit is contained in:
Anuken
2019-10-07 20:26:08 -04:00
parent 9aec61020d
commit 9fdc4a2c45
6 changed files with 57 additions and 7 deletions

View File

@ -216,7 +216,9 @@ quit.confirm.tutorial = Are you sure you know what you're doing?\nThe tutorial c
loading = [accent]Loading...
reloading = [accent]Reloading Mods...
saving = [accent]Saving...
cancelbuilding = [accent][[{0}][] to clear buildings
cancelbuilding = [accent][[{0}][] to clear plan
pausebuilding = [accent][[{0}][] to pause building
resumebuilding = [scarlet][[{0}][] to resume building
wave = [accent]Wave {0}
wave.waiting = [lightgray]Wave in {0}
wave.waveInProgress = [lightgray]Wave in progress
@ -561,6 +563,7 @@ category.optional = Optional Enhancements
setting.landscape.name = Lock Landscape
setting.shadows.name = Shadows
setting.linear.name = Linear Filtering
setting.hints.name = Hints
setting.animatedwater.name = Animated Water
setting.animatedshields.name = Animated Shields
setting.antialias.name = Antialias[lightgray] (requires restart)[]
@ -632,6 +635,7 @@ keybind.zoom_hold.name = Zoom Hold
keybind.zoom.name = Zoom
keybind.menu.name = Menu
keybind.pause.name = Pause
keybind.pause_building.name = Pause/Resume Building
keybind.minimap.name = Minimap
keybind.dash.name = Dash
keybind.chat.name = Chat

View File

@ -49,7 +49,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
public String name = "noname";
public @Nullable
String uuid, usid;
public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile, isTyping;
public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile, isTyping, isBuilding = true;
public float boostHeat, shootHeat, destructTime;
public boolean achievedFlight;
public Color color = new Color();
@ -356,7 +356,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
if(dead) return;
if(isBuilding()){
if(!state.isPaused()){
if(!state.isPaused() && isBuilding){
drawBuilding();
}
}else{
@ -448,6 +448,18 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
//region update methods
@Override
public void updateMechanics(){
if(isBuilding){
updateBuilding();
}
//mine only when not building
if(buildRequest() == null){
updateMining();
}
}
@Override
public void update(){
hitTime -= Time.delta();
@ -480,7 +492,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
}
BuildRequest request = buildRequest();
if(isBuilding() && request.tile() != null && (request.tile().withinDst(x, y, placeDistance) || state.isEditor())){
if(isBuilding() && isBuilding && request.tile() != null && (request.tile().withinDst(x, y, placeDistance) || state.isEditor())){
loops.play(Sounds.build, request.tile(), 0.75f);
}
@ -780,6 +792,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
placeQueue.clear();
dead = true;
lastText = null;
isBuilding = true;
textFadeTime = 0f;
target = null;
moveTarget = null;
@ -873,7 +886,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
public void write(DataOutput buffer) throws IOException{
super.writeSave(buffer, !isLocal);
TypeIO.writeStringData(buffer, name);
buffer.writeByte(Pack.byteValue(isAdmin) | (Pack.byteValue(dead) << 1) | (Pack.byteValue(isBoosting) << 2) | (Pack.byteValue(isTyping) << 3));
buffer.writeByte(Pack.byteValue(isAdmin) | (Pack.byteValue(dead) << 1) | (Pack.byteValue(isBoosting) << 2) | (Pack.byteValue(isTyping) << 3)| (Pack.byteValue(isBuilding) << 4));
buffer.writeInt(Color.rgba8888(color));
buffer.writeByte(mech.id);
buffer.writeInt(mining == null ? noSpawner : mining.pos());
@ -895,6 +908,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
dead = (bools & 2) != 0;
boolean boosting = (bools & 4) != 0;
isTyping = (bools & 8) != 0;
boolean building = (bools & 16) != 0;
color.set(buffer.readInt());
mech = content.getByID(ContentType.mech, buffer.readByte());
int mine = buffer.readInt();
@ -913,6 +927,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
velocity.y = lastvy;
}else{
mining = world.tile(mine);
isBuilding = building;
isBoosting = boosting;
}

View File

@ -13,6 +13,7 @@ public enum Binding implements KeyBind{
deselect(KeyCode.MOUSE_RIGHT),
break_block(KeyCode.MOUSE_RIGHT),
clear_building(KeyCode.Q),
pause_building(KeyCode.E),
rotate(new Axis(KeyCode.SCROLL)),
rotateplaced(KeyCode.R),
diagonal_placement(KeyCode.CONTROL_LEFT),

View File

@ -33,6 +33,8 @@ public class DesktopInput extends InputHandler{
private float selectScale;
/** Selected build request for movement. */
private @Nullable BuildRequest sreq;
/** Whether player is currently deleting removal requests. */
private boolean deleting = false;
@Override
public boolean isDrawing(){
@ -43,7 +45,13 @@ public class DesktopInput extends InputHandler{
public void buildUI(Group group){
group.fill(t -> {
t.bottom().update(() -> t.getColor().a = Mathf.lerpDelta(t.getColor().a, player.isBuilding() ? 1f : 0f, 0.15f));
t.table(Styles.black6, b -> b.add(Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.name())).style(Styles.outlineLabel)).margin(10f);
t.visible(() -> Core.settings.getBool("hints"));
t.table(Styles.black6, b -> {
b.defaults().left();
b.label(() -> Core.bundle.format(!player.isBuilding ? "resumebuilding" : "pausebuilding", Core.keybinds.get(Binding.pause_building).key.name())).style(Styles.outlineLabel);
b.row();
b.add(Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.name())).style(Styles.outlineLabel);
}).margin(10f);
});
}
@ -212,6 +220,10 @@ public class DesktopInput extends InputHandler{
lineRequests.clear();
}
if(Core.input.keyTap(Binding.pause_building)){
player.isBuilding = !player.isBuilding;
}
if((cursorX != lastLineX || cursorY != lastLineY) && isPlacing() && mode == placing){
updateLine(selectX, selectY);
lastLineX = cursorX;
@ -230,6 +242,8 @@ public class DesktopInput extends InputHandler{
updateLine(selectX, selectY);
}else if(req != null && !req.breaking && mode == none){
sreq = req;
}else if(req != null && req.breaking){
deleting = true;
}else if(selected != null){
//only begin shooting if there's no cursor event
if(!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && player.buildQueue().size == 0 && !droppingItem &&
@ -244,11 +258,21 @@ public class DesktopInput extends InputHandler{
mode = none;
}else if(Core.input.keyTap(Binding.break_block) && !Core.scene.hasMouse()){
//is recalculated because setting the mode to breaking removes potential multiblock cursor offset
deleting = false;
mode = breaking;
selectX = tileX(Core.input.mouseX());
selectY = tileY(Core.input.mouseY());
}
if(Core.input.keyDown(Binding.select) && mode == none && !isPlacing() && deleting){
BuildRequest req = getRequest(cursorX, cursorY);
if(req != null && req.breaking){
player.buildQueue().remove(req);
}
}else{
deleting = false;
}
if(mode == placing && block != null){
if(!overrideLineRotation && !Core.input.keyDown(Binding.diagonal_placement) && (selectX != cursorX || selectY != cursorY) && ((int) Core.input.axisTap(Binding.rotate) != 0)){
rotation = ((int)((Angles.angle(selectX, selectY, cursorX, cursorY) + 45) / 90f)) % 4;
@ -274,7 +298,7 @@ public class DesktopInput extends InputHandler{
if(sreq != null){
if(getRequest(sreq.x, sreq.y, sreq.block.size, sreq) != null){
player.buildQueue().removeValue(sreq, true);
player.buildQueue().remove(sreq, true);
}
sreq = null;
}

View File

@ -518,6 +518,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
ui.hudGroup.addChild(uiGroup);
buildUI(uiGroup);
}
if(player != null){
player.isBuilding = true;
}
}
public boolean canShoot(){

View File

@ -225,6 +225,8 @@ public class SettingsMenuDialog extends SettingsDialog{
game.checkPref("savecreate", true);
game.checkPref("hints", true);
if(steam){
game.checkPref("publichost", false, i -> {
platform.updateLobby();