1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-02-04 15:12:17 +08:00

Compare commits

...

3 Commits

Author SHA1 Message Date
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
7 changed files with 122 additions and 54 deletions

Binary file not shown.

Binary file not shown.

View File

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

View File

@@ -3,6 +3,10 @@
## 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
* Support game version 0.10.34
* New features:
@@ -365,6 +369,10 @@
## 更新日志
* 1.5.2
* 修复在银河系登录/上传出错时崩溃的问题
* 1.5.1
* 支持游戏版本 0.10.34.28392
* 1.5.0
* 支持游戏版本 0.10.34
* 新功能:

View File

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

View File

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

View File

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