1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 22:13:30 +08:00
This commit is contained in:
2024-05-23 22:04:54 +08:00
parent c8a0651ae2
commit c7b5303da2
3 changed files with 66 additions and 15 deletions

View File

@@ -27,6 +27,7 @@ public static class FactoryPatch
public static ConfigEntry<bool> DoNotRenderEntitiesEnabled;
public static ConfigEntry<bool> DragBuildPowerPolesEnabled;
public static ConfigEntry<bool> AllowOverflowInLogisticsEnabled;
public static ConfigEntry<bool> GreaterPowerUsageInLogisticsEnabled;
private static PressKeyBind _doNotRenderEntitiesKey;
private static Harmony _factoryPatch;
@@ -56,6 +57,7 @@ public static class FactoryPatch
DoNotRenderEntitiesEnabled.SettingChanged += (_, _) => DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value);
DragBuildPowerPolesEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value);
AllowOverflowInLogisticsEnabled.SettingChanged += (_, _) => AllowOverflowInLogistics.Enable(AllowOverflowInLogisticsEnabled.Value);
GreaterPowerUsageInLogisticsEnabled.SettingChanged += (_, _) => LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value);
UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
NightLight.Enable(NightLightEnabled.Value);
@@ -70,6 +72,7 @@ public static class FactoryPatch
DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value);
DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value);
AllowOverflowInLogistics.Enable(AllowOverflowInLogisticsEnabled.Value);
GreaterPowerUsageInLogistics.Enable(GreaterPowerUsageInLogisticsEnabled.Value);
_factoryPatch ??= Harmony.CreateAndPatchAll(typeof(FactoryPatch));
}
@@ -90,6 +93,7 @@ public static class FactoryPatch
DoNotRenderEntities.Enable(false);
DragBuildPowerPoles.Enable(false);
AllowOverflowInLogistics.Enable(false);
GreaterPowerUsageInLogistics.Enable(false);
_factoryPatch?.UnpatchSelf();
_factoryPatch = null;
@@ -884,47 +888,50 @@ public static class FactoryPatch
return true;
}
public static void OnUpdate()
public static void UpdateInput()
{
if (_lastKey != KeyCode.None && Input.GetKeyUp(_lastKey))
{
_lastKey = KeyCode.None;
}
if (!VFInput.noModifier) return;
if (VFInput.shift) return;
var ctrl = VFInput.control;
var alt = VFInput.alt;
if (ctrl && alt) return;
int delta;
if (UpdateKeyPressed(KeyCode.LeftArrow))
{
if (VFInput.control)
if (ctrl)
delta = -100000;
else if (VFInput.alt)
else if (alt)
delta = -1000;
else
delta = -10;
}
else if (UpdateKeyPressed(KeyCode.RightArrow))
{
if (VFInput.control)
if (ctrl)
delta = 100000;
else if (VFInput.alt)
else if (alt)
delta = 1000;
else
delta = 10;
}
else if (UpdateKeyPressed(KeyCode.DownArrow))
{
if (VFInput.control)
if (ctrl)
delta = -1000000;
else if (VFInput.alt)
else if (alt)
delta = -10000;
else
delta = -100;
}
else if (UpdateKeyPressed(KeyCode.UpArrow))
{
if (VFInput.control)
if (ctrl)
delta = 1000000;
else if (VFInput.alt)
else if (alt)
delta = 10000;
else
delta = 100;
@@ -953,7 +960,7 @@ public static class FactoryPatch
int itemCountMax;
if (AllowOverflowInLogisticsEnabled.Value)
{
itemCountMax = 1000000000;
itemCountMax = 90000000;
}
else
{
@@ -1795,5 +1802,44 @@ public static class FactoryPatch
);
return matcher.InstructionEnumeration();
}
}
// Remove storage limit check
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.SetStationStorage))]
private static IEnumerable<CodeInstruction> PlanetTransport_SetStationStorage_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(ci => ci.IsLdarg()),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(OpCodes.Add),
new CodeMatch(ci => ci.Branches(out _)),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(OpCodes.Add),
new CodeMatch(ci => ci.IsStarg())
);
var labels = matcher.Labels;
matcher.RemoveInstructions(9).Labels.AddRange(labels);
return matcher.InstructionEnumeration();
}
}
private static class GreaterPowerUsageInLogistics
{
private static Harmony _patch;
public static void Enable(bool enable)
{
if (enable)
{
_patch ??= Harmony.CreateAndPatchAll(typeof(GreaterPowerUsageInLogistics));
return;
}
_patch?.UnpatchSelf();
_patch = null;
}
}
}

View File

@@ -45,6 +45,7 @@ public static class UIConfigWindow
I18N.Add("Do not render factory entities", "Do not render factory entities (except belts and sorters)", "不渲染工厂建筑实体(除了传送带和分拣器)");
I18N.Add("Drag building power poles in maximum connection range", "Drag building power poles in maximum connection range", "拖动建造电线杆时自动使用最大连接距离间隔");
I18N.Add("Allow overflow for Logistic Stations and Advanced Mining Machines", "Allow overflow for Logistic Stations and Advanced Mining Machines", "允许物流站和大型采矿机物品溢出");
I18N.Add("Increase maximum power usage in Logistic Stations and Advanced Mining Machines", "Increase maximum power usage in Logistic Stations and Advanced Mining Machines", "提升物流塔和大型采矿机的最大功耗");
I18N.Add("Auto navigation on sailings", "Auto navigation on sailings", "宇宙航行时自动导航");
I18N.Add("Enable auto-cruise", "Enable auto-cruise", "启用自动巡航");
I18N.Add("Auto boost", "Auto boost", "自动加速");
@@ -121,11 +122,13 @@ public static class UIConfigWindow
MyWindow.AddTipsButton(x, y, tab2, "Protect veins from exhaustion", "Protect veins from exhaustion tips", "protect-veins-tips");
x = 0f;
y += 30f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.DoNotRenderEntitiesEnabled, "Do not render factory entities");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.DragBuildPowerPolesEnabled, "Drag building power poles in maximum connection range");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.AllowOverflowInLogisticsEnabled, "Allow overflow for Logistic Stations and Advanced Mining Machines");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.GreaterPowerUsageInLogisticsEnabled, "Increase maximum power usage in Logistic Stations and Advanced Mining Machines");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.DoNotRenderEntitiesEnabled, "Do not render factory entities");
x = 400f;
y = 10f;
wnd.AddButton(x, y, tab2, "Initialize This Planet", 16, "button-init-planet", () =>

View File

@@ -80,6 +80,8 @@ public class UXAssist : BaseUnityPlugin
"Drag building power poles in maximum connection range");
FactoryPatch.AllowOverflowInLogisticsEnabled = Config.Bind("Factory", "AllowOverflowInLogistics", false,
"Allow overflow in logistic stations");
FactoryPatch.GreaterPowerUsageInLogisticsEnabled = Config.Bind("Factory", "GreaterPowerUsageInLogistics", false,
"Increase maximum power usage in Logistic Stations and Advanced Mining Machines");
PlanetFunctions.OrbitalCollectorMaxBuildCount = Config.Bind("Factory", "OCMaxBuildCount", 0, "Maximum Orbital Collectors to build once, set to 0 to build as many as possible");
PlayerPatch.EnhancedMechaForgeCountControlEnabled = Config.Bind("Player", "EnhancedMechaForgeCountControl", false,
"Enhanced count control for hand-make, increases maximum of count to 1000, and you can hold Ctrl/Shift/Alt to change the count rapidly");
@@ -134,7 +136,7 @@ public class UXAssist : BaseUnityPlugin
if (VFInput.inputing) return;
if (VFInput.onGUI)
{
FactoryPatch.LogisticsCapacityTweaks.OnUpdate();
FactoryPatch.LogisticsCapacityTweaks.UpdateInput();
}
if (_toggleKey.keyValue)
{