Skip to content

Commit

Permalink
Fix autoohno
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Nov 13, 2023
1 parent fe03fb3 commit c16cc1b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
3 changes: 1 addition & 2 deletions core/src/mindustry/client/ClientLogic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import mindustry.client.navigation.*
import mindustry.client.navigation.Navigation.stopFollowing
import mindustry.client.ui.*
import mindustry.client.utils.*
import mindustry.content.*
import mindustry.core.*
import mindustry.game.EventType.*
import mindustry.gen.*
Expand Down Expand Up @@ -87,7 +86,7 @@ class ClientLogic {
if (!syncing) {
AutoTransfer.enabled = settings.getBool("autotransfer") && !(state.rules.pvp && Server.io())
Server.ohnoTask?.cancel()
Server.ohnoTask = if (Server.fish() && settings.getBool("autoohno", false)) Timer.schedule({ if (player.tileOn()?.block() ?: Blocks.air != Blocks.air) Call.sendChatMessage("/ohno") }, 3f, 0.3f) else null
Server.ohnoTask = if (Server.fish() && settings.getBool("autoohno", false)) Server.ohno() else null
frozenPlans.clear()

when (val vote = settings.getInt("automapvote")) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/mindustry/client/Commands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ fun setupCommands() {

if (confirmed) {
plans.chunked(200) { configs.add { Call.deletePlans(player, it.toIntArray()) } }
player.sendMessage("[accent]Removed ${plans.size} plans, ${player.team().data().plans.size} remain")
player.sendMessage("[accent]Removed ${plans.size} plans, ${player.team().data().plans.size - plans.size} remain")
} else player.sendMessage("[accent]Found ${plans.size} (out of ${player.team().data().plans.size}) block ghosts within turret range, run [coral]!clearghosts c[] to remove them")
}

Expand Down Expand Up @@ -728,7 +728,7 @@ fun setupCommands() {
if (!Server.fish()) return@register
player.sendMessage("[accent]Running auto ohno") // FINISHME: Bundle
Server.ohnoTask?.cancel()
Server.ohnoTask = Timer.schedule({ Call.sendChatMessage("/ohno") }, 0f, 0.3f)
Server.ohnoTask = Server.ohno()
}

// Special commands
Expand Down
3 changes: 3 additions & 0 deletions core/src/mindustry/client/utils/ServerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,6 @@ fun handleKick(reason: String) {

}
}

// FINISHME: The jank is growing worse. The servers really need their own classes
fun Server.Companion.ohno(): Timer.Task = Timer.schedule({ if (!player.blockOn().solid && UnitTypes.alpha.supportsEnv(state.rules.env)) Call.sendChatMessage("/ohno") }, 3f, 0.3f)
31 changes: 16 additions & 15 deletions core/src/mindustry/ui/fragments/HudFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,13 @@ public void build(Group parent){

// button to skip wave
s.button(Icon.play, rightStyle, 30f, () -> {
if(net.client() && player.admin){
if(!canSkipWave()) new Toast(1f).add("You tried and that's all that matters.");
else if(net.client() && (player.admin || Server.current.adminui())){
Call.adminRequest(player, AdminAction.wave, null);
}else{
logic.skipWave();
}
}).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).name("skip").get().toBack();
}).growY().fillX().right().width(40f).name("skip").get().toBack();
}).width(dsize * 5 + 4f).name("statustable");

if(Core.settings.getBool("activemodesdisplay", true)){
Expand Down Expand Up @@ -898,18 +899,18 @@ public void draw(){

lcell[0] = table.labelWrap(() -> {

//update padding depend on whether the button to the right is there
boolean can = canSkipWave();
if(can != couldSkip[0]){
if(canSkipWave()){
lcell[0].padRight(8f);
}else{
lcell[0].padRight(-42f);
}
table.invalidateHierarchy();
table.pack();
couldSkip[0] = can;
}
// //update padding depend on whether the button to the right is there
// boolean can = canSkipWave();
// if(can != couldSkip[0]){
// if(canSkipWave()){
// lcell[0].padRight(8f);
// }else{
// lcell[0].padRight(-42f);
// }
// table.invalidateHierarchy();
// table.pack();
// couldSkip[0] = can;
// }

builder.setLength(0);

Expand Down Expand Up @@ -1054,7 +1055,7 @@ private void addInfoTable(Table table){
}

private boolean canSkipWave(){
return state.rules.waves && (state.rules.winWave <= 0 || state.wave < state.rules.winWave) && ((net.server() || player.admin) || !net.active()) /* && state.enemies == 0 && !spawner.isSpawning() */;
return state.rules.waves && (state.rules.winWave <= 0 || state.wave < state.rules.winWave) && (net.server() || player.admin || !net.active() || Server.current.adminui()) /* && state.enemies == 0 && !spawner.isSpawning() */;
}

}

0 comments on commit c16cc1b

Please sign in to comment.