mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 21:33:28 +08:00
UXAssist: add a minor option to auto logistics config
This commit is contained in:
@@ -29,6 +29,7 @@ public static class LogisticsPatch
|
||||
public static ConfigEntry<int> AutoConfigPLSMinPilerValue; // 0~4; 0 = Maximum in tech, 1~4 = piler stacking count
|
||||
public static ConfigEntry<int> AutoConfigPLSDroneCount; // 0~50
|
||||
// ILS config
|
||||
public static ConfigEntry<bool> SetDefaultRemoteLogicToStorage;
|
||||
public static ConfigEntry<int> AutoConfigILSChargePower; // 2~20, display as 15000000.0 * value
|
||||
public static ConfigEntry<int> AutoConfigILSMaxTripDrone; // 1~180, by degress
|
||||
public static ConfigEntry<int> AutoConfigILSMaxTripShip; // 1~41; 1~20 = value LY, 21-40 = 2*value-20LY, 41 = Unlimited
|
||||
@@ -54,6 +55,7 @@ public static class LogisticsPatch
|
||||
{
|
||||
AutoConfigLogisticsEnabled.SettingChanged += (_, _) => AutoConfigLogistics.Enable(AutoConfigLogisticsEnabled.Value);
|
||||
AutoConfigLimitAutoReplenishCount.SettingChanged += (_, _) => AutoConfigLogistics.ToggleLimitAutoReplenishCount();
|
||||
SetDefaultRemoteLogicToStorage.SettingChanged += (_, _) => AutoConfigLogisticsSetDefaultRemoteLogicToStorage.Enable(SetDefaultRemoteLogicToStorage.Value);
|
||||
LogisticsCapacityTweaksEnabled.SettingChanged += (_, _) => LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value);
|
||||
AllowOverflowInLogisticsEnabled.SettingChanged += (_, _) => AllowOverflowInLogistics.Enable(AllowOverflowInLogisticsEnabled.Value);
|
||||
LogisticsConstrolPanelImprovementEnabled.SettingChanged += (_, _) => LogisticsConstrolPanelImprovement.Enable(LogisticsConstrolPanelImprovementEnabled.Value);
|
||||
@@ -64,6 +66,7 @@ public static class LogisticsPatch
|
||||
public static void Start()
|
||||
{
|
||||
AutoConfigLogistics.Enable(AutoConfigLogisticsEnabled.Value);
|
||||
AutoConfigLogisticsSetDefaultRemoteLogicToStorage.Enable(SetDefaultRemoteLogicToStorage.Value);
|
||||
LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value);
|
||||
AllowOverflowInLogistics.Enable(AllowOverflowInLogisticsEnabled.Value);
|
||||
LogisticsConstrolPanelImprovement.Enable(LogisticsConstrolPanelImprovementEnabled.Value);
|
||||
@@ -80,6 +83,7 @@ public static class LogisticsPatch
|
||||
GameLogic.OnGameBegin -= RealtimeLogisticsInfoPanel.OnGameBegin;
|
||||
|
||||
AutoConfigLogistics.Enable(false);
|
||||
AutoConfigLogisticsSetDefaultRemoteLogicToStorage.Enable(false);
|
||||
LogisticsCapacityTweaks.Enable(false);
|
||||
AllowOverflowInLogistics.Enable(false);
|
||||
LogisticsConstrolPanelImprovement.Enable(false);
|
||||
@@ -275,6 +279,33 @@ public static class LogisticsPatch
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoConfigLogisticsSetDefaultRemoteLogicToStorage : PatchImpl<AutoConfigLogisticsSetDefaultRemoteLogicToStorage>
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIControlPanelStationStorage), nameof(UIControlPanelStationStorage.OnItemPickerReturn))]
|
||||
[HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnItemPickerReturn))]
|
||||
private static IEnumerable<CodeInstruction> UIStationStorage_OnItemPickerReturn_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(StationComponent), nameof(StationComponent.isStellar))),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Brtrue_S || ci.opcode == OpCodes.Brtrue),
|
||||
new CodeMatch(OpCodes.Ldc_I4_0),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Br_S || ci.opcode == OpCodes.Br),
|
||||
new CodeMatch(OpCodes.Ldc_I4_1),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(GameMain), nameof(GameMain.mainPlayer)))
|
||||
);
|
||||
if (matcher.IsValid) {
|
||||
matcher.RemoveInstructions(7).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0)
|
||||
);
|
||||
}
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
public class LogisticsCapacityTweaks : PatchImpl<LogisticsCapacityTweaks>
|
||||
{
|
||||
private static KeyCode _lastKey = KeyCode.None;
|
||||
|
||||
@@ -490,8 +490,8 @@ public class MyWindowWithTabs : MyWindow
|
||||
var textTrans = btn.transform.Find("Text");
|
||||
var btnText = textTrans.GetComponent<Text>();
|
||||
var shadow = textTrans.GetComponent<Shadow>() ?? textTrans.gameObject.AddComponent<Shadow>();
|
||||
shadow.effectColor = new Color(0f, 0f, 0f, 0.6f);
|
||||
shadow.effectDistance = new Vector2(1f, -2f);
|
||||
shadow.effectColor = new Color(0f, 0f, 0f, 0.4f);
|
||||
shadow.effectDistance = new Vector2(1f, -1f);
|
||||
btnText.text = label.Translate();
|
||||
btnText.fontSize = 16;
|
||||
btn.data = index;
|
||||
|
||||
@@ -87,6 +87,7 @@ public static class UIConfigWindow
|
||||
I18N.Add("PLS", "PLS", "行星物流站");
|
||||
I18N.Add("ILS", "ILS", "星际物流站");
|
||||
I18N.Add("Advanced Mining Machine", "Advanced Mining Machine", "大型采矿机");
|
||||
I18N.Add("Set default remote logic to storage", "Set default remote logic to storage", "设置默认远程逻辑为仓储");
|
||||
I18N.Add("Max. Charging Power", "Max. Charging Power", "最大充能功率");
|
||||
I18N.Add("Count of Bots filled", "Count of Bots filled", "填充的配送机数量");
|
||||
I18N.Add("Drone transport range", "Drone transport range", "运输机最远路程");
|
||||
@@ -557,9 +558,11 @@ public static class UIConfigWindow
|
||||
}
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab3, LogisticsPatch.AutoConfigLogisticsEnabled, "Auto-config logistic stations");
|
||||
y += 24f;
|
||||
wnd.AddCheckBox(10f, y, tab3, LogisticsPatch.AutoConfigLimitAutoReplenishCount, "Limit auto-replenish count to values below", 13).WithSmallerBox();
|
||||
y += 26f;
|
||||
wnd.AddCheckBox(x + 10f, y, tab3, LogisticsPatch.AutoConfigLimitAutoReplenishCount, "Limit auto-replenish count to values below", 13).WithSmallerBox();
|
||||
y += 18f;
|
||||
wnd.AddCheckBox(x + 10f, y, tab3, LogisticsPatch.SetDefaultRemoteLogicToStorage, "Set default remote logic to storage", 13).WithSmallerBox();
|
||||
y += 16f;
|
||||
var maxWidth = 0f;
|
||||
wnd.AddText2(10f, y, tab3, "Dispenser", 14, "text-dispenser");
|
||||
y += 18f;
|
||||
|
||||
@@ -142,6 +142,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
||||
"Auto-config logistic stations");
|
||||
LogisticsPatch.AutoConfigLimitAutoReplenishCount = Config.Bind("Factory", "AutoConfigLimitAutoReplenishCount", false,
|
||||
"Limit auto-replenish count to config values");
|
||||
LogisticsPatch.SetDefaultRemoteLogicToStorage = Config.Bind("Factory", "AutoConfigSetDefaultRemoteLogicToStorage", false,
|
||||
"Set default remote logic to storage");
|
||||
LogisticsPatch.AutoConfigDispenserChargePower = Config.Bind("Factory", "AutoConfigDispenserChargePower", 30, new ConfigDescription("LD: Max. Charging Power", new AcceptableValueRange<int>(3, 30)));
|
||||
LogisticsPatch.AutoConfigDispenserCourierCount = Config.Bind("Factory", "AutoConfigDispenserCourierCount", 10, new ConfigDescription("LD: Count of Bots filled", new AcceptableValueRange<int>(0, 10)));
|
||||
LogisticsPatch.AutoConfigBattleBaseChargePower = Config.Bind("Factory", "AutoConfigBattleBaseChargePower", 8, new ConfigDescription("Battlefield Analysis Base: Max. Charging Power", new AcceptableValueRange<int>(4, 40)));
|
||||
|
||||
Reference in New Issue
Block a user