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

Compare commits

..

9 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
c1428f6aee CheatEnabler: Immediate Build fix 2026-02-04 03:07:25 +08:00
260e419855 UXAssist 1.5.2 2026-02-04 03:07:05 +08:00
6e0484f035 UXAssist v1.5.2 2026-01-31 00:28:56 +08:00
24 changed files with 339 additions and 74 deletions

Binary file not shown.

Binary file not shown.

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

@@ -119,9 +119,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
} }
private static HashSet<int> _beltIds = []; private static HashSet<int> _beltIds = [];
private static HashSet<int> _alterBeltRendererIds;
private static HashSet<int> _alterPathRendererIds;
private static HashSet<int> _refreshPathUVIds;
private static void OnDataLoaded() private static void OnDataLoaded()
{ {
@@ -168,16 +165,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
var prebuilds = factory.prebuildPool; var prebuilds = factory.prebuildPool;
if (imm) if (imm)
{ {
var anyBelt = false; var player = GameMain.mainPlayer;
var anyBuilt = false;
_alterBeltRendererIds ??= [];
_alterPathRendererIds ??= [];
_refreshPathUVIds ??= [];
CargoTrafficPatch.IsBatchBuilding = true;
factory.BeginFlattenTerrain();
factory.cargoTraffic._batch_buffer_no_refresh = true;
PlanetFactory.batchBuild = true;
CargoTrafficPatch.DisableRefreshBatchesBuffers = true;
for (var i = factory.prebuildCursor - 1; i > 0; i--) for (var i = factory.prebuildCursor - 1; i > 0; i--)
{ {
ref var pb = ref prebuilds[i]; ref var pb = ref prebuilds[i];
@@ -187,14 +175,49 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
if (!architect) continue; if (!architect) continue;
pb.itemRequired = 0; pb.itemRequired = 0;
} }
anyBelt = anyBelt || _beltIds.Contains(pb.protoId); CargoTrafficPatch.InstantBuild(player, factory, i);
factory.BuildFinally(GameMain.mainPlayer, i, false);
anyBuilt = true;
} }
CargoTrafficPatch.TryEndBatchBuilding(factory);
}
else if (architect)
{
for (var i = factory.prebuildCursor - 1; i > 0; i--)
{
ref var pb = ref prebuilds[i];
if (pb.id != i || pb.isDestroyed || pb.itemRequired == 0) continue;
pb.itemRequired = 0;
factory.AlterPrebuildModelState(i);
}
}
}
private class CargoTrafficPatch : PatchImpl<CargoTrafficPatch>
{
private static bool _isBatchBuilding;
private static bool _disableRefreshBatchesBuffers;
private static bool _anyBelt;
private static readonly HashSet<int> _alterBeltRendererIds = [];
private static readonly HashSet<int> _alterPathRendererIds = [];
private static readonly HashSet<int> _refreshPathUVIds = [];
public static bool IsBatchBuilding => _isBatchBuilding;
public static void StartBatchBuilding(PlanetFactory factory)
{
factory.BeginFlattenTerrain();
factory.cargoTraffic._batch_buffer_no_refresh = true;
PlanetFactory.batchBuild = true;
_isBatchBuilding = true;
_disableRefreshBatchesBuffers = true;
_anyBelt = false;
}
public static void EndBatchBuilding(PlanetFactory factory)
{
PlanetFactory.batchBuild = false; PlanetFactory.batchBuild = false;
factory.cargoTraffic._batch_buffer_no_refresh = false; factory.cargoTraffic._batch_buffer_no_refresh = false;
factory.EndFlattenTerrain(); factory.EndFlattenTerrain();
CargoTrafficPatch.IsBatchBuilding = false; _isBatchBuilding = false;
var cargoTraffic = factory.cargoTraffic; var cargoTraffic = factory.cargoTraffic;
var entityPool = factory.entityPool; var entityPool = factory.entityPool;
var colChunks = factory.planet.physics?.colChunks; var colChunks = factory.planet.physics?.colChunks;
@@ -213,40 +236,36 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
_alterBeltRendererIds.Clear(); _alterBeltRendererIds.Clear();
_alterPathRendererIds.Clear(); _alterPathRendererIds.Clear();
_refreshPathUVIds.Clear(); _refreshPathUVIds.Clear();
CargoTrafficPatch.DisableRefreshBatchesBuffers = false; _disableRefreshBatchesBuffers = false;
if (anyBelt) if (_anyBelt)
{ {
factory.cargoTraffic.RefreshBeltBatchesBuffers(); factory.cargoTraffic.RefreshBeltBatchesBuffers();
factory.cargoTraffic.RefreshPathBatchesBuffers(); factory.cargoTraffic.RefreshPathBatchesBuffers();
} }
if (anyBuilt) _anyBelt = false;
{
factory.planet.physics?.raycastLogic?.NotifyBatchObjectRemove(); factory.planet.physics?.raycastLogic?.NotifyBatchObjectRemove();
factory.planet.audio?.SetPlanetAudioDirty(); factory.planet.audio?.SetPlanetAudioDirty();
} }
}
else if (architect) public static void TryEndBatchBuilding(PlanetFactory factory)
{ {
for (var i = factory.prebuildCursor - 1; i > 0; i--) if (!_isBatchBuilding) return;
{ EndBatchBuilding(factory);
ref var pb = ref prebuilds[i];
if (pb.id != i || pb.isDestroyed || pb.itemRequired == 0) continue;
pb.itemRequired = 0;
factory.AlterPrebuildModelState(i);
}
}
} }
private class CargoTrafficPatch : PatchImpl<CargoTrafficPatch> public static void InstantBuild(Player player, PlanetFactory factory, int id)
{ {
public static bool IsBatchBuilding; if (!_isBatchBuilding) StartBatchBuilding(factory);
public static bool DisableRefreshBatchesBuffers; _anyBelt = _anyBelt || _beltIds.Contains(factory.prebuildPool[id].protoId);
factory.BuildFinally(player, id, false);
}
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPriority(Priority.First)] [HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterBeltRenderer))] [HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterBeltRenderer))]
private static bool CargoTraffic_AlterBeltRenderer_Prefix(int beltId) private static bool CargoTraffic_AlterBeltRenderer_Prefix(int beltId)
{ {
if (!IsBatchBuilding) return true; if (!_isBatchBuilding) return true;
_alterBeltRendererIds.Add(beltId); _alterBeltRendererIds.Add(beltId);
return false; return false;
} }
@@ -256,7 +275,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterPathRenderer))] [HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.AlterPathRenderer))]
private static bool CargoTraffic_AlterPathRenderer_Prefix(int pathId) private static bool CargoTraffic_AlterPathRenderer_Prefix(int pathId)
{ {
if (!IsBatchBuilding) return true; if (!_isBatchBuilding) return true;
_alterPathRendererIds.Add(pathId); _alterPathRendererIds.Add(pathId);
return false; return false;
} }
@@ -266,7 +285,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshPathUV))] [HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshPathUV))]
private static bool CargoTraffic_RefreshPathUV_Prefix(int pathId) private static bool CargoTraffic_RefreshPathUV_Prefix(int pathId)
{ {
if (!IsBatchBuilding) return true; if (!_isBatchBuilding) return true;
_refreshPathUVIds.Add(pathId); _refreshPathUVIds.Add(pathId);
return false; return false;
} }
@@ -277,7 +296,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshPathBatchesBuffers))] [HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RefreshPathBatchesBuffers))]
private static bool CargoTraffic_RefreshBeltBatchesBuffers_Prefix() private static bool CargoTraffic_RefreshBeltBatchesBuffers_Prefix()
{ {
return !DisableRefreshBatchesBuffers; return !_disableRefreshBatchesBuffers;
} }
} }
@@ -419,6 +438,87 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();
} }
[HarmonyPrefix]
[HarmonyPatch(typeof(ConstructionSystem), nameof(ConstructionSystem.GameTick))]
private static void ConstructionSystem_GameTick_Prefix(ConstructionSystem __instance, long time)
{
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);
}
}
/* /*
[HarmonyTranspiler] [HarmonyTranspiler]
[HarmonyPatch(typeof(ConstructionSystem), nameof(ConstructionSystem.AddBuildTargetToModules))] [HarmonyPatch(typeof(ConstructionSystem), nameof(ConstructionSystem.AddBuildTargetToModules))]

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

@@ -3,6 +3,10 @@
## Changlog ## Changlog
* 1.5.2
* Fix crash while error occurs on milkyway login/upload.
* 1.5.1
* Support game version 0.10.34.28392
* 1.5.0 * 1.5.0
* Support game version 0.10.34 * Support game version 0.10.34
* New features: * New features:
@@ -365,6 +369,10 @@
## 更新日志 ## 更新日志
* 1.5.2
* 修复在银河系登录/上传出错时崩溃的问题
* 1.5.1
* 支持游戏版本 0.10.34.28392
* 1.5.0 * 1.5.0
* 支持游戏版本 0.10.34 * 支持游戏版本 0.10.34
* 新功能: * 新功能:

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

@@ -181,16 +181,16 @@ public class PersistPatch : PatchImpl<PersistPatch>
switch (errorType) switch (errorType)
{ {
case DSPWeb.HTTP_ERROR_TYPE.NETWORK_ERROR: case DSPWeb.HTTP_ERROR_TYPE.NETWORK_ERROR:
Functions.UIFunctions.AddClusterUploadResult(-10001, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(-10001, 0f);
break; break;
case DSPWeb.HTTP_ERROR_TYPE.HTTP_ERROR: case DSPWeb.HTTP_ERROR_TYPE.HTTP_ERROR:
Functions.UIFunctions.AddClusterUploadResult(-10010 - errorCode, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(-10010 - errorCode, 0f);
break; break;
case DSPWeb.HTTP_ERROR_TYPE.USER_ABORT: case DSPWeb.HTTP_ERROR_TYPE.USER_ABORT:
Functions.UIFunctions.AddClusterUploadResult(-10003, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(-10003, 0f);
break; break;
case DSPWeb.HTTP_ERROR_TYPE.UNEXPECTED_ERROR: case DSPWeb.HTTP_ERROR_TYPE.UNEXPECTED_ERROR:
Functions.UIFunctions.AddClusterUploadResult(-10004, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(-10004, 0f);
break; break;
} }
} }
@@ -202,16 +202,16 @@ public class PersistPatch : PatchImpl<PersistPatch>
switch (errorType) switch (errorType)
{ {
case DSPWeb.HTTP_ERROR_TYPE.NETWORK_ERROR: case DSPWeb.HTTP_ERROR_TYPE.NETWORK_ERROR:
Functions.UIFunctions.AddClusterUploadResult(-101, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(-101, 0f);
break; break;
case DSPWeb.HTTP_ERROR_TYPE.HTTP_ERROR: case DSPWeb.HTTP_ERROR_TYPE.HTTP_ERROR:
Functions.UIFunctions.AddClusterUploadResult(-110 - errorCode, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(-110 - errorCode, 0f);
break; break;
case DSPWeb.HTTP_ERROR_TYPE.USER_ABORT: case DSPWeb.HTTP_ERROR_TYPE.USER_ABORT:
Functions.UIFunctions.AddClusterUploadResult(-103, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(-103, 0f);
break; break;
case DSPWeb.HTTP_ERROR_TYPE.UNEXPECTED_ERROR: case DSPWeb.HTTP_ERROR_TYPE.UNEXPECTED_ERROR:
Functions.UIFunctions.AddClusterUploadResult(-104, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(-104, 0f);
break; break;
} }
} }
@@ -222,7 +222,7 @@ public class PersistPatch : PatchImpl<PersistPatch>
{ {
if (!int.TryParse(handler.text, out var rcode)) if (!int.TryParse(handler.text, out var rcode))
rcode = -1; rcode = -1;
Functions.UIFunctions.AddClusterUploadResult(rcode, (float)__instance.uploadRequest.reqTime); Functions.UIFunctions.AddClusterUploadResult(rcode, __instance.uploadRequest == null ? 0f : (float)__instance.uploadRequest.reqTime);
} }
[HarmonyTranspiler] [HarmonyTranspiler]

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

@@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid> <BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
<Description>DSP MOD - UXAssist</Description> <Description>DSP MOD - UXAssist</Description>
<Version>1.5.0</Version> <Version>1.5.2</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<PackageId>UXAssist</PackageId> <PackageId>UXAssist</PackageId>
@@ -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

@@ -1,6 +1,6 @@
{ {
"name": "UXAssist", "name": "UXAssist",
"version_number": "1.5.0", "version_number": "1.5.2",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
"dependencies": [ "dependencies": [

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>