1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-02-05 03:02:20 +08:00

Compare commits

6 Commits

Author SHA1 Message Date
2456280151 UXAssist: finished auto construct 2026-02-05 02:58:27 +08:00
0d090ddfb0 work in progress 2026-02-04 22:55:38 +08:00
39578559aa UXAssist: Auto construct 2026-02-04 22:04:02 +08:00
157c86112b optimized batch building 2026-02-04 14:54:06 +08:00
d0c20693e3 updated dlls 2026-02-04 14:49:48 +08:00
8ae88f4b41 CheatEnabler: Immediate Build fix optimization 2026-02-04 13:22:29 +08:00
19 changed files with 257 additions and 60 deletions

View File

@@ -16,7 +16,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
</ItemGroup> </ItemGroup>

View File

@@ -175,7 +175,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
if (!architect) continue; if (!architect) continue;
pb.itemRequired = 0; pb.itemRequired = 0;
} }
CargoTrafficPatch.TryStartBatchBuilding(factory);
CargoTrafficPatch.InstantBuild(player, factory, i); CargoTrafficPatch.InstantBuild(player, factory, i);
} }
CargoTrafficPatch.TryEndBatchBuilding(factory); CargoTrafficPatch.TryEndBatchBuilding(factory);
@@ -201,6 +200,8 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
private static readonly HashSet<int> _alterPathRendererIds = []; private static readonly HashSet<int> _alterPathRendererIds = [];
private static readonly HashSet<int> _refreshPathUVIds = []; private static readonly HashSet<int> _refreshPathUVIds = [];
public static bool IsBatchBuilding => _isBatchBuilding;
public static void StartBatchBuilding(PlanetFactory factory) public static void StartBatchBuilding(PlanetFactory factory)
{ {
factory.BeginFlattenTerrain(); factory.BeginFlattenTerrain();
@@ -211,12 +212,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
_anyBelt = false; _anyBelt = false;
} }
public static void TryStartBatchBuilding(PlanetFactory factory)
{
if (_isBatchBuilding) return;
StartBatchBuilding(factory);
}
public static void EndBatchBuilding(PlanetFactory factory) public static void EndBatchBuilding(PlanetFactory factory)
{ {
PlanetFactory.batchBuild = false; PlanetFactory.batchBuild = false;
@@ -260,6 +255,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
public static void InstantBuild(Player player, PlanetFactory factory, int id) public static void InstantBuild(Player player, PlanetFactory factory, int id)
{ {
if (!_isBatchBuilding) StartBatchBuilding(factory);
_anyBelt = _anyBelt || _beltIds.Contains(factory.prebuildPool[id].protoId); _anyBelt = _anyBelt || _beltIds.Contains(factory.prebuildPool[id].protoId);
factory.BuildFinally(player, id, false); factory.BuildFinally(player, id, false);
} }
@@ -442,41 +438,85 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();
} }
[HarmonyTranspiler] [HarmonyPrefix]
[HarmonyPatch(typeof(ConstructionModuleComponent), nameof(ConstructionModuleComponent.PlaceItems))]
private static IEnumerable<CodeInstruction> ConstructionModuleComponent_PlaceItems_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldarg_1),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PlanetFactory), nameof(PlanetFactory.constructionSystem))),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PrebuildData), nameof(PrebuildData.id))),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(OpCodes.Ldflda, AccessTools.Field(typeof(PrebuildData), nameof(PrebuildData.pos))),
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(ConstructionSystem), nameof(ConstructionSystem.AddBuildTargetToModules)))
);
matcher.Repeat(codeMatcher =>
{
codeMatcher.Advance(4).InsertAndAdvance(
new CodeInstruction(OpCodes.Dup),
new CodeInstruction(OpCodes.Ldarg_1),
Transpilers.EmitDelegate((int objId, PlanetFactory factory) =>
{
CargoTrafficPatch.TryStartBatchBuilding(factory);
CargoTrafficPatch.InstantBuild(GameMain.mainPlayer, factory, objId);
})
)
.Advance(3);
});
return matcher.InstructionEnumeration();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ConstructionSystem), nameof(ConstructionSystem.GameTick))] [HarmonyPatch(typeof(ConstructionSystem), nameof(ConstructionSystem.GameTick))]
private static void ConstructionSystem_GameTick_Postfix(ConstructionSystem __instance) private static void ConstructionSystem_GameTick_Prefix(ConstructionSystem __instance, long time)
{ {
CargoTrafficPatch.TryEndBatchBuilding(__instance.factory); if (time % 6 != 0) return;
var factory = __instance.factory;
if (factory.prebuildCount <= 0) return;
var player = GameMain.mainPlayer;
var total = factory.prebuildCursor - 1;
var stepCount = total switch {
< 256 => 1,
< 2048 => 3,
< 16384 => 10,
_ => 20,
};
var step = (int)(time / 6 % stepCount);
var start = 1 + total * step / stepCount;
var end = 1 + total * (step + 1) / stepCount;
for (var i = start; i < end; i++)
{
ref var prebuild = ref factory.prebuildPool[i];
if (prebuild.id != i || prebuild.isDestroyed) continue;
if (prebuild.itemRequired > 0)
{
int itemId = prebuild.protoId;
int count = prebuild.itemRequired;
player.package.TakeTailItems(ref itemId, ref count, out var _, false);
if (count > 0)
{
prebuild.itemRequired -= count;
if (prebuild.itemRequired <= 0)
{
CargoTrafficPatch.InstantBuild(player, factory, i);
}
}
}
}
if (CargoTrafficPatch.IsBatchBuilding)
{
for (var i = start - 1; i > 0; i--)
{
ref var prebuild = ref factory.prebuildPool[i];
if (prebuild.id != i || prebuild.isDestroyed) continue;
if (prebuild.itemRequired > 0)
{
int itemId = prebuild.protoId;
int count = prebuild.itemRequired;
player.package.TakeTailItems(ref itemId, ref count, out var _, false);
if (count > 0)
{
prebuild.itemRequired -= count;
if (prebuild.itemRequired <= 0)
{
CargoTrafficPatch.InstantBuild(player, factory, i);
}
}
}
}
for (var i = end; i <= total; i++)
{
ref var prebuild = ref factory.prebuildPool[i];
if (prebuild.id != i || prebuild.isDestroyed) continue;
if (prebuild.itemRequired > 0)
{
int itemId = prebuild.protoId;
int count = prebuild.itemRequired;
player.package.TakeTailItems(ref itemId, ref count, out var _, false);
if (count > 0)
{
prebuild.itemRequired -= count;
if (prebuild.itemRequired <= 0)
{
CargoTrafficPatch.InstantBuild(player, factory, i);
}
}
}
}
CargoTrafficPatch.EndBatchBuilding(factory);
}
} }
/* /*

View File

@@ -19,7 +19,7 @@
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" /> <PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
<PackageReference Include="DysonSphereProgram.Modding.NebulaMultiplayerModApi" Version="2.0.0" /> <PackageReference Include="DysonSphereProgram.Modding.NebulaMultiplayerModApi" Version="2.0.0" />
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -15,7 +15,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -16,7 +16,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -16,7 +16,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -15,7 +15,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -16,7 +16,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -17,7 +17,7 @@
<PackageReference Include="NLua" Version="1.*" /> <PackageReference Include="NLua" Version="1.*" />
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
<PackageReference Include="obs-websocket-dotnet" Version="5.*" /> <PackageReference Include="obs-websocket-dotnet" Version="5.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" /> -->
</ItemGroup> </ItemGroup>

View File

@@ -16,7 +16,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -18,7 +18,7 @@
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" /> <PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -16,7 +16,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -33,6 +33,9 @@ public static class UIFunctions
I18N.Add("Enable auto-cruise", "Enable auto-cruise", "启用自动巡航"); I18N.Add("Enable auto-cruise", "Enable auto-cruise", "启用自动巡航");
I18N.Add("Disable auto-cruise", "Disable auto-cruise", "禁用自动巡航"); I18N.Add("Disable auto-cruise", "Disable auto-cruise", "禁用自动巡航");
I18N.Add("Enable auto-construct", "Enable auto-construct", "启用自动建造");
I18N.Add("Disable auto-construct", "Disable auto-construct", "禁用自动建造");
I18N.Add("Buildings to construct: {0}", "Buildings to construct: {0}", "待建造数量: {0}");
I18N.Add("High yield", "High yield", "高产"); I18N.Add("High yield", "High yield", "高产");
I18N.Add("Perfect", "Perfect", "完美"); I18N.Add("Perfect", "Perfect", "完美");
I18N.Add("Union results", "Union results", "结果取并集"); I18N.Add("Union results", "Union results", "结果取并集");
@@ -136,6 +139,7 @@ public static class UIFunctions
} }
} }
InitToggleAutoCruiseCheckButton(); InitToggleAutoCruiseCheckButton();
InitToggleAutoConstructCheckButton();
InitStarmapButtons(); InitStarmapButtons();
_initialized = true; _initialized = true;
} }
@@ -171,15 +175,17 @@ public static class UIFunctions
public static void InitToggleAutoCruiseCheckButton() public static void InitToggleAutoCruiseCheckButton()
{ {
var lowGroup = GameObject.Find("UI Root/Overlay Canvas/In Game/Low Group"); var lowGroup = GameObject.Find("UI Root/Overlay Canvas/In Game/Low Group");
ToggleAutoCruise = MyCheckButton.CreateCheckButton(0, 0, lowGroup.GetComponent<RectTransform>(), Patches.PlayerPatch.AutoCruiseEnabled).WithSize(120f, 40f); ToggleAutoCruise = MyCheckButton.CreateCheckButton(0, 0, lowGroup.GetComponent<RectTransform>(), Patches.PlayerPatch.AutoCruiseEnabled).WithSize(160f, 40f);
UpdateToggleAutoCruiseCheckButtonVisiblility();
ToggleAutoCruiseChecked();
ToggleAutoCruise.OnChecked += ToggleAutoCruiseChecked;
var rectTrans = ToggleAutoCruise.rectTrans; var rectTrans = ToggleAutoCruise.rectTrans;
rectTrans.anchorMax = new Vector2(0.5f, 0f); rectTrans.anchorMax = new Vector2(0.5f, 0f);
rectTrans.anchorMin = new Vector2(0.5f, 0f); rectTrans.anchorMin = new Vector2(0.5f, 0f);
rectTrans.pivot = new Vector2(0.5f, 0f); rectTrans.pivot = new Vector2(0.5f, 0f);
rectTrans.anchoredPosition3D = new Vector3(0f, 185f, 0f); rectTrans.anchoredPosition3D = new Vector3(0f, 185f, 0f);
rectTrans.localScale = new Vector3(1f, 1f, 1f);
UpdateToggleAutoCruiseCheckButtonVisiblility();
ToggleAutoCruiseChecked();
ToggleAutoCruise.OnChecked += ToggleAutoCruiseChecked;
static void ToggleAutoCruiseChecked() static void ToggleAutoCruiseChecked()
{ {
if (ToggleAutoCruise.Checked) if (ToggleAutoCruise.Checked)
@@ -201,6 +207,82 @@ public static class UIFunctions
} }
#endregion #endregion
#region ToggleAutoConstructCheckButton
public static UI.MyCheckButton ToggleAutoConstruct;
public static GameObject ConstructCountPanel;
public static Text ConstructCountText;
public static void InitToggleAutoConstructCheckButton()
{
var lowGroup = GameObject.Find("UI Root/Overlay Canvas/In Game/Low Group");
var parent = lowGroup.GetComponent<RectTransform>();
ToggleAutoConstruct = MyCheckButton.CreateCheckButton(0, 0, parent, Patches.FactoryPatch.AutoConstructEnabled).WithSize(160f, 40f);
var rectTrans = ToggleAutoConstruct.rectTrans;
rectTrans.anchorMax = new Vector2(0.5f, 0f);
rectTrans.anchorMin = new Vector2(0.5f, 0f);
rectTrans.pivot = new Vector2(0.5f, 0f);
rectTrans.anchoredPosition3D = new Vector3(0f, 140f, 0f);
rectTrans.localScale = new Vector3(1f, 1f, 1f);
ConstructCountPanel = new GameObject("uxassist-construct-count-panel");
rectTrans = ConstructCountPanel.AddComponent<RectTransform>();
rectTrans.SetParent(parent);
rectTrans.anchorMax = new Vector2(0.5f, 0f);
rectTrans.anchorMin = new Vector2(0.5f, 0f);
rectTrans.pivot = new Vector2(0.5f, 0f);
rectTrans.anchoredPosition3D = new Vector3(0f, 116f, 0f);
rectTrans.localScale = new Vector3(1f, 1f, 1f);
rectTrans.sizeDelta = new Vector2(160f, 24f);
var bg = ConstructCountPanel.AddComponent<Image>();
bg.color = new Color(0.2f, 0.2f, 0.2f, 0.6f);
ConstructCountText = GameObject.Instantiate(UIRoot.instance.uiGame.assemblerWindow.stateText);
ConstructCountText.gameObject.name = "construct-count-text";
ConstructCountText.text = String.Format("Buildings to construct: {0}".Translate(), 0);
ConstructCountText.color = new Color(1f, 1f, 1f, 0.4f);
ConstructCountText.alignment = TextAnchor.MiddleLeft;
ConstructCountText.fontSize = 16;
rectTrans = ConstructCountText.rectTransform;
rectTrans.SetParent(ConstructCountPanel.transform);
rectTrans.sizeDelta = new Vector2(150f, 20f);
rectTrans.anchorMax = new Vector2(0.5f, 0.5f);
rectTrans.anchorMin = new Vector2(0.5f, 0.5f);
rectTrans.pivot = new Vector2(0.5f, 0.5f);
rectTrans.anchoredPosition3D = new Vector3(0f, 0f, 0f);
rectTrans.localScale = new Vector3(1f, 1f, 1f);
UpdateToggleAutoConstructCheckButtonVisiblility();
ToggleAutoConstructChecked();
ToggleAutoConstruct.OnChecked += ToggleAutoConstructChecked;
static void ToggleAutoConstructChecked()
{
if (ToggleAutoConstruct.Checked)
{
ToggleAutoConstruct.SetLabelText("Disable auto-construct");
}
else
{
ToggleAutoConstruct.SetLabelText("Enable auto-construct");
}
}
}
public static void UpdateToggleAutoConstructCheckButtonVisiblility()
{
if (ToggleAutoConstruct == null) return;
var localPlanet = GameMain.localPlanet;
var active = localPlanet != null && localPlanet.factoryLoaded && localPlanet.factory.prebuildCount > 0;
ToggleAutoConstruct.gameObject.SetActive(active);
ConstructCountPanel.gameObject.SetActive(active);
}
public static void UpdateConstructCountText(int count)
{
if (ConstructCountText == null) return;
ConstructCountText.text = String.Format("Buildings to construct: {0}".Translate(), count);
}
#endregion
#region StarMapButtons #region StarMapButtons
private static int _cornerComboBoxIndex; private static int _cornerComboBoxIndex;
private static string[] _starOrderNames; private static string[] _starOrderNames;

View File

@@ -32,6 +32,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
public static ConfigEntry<bool> DoNotRenderEntitiesEnabled; public static ConfigEntry<bool> DoNotRenderEntitiesEnabled;
public static ConfigEntry<bool> DragBuildPowerPolesEnabled; public static ConfigEntry<bool> DragBuildPowerPolesEnabled;
public static ConfigEntry<bool> DragBuildPowerPolesAlternatelyEnabled; public static ConfigEntry<bool> DragBuildPowerPolesAlternatelyEnabled;
public static ConfigEntry<bool> AutoConstructEnabled;
public static ConfigEntry<bool> BeltSignalsForBuyOutEnabled; public static ConfigEntry<bool> BeltSignalsForBuyOutEnabled;
public static ConfigEntry<bool> TankFastFillInAndTakeOutEnabled; public static ConfigEntry<bool> TankFastFillInAndTakeOutEnabled;
public static ConfigEntry<int> TankFastFillInAndTakeOutMultiplier; public static ConfigEntry<int> TankFastFillInAndTakeOutMultiplier;
@@ -123,6 +124,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
DoNotRenderEntitiesEnabled.SettingChanged += (_, _) => DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value); DoNotRenderEntitiesEnabled.SettingChanged += (_, _) => DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value);
DragBuildPowerPolesEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value); DragBuildPowerPolesEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value);
DragBuildPowerPolesAlternatelyEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.AlternatelyChanged(); DragBuildPowerPolesAlternatelyEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.AlternatelyChanged();
AutoConstructEnabled.SettingChanged += (_, _) => Functions.UIFunctions.UpdateToggleAutoConstructCheckButtonVisiblility();
BeltSignalsForBuyOutEnabled.SettingChanged += (_, _) => BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value); BeltSignalsForBuyOutEnabled.SettingChanged += (_, _) => BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
TankFastFillInAndTakeOutEnabled.SettingChanged += (_, _) => TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value); TankFastFillInAndTakeOutEnabled.SettingChanged += (_, _) => TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value);
TankFastFillInAndTakeOutMultiplier.SettingChanged += (_, _) => UpdateTankFastFillInAndTakeOutMultiplierRealValue(); TankFastFillInAndTakeOutMultiplier.SettingChanged += (_, _) => UpdateTankFastFillInAndTakeOutMultiplierRealValue();
@@ -274,6 +276,77 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();
} }
#region Auto Construct
private static int _lastPrebuildCount = -1;
[HarmonyPostfix]
[HarmonyPatch(typeof(PlanetData), nameof(PlanetData.NotifyFactoryLoaded))]
private static void PlanetData_NotifyFactoryLoaded_Postfix()
{
Functions.UIFunctions.UpdateToggleAutoConstructCheckButtonVisiblility();
_lastPrebuildCount = -1;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlanetData), nameof(PlanetData.UnloadFactory))]
private static void PlanetData_UnloadFactory_Postfix()
{
Functions.UIFunctions.UpdateToggleAutoConstructCheckButtonVisiblility();
_lastPrebuildCount = -1;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerAction_Rts), nameof(PlayerAction_Rts.GameTick))]
private static void PlayerAction_Rts_GameTick_Prefix(PlayerAction_Rts __instance, long timei)
{
if (timei % 60L != 0) return;
var planet = GameMain.localPlanet;
if (planet == null || !planet.factoryLoaded) return;
var factory = planet.factory;
var prebuildCount = factory.prebuildCount;
if (_lastPrebuildCount != prebuildCount)
{
if (_lastPrebuildCount <= 0 || prebuildCount == 0)
{
Functions.UIFunctions.UpdateToggleAutoConstructCheckButtonVisiblility();
}
_lastPrebuildCount = prebuildCount;
Functions.UIFunctions.UpdateConstructCountText(prebuildCount);
}
if (prebuildCount <= 0) return;
if (!AutoConstructEnabled.Value) return;
var player = __instance.player;
if (player.orders.orderCount > 0) return;
if (player.movementState == EMovementState.Walk && player.mecha.thrusterLevel >= 1)
{
player.controller.actionWalk.SwitchToFly();
return;
}
var prebuilds = factory.prebuildPool;
var minDist = float.MaxValue;
var minIndex = 0;
var playerPos = player.position;
for (var i = factory.prebuildCursor - 1; i > 0; i--)
{
ref var prebuild = ref prebuilds[i];
if (prebuild.id != i || prebuild.isDestroyed) continue;
if (prebuild.itemRequired > 0)
{
if (player.package.GetItemCount(prebuild.protoId) < prebuild.itemRequired) continue;
}
var dist = (prebuild.pos - playerPos).sqrMagnitude;
if (dist < minDist)
{
minDist = dist;
minIndex = i;
}
}
if (minIndex == 0) return;
if ((prebuilds[minIndex].pos - playerPos).sqrMagnitude < 400f) return;
player.Order(OrderNode.MoveTo(prebuilds[minIndex].pos), false);
}
#endregion
public class NightLight : PatchImpl<NightLight> public class NightLight : PatchImpl<NightLight>
{ {
private static bool _nightlightInitialized; private static bool _nightlightInitialized;

View File

@@ -33,7 +33,7 @@ public class MyCheckButton : MonoBehaviour
openNormalColor = tankWindow.openNormalColor; openNormalColor = tankWindow.openNormalColor;
closeMouseOverColor = tankWindow.closeMouseOverColor; closeMouseOverColor = tankWindow.closeMouseOverColor;
closePressColor = tankWindow.closePressColor; closePressColor = tankWindow.closePressColor;
closeNormalColor = tankWindow.closeNormalColor; closeNormalColor = /*tankWindow.closeNormalColor*/ new Color(0.6557f, 0.9145f, 1f, 0.4f);
var go = Instantiate(UIRoot.instance.uiGame.beltWindow.reverseButton.gameObject); var go = Instantiate(UIRoot.instance.uiGame.beltWindow.reverseButton.gameObject);
go.name = "my-checkbutton"; go.name = "my-checkbutton";
@@ -259,7 +259,7 @@ public class MyCheckButton : MonoBehaviour
{ {
uiButton.transitions[0].mouseoverColor = closeMouseOverColor; uiButton.transitions[0].mouseoverColor = closeMouseOverColor;
uiButton.transitions[0].pressedColor = closePressColor; uiButton.transitions[0].pressedColor = closePressColor;
uiButton.transitions[0].normalColor = new Color(0.6557f, 0.9145f, 1f, 0.0627f); uiButton.transitions[0].normalColor = closeNormalColor;
} }
uiButton.RefreshTransitionsImmediately(); uiButton.RefreshTransitionsImmediately();
} }

View File

@@ -130,6 +130,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
"Drag building power poles in maximum connection range"); "Drag building power poles in maximum connection range");
FactoryPatch.DragBuildPowerPolesAlternatelyEnabled = Config.Bind("Factory", "DragBuildPowerPolesAlternately", true, FactoryPatch.DragBuildPowerPolesAlternatelyEnabled = Config.Bind("Factory", "DragBuildPowerPolesAlternately", true,
"Build Tesla Tower and Wireless Power Tower alternately"); "Build Tesla Tower and Wireless Power Tower alternately");
FactoryPatch.AutoConstructEnabled = Config.Bind("Factory", "AutoConstruct", false,
"Fly toward the building to be constructed automatically");
FactoryPatch.BeltSignalsForBuyOutEnabled = Config.Bind("Factory", "BeltSignalsForBuyOut", false, FactoryPatch.BeltSignalsForBuyOutEnabled = Config.Bind("Factory", "BeltSignalsForBuyOut", false,
"Belt signals for buy out dark fog items automatically"); "Belt signals for buy out dark fog items automatically");
FactoryPatch.TankFastFillInAndTakeOutEnabled = Config.Bind("Factory", "TankFastFillInAndTakeOut", false, FactoryPatch.TankFastFillInAndTakeOutEnabled = Config.Bind("Factory", "TankFastFillInAndTakeOut", false,

View File

@@ -15,7 +15,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="DysonSphereProgram.Modding.CommonAPI" Version="1.*" /> <PackageReference Include="DysonSphereProgram.Modding.CommonAPI" Version="1.*" />
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" /> <PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />

View File

@@ -15,7 +15,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" /> <PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
</ItemGroup> </ItemGroup>

View File

@@ -16,7 +16,7 @@
<PackageReference Include="BepInEx.Core" Version="5.*" /> <PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> --> <!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" /> <PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>