Skip to content

Commit

Permalink
快速装填:默认不往塑钢/桥中装填
Browse files Browse the repository at this point in the history
  • Loading branch information
way-zer committed Dec 22, 2024
1 parent 3f7d6ca commit 8775d92
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions assets/bundles/bundle-mdtx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ setting.autoFill.cooldown.name = 操作冷却(ms)
setting.autoFill.cooldown.description = 过小的值可能导致被服务器踢出
setting.autoFill.minFill.name = 最小装填个数
setting.autoFill.fillStorageBlock.name = 允许往容器/仓库内填充
setting.autoFill.fillDistribution.name = 允许往塑钢/桥中填充
setting.radarMode.name = [acid]雷达模式
setting.radarSize.name = [acid]雷达大小
#end SettingsV2
Expand Down
16 changes: 11 additions & 5 deletions src/mindustryX/features/AutoFill.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import mindustry.Vars
import mindustry.game.EventType
import mindustry.gen.Building
import mindustry.gen.Call
import mindustry.type.Category
import mindustry.world.blocks.storage.StorageBlock

/** 一键装弹
Expand All @@ -18,10 +19,12 @@ object AutoFill {
@JvmField
var enable = false
private val transferredThisTick = mutableSetOf<Building>()
val cooldown = SettingsV2.SliderPref(0, 3000, 100).create("autoFill.cooldown", 300)
val minFill = SettingsV2.SliderPref(1, 20, 1).create("autoFill.minFill", 5)
val fillStorageBlock = SettingsV2.CheckPref.create("autoFill.fillStorageBlock")
val settings = listOf(cooldown, minFill, fillStorageBlock)
private val cooldown = SettingsV2.SliderPref(0, 3000, 100).create("autoFill.cooldown", 300)
private val minFill = SettingsV2.SliderPref(1, 20, 1).create("autoFill.minFill", 5)
private val fillStorageBlock = SettingsV2.CheckPref.create("autoFill.fillStorageBlock")
private val fillDistribution = SettingsV2.CheckPref.create("autoFill.fillDistribution")
val settings = listOf(cooldown, minFill, fillStorageBlock, fillDistribution)

private var timer = Interval()

private fun justTransferred(build: Building): Boolean {
Expand All @@ -31,7 +34,10 @@ object AutoFill {

private fun tryFill(build: Building) {
val player = Vars.player ?: return
if ((!fillStorageBlock.value && build.block is StorageBlock) || build.team != player.team()) return
if (build.team != player.team()
|| (!fillStorageBlock.value && build.block is StorageBlock)
|| (!fillDistribution.value && build.block.category == Category.distribution) || build.team != player.team()
) return
val item = player.unit()?.item() ?: return
if (build.within(player, Vars.itemTransferRange) && build.acceptStack(item, 9999, player.unit()) >= minFill.value) {
if (justTransferred(build)) return
Expand Down
4 changes: 2 additions & 2 deletions src/mindustryX/features/UIExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import static mindustry.Vars.*;

public class UIExt{
public static SettingsV2.Data<Integer> quickToolOffset = new SettingsV2.SliderPref(-250, 250, 10).create("quickToolOffset", 0);

public static TeamSelectDialog teamSelect;
public static ModsRecommendDialog modsRecommend = new ModsRecommendDialog();
public static TeamsStatDisplay teamsStatDisplay;
Expand All @@ -29,8 +31,6 @@ public class UIExt{
public static WaveInfoDisplay waveInfoDisplay = new WaveInfoDisplay();
public static NewCoreItemsDisplay coreItems = new NewCoreItemsDisplay();

public static SettingsV2.Data<Integer> quickToolOffset = new SettingsV2.SliderPref(-250, 250, 10).create("quickToolOffset", 0);

public static void init(){
teamSelect = new TeamSelectDialog();

Expand Down

0 comments on commit 8775d92

Please sign in to comment.