mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(mods): restore architect mode and clear stale station panels
Restore architect inventory handling and use 999 virtual items, including logistics bots, drones, and vessels. Recycle removed station panels and refresh overlays independently of typing guards. Bump CheatEnabler to 2.4.6 and UXAssist to 1.6.1, with release notes and synchronized package manifests.
This commit is contained in:
1 parent
d084f9cf75
commit
1c5073c6ac
12 files changed
+145
-105
No files matched your search
@@ -3,7 +3,10 @@
|
||||
|
||||
## Changlog
|
||||
|
||||
* Unreleased
|
||||
* 2.4.6
|
||||
* `Architect mode`: Restore infinite-building behavior and keep construction previews, inventory queries, and cached package statistics in sync.
|
||||
* `Architect mode`: Increase the default virtual stock from 100 to 999 and explicitly include Logistics Bots, Logistics Drones, and Logistics Vessels.
|
||||
* `Architect mode`: Fix item withdrawal results without consuming real stock or affecting unrelated storage. Preserve physical package capacity and restore native statistics when the mode is disabled.
|
||||
* `PowerGlobalCoverage`: Fix a startup crash before wind-turbine prefabs finish loading. Retry after preload without corrupting activation state or the original power ranges, and tolerate unallocated factory data.
|
||||
* 2.4.5
|
||||
* Support Dyson Sphere Program 0.10.35.29057.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<BepInExPluginGuid>org.soardev.cheatenabler</BepInExPluginGuid>
|
||||
<Description>DSP MOD - CheatEnabler</Description>
|
||||
<Version>2.4.5</Version>
|
||||
<Version>2.4.6</Version>
|
||||
<PackageId>CheatEnabler</PackageId>
|
||||
<RootNamespace>CheatEnabler</RootNamespace>
|
||||
<PackHasChangelog>true</PackHasChangelog>
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.GameConstants;
|
||||
|
||||
namespace CheatEnabler.Patches.Factory;
|
||||
|
||||
[PatchSetCallbackFlag(PatchCallbackFlag.CallOnDisableAfterUnpatch)]
|
||||
internal class ArchitectMode : PatchImpl<ArchitectMode>
|
||||
{
|
||||
private static bool[] _canBuildItems;
|
||||
private const int DefaultItemCount = 999;
|
||||
private static readonly AccessTools.FieldRef<BuildTool, StorageComponent> BuildToolPackage =
|
||||
AccessTools.FieldRefAccess<BuildTool, StorageComponent>(nameof(BuildTool.tmpPackage));
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
RefreshPackageStatistics();
|
||||
var factory = GameMain.mainPlayer?.factory;
|
||||
if (factory?.planet?.data != null)
|
||||
{
|
||||
@@ -16,43 +22,114 @@ internal class ArchitectMode : PatchImpl<ArchitectMode>
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
RefreshPackageStatistics();
|
||||
}
|
||||
|
||||
private static void RefreshPackageStatistics()
|
||||
{
|
||||
var player = GameMain.mainPlayer;
|
||||
if (player?.package == null) return;
|
||||
player.packageUtility?.statistics?.Count(player.package);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PackageStatistics), nameof(PackageStatistics.Count))]
|
||||
private static void CountPackageItemsPatch(PackageStatistics __instance)
|
||||
{
|
||||
if (__instance != GameMain.mainPlayer?.packageUtility?.statistics) return;
|
||||
var items = LDB.items?.dataArray;
|
||||
if (items == null) return;
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item == null || !IsArchitectItem(item.ID)) continue;
|
||||
var count = __instance.itemBundle.GetCount(item.ID);
|
||||
if (count < DefaultItemCount) __instance.itemBundle.Add(item.ID, DefaultItemCount - count, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.TakeTailItems), [typeof(int), typeof(int), typeof(int), typeof(bool)],
|
||||
[ArgumentType.Ref, ArgumentType.Ref, ArgumentType.Out, ArgumentType.Normal])]
|
||||
public static bool TakeTailItemsPatch(StorageComponent __instance, int itemId, int count, ref int inc)
|
||||
{
|
||||
if (count <= 0 || !IsPlayerStorage(__instance) || !IsArchitectItem(itemId)) return true;
|
||||
inc = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.TakeTailItems), [typeof(int), typeof(int), typeof(int[]), typeof(int), typeof(bool)],
|
||||
[ArgumentType.Ref, ArgumentType.Ref, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal])]
|
||||
public static bool TakeTailItemsPatch(StorageComponent __instance, int itemId)
|
||||
private static bool TakeTailItemsWithNeedsPatch(StorageComponent __instance, int itemId, int count, int[] needs, ref int inc, ref bool __result)
|
||||
{
|
||||
if (__instance == null || GameMain.mainPlayer == null || __instance.id != GameMain.mainPlayer.package.id) return true;
|
||||
if (itemId <= 0) return true;
|
||||
if (_canBuildItems == null)
|
||||
{
|
||||
DoInit();
|
||||
}
|
||||
if (needs == null || Array.IndexOf(needs, itemId) < 0) return true;
|
||||
if (TakeTailItemsPatch(__instance, itemId, count, ref inc)) return true;
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return itemId >= 12000 || !_canBuildItems[itemId];
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerPackageUtility), nameof(PlayerPackageUtility.TryTakeItemFromAllPackages))]
|
||||
private static bool TryTakeItemFromAllPackagesPatch(PlayerPackageUtility __instance, int itemId, int count, ref int inc)
|
||||
{
|
||||
if (__instance.player == null || __instance.player != GameMain.mainPlayer || count <= 0 || !IsArchitectItem(itemId)) return true;
|
||||
inc = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerPackageUtility), nameof(PlayerPackageUtility.TakeItemFromAllPackages))]
|
||||
private static bool TakeItemFromAllPackagesPatch(PlayerPackageUtility __instance, int itemId, int count, ref int inc)
|
||||
{
|
||||
return TryTakeItemFromAllPackagesPatch(__instance, itemId, count, ref inc);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.GetItemCount), typeof(int))]
|
||||
public static void GetItemCountPatch(StorageComponent __instance, int itemId, ref int __result)
|
||||
{
|
||||
if (__result > 99) return;
|
||||
if (__instance == null || GameMain.mainPlayer == null || __instance.id != GameMain.mainPlayer.package.id) return;
|
||||
if (itemId <= 0) return;
|
||||
if (_canBuildItems == null)
|
||||
{
|
||||
DoInit();
|
||||
}
|
||||
if (itemId < 12000 && _canBuildItems[itemId]) __result = 100;
|
||||
if (__result >= DefaultItemCount || !IsPlayerStorage(__instance) || !IsArchitectItem(itemId)) return;
|
||||
__result = DefaultItemCount;
|
||||
}
|
||||
|
||||
private static void DoInit()
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.GetItemCount), [typeof(int), typeof(int)],
|
||||
[ArgumentType.Normal, ArgumentType.Out])]
|
||||
private static void GetItemCountWithIncPatch(StorageComponent __instance, int itemId, ref int __result)
|
||||
{
|
||||
_canBuildItems = new bool[12000];
|
||||
foreach (var ip in LDB.items.dataArray)
|
||||
GetItemCountPatch(__instance, itemId, ref __result);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerPackageUtility), nameof(PlayerPackageUtility.GetPackageItemCount))]
|
||||
private static void GetPackageItemCountPatch(PlayerPackageUtility __instance, int itemId, ref int __result)
|
||||
{
|
||||
if (__instance.player == null || __instance.player != GameMain.mainPlayer || __result >= DefaultItemCount || !IsArchitectItem(itemId)) return;
|
||||
__result = DefaultItemCount;
|
||||
}
|
||||
|
||||
private static bool IsPlayerStorage(StorageComponent storage)
|
||||
{
|
||||
var player = GameMain.mainPlayer;
|
||||
if (storage == null || player == null) return false;
|
||||
if (storage == player.package) return true;
|
||||
var buildTools = player.controller?.actionBuild?.tools;
|
||||
if (buildTools == null) return false;
|
||||
foreach (var buildTool in buildTools)
|
||||
{
|
||||
if ((ip.Type == EItemType.Logistics || ip.CanBuild) && ip.ID < 12000) _canBuildItems[ip.ID] = true;
|
||||
if (buildTool != null && storage == BuildToolPackage(buildTool)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsArchitectItem(int itemId)
|
||||
{
|
||||
if (itemId <= 0) return false;
|
||||
if (itemId is ItemIds.LogisticsBot or ItemIds.LogisticsDrone or ItemIds.LogisticsVessel) return true;
|
||||
var item = LDB.items?.Select(itemId);
|
||||
return item != null && (item.Type == EItemType.Logistics || item.CanBuild);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "CheatEnabler",
|
||||
"version_number": "2.4.5",
|
||||
"version_number": "2.4.6",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
|
||||
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
|
||||
"dependencies": [
|
||||
|
||||
Reference in new issue
Block a user