diff --git a/AGENTS.md b/AGENTS.md index 0db88f4..fe0803c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,7 +19,7 @@ - `Directory.Build.props` supplies common frameworks, BepInEx packages, game references, warning policy, and the `UpdateGameDlls` dependency. `Directory.Build.targets` defines `ZipMod` and `CopyToParentPackage`. - Normal validation: `dotnet build /.csproj -c Release --no-restore`. -- Refresh game references explicitly with `dotnet build UpdateGameDlls/UpdateGameDlls.csproj`; the script compares timestamps and uses `assembly-publicizer --strip --overwrite`. Missing DSP or the publicizer is a warning, not a build failure. +- Refresh game references explicitly with `dotnet build UpdateGameDlls/UpdateGameDlls.csproj`; the script publicizes installed DLLs in staging and compares generated content hashes so checkout timestamps cannot hide game updates. Missing DSP or the publicizer is a warning, not a build failure. - Package main mods with `dotnet build -t:ZipMod -c Release`; package preloaders with `dotnet build -t:CopyToParentPackage -c Release`. The mod `.csproj` `` is the single version source and packaging synchronizes `package/manifest.json`. Keep the latest English and Chinese `CHANGELOG.md` release headings and notes aligned with ``. Group user-visible changes by feature, omit implementation-only details, and carry forward existing unreleased notes without rewriting historical entries. - Treat warnings as errors except the intentional obsolete API warning `0618`; do not weaken this policy to hide new warnings. - Export Thunderstore package icons as 256x256 PNG files and verify their format and dimensions. For circular exports, apply an antialiased alpha mask to the approved artwork instead of regenerating it; preserve RGB pixels and make the exterior fully transparent. Convey the mod's function through familiar, conventionally oriented symbols rather than lettering. Preserve DSP motifs and consistent materials across related mod icons. During localized edits, preserve all unrequested geometry, placement and styling from the chosen reference; do not redesign surrounding structures to produce an overlap. Use clear foreground occlusion for intersecting forms without losing the main symbol's silhouette, and check contrast in 64x64 and 32x32 side-by-side previews. Keep unselected icon candidates under `artifacts/`, outside release package directories. @@ -34,12 +34,14 @@ - Prefer `UXAssist/Common/GameConstants` for item, tech, logistics, and Dyson sphere constants instead of inline literals. - Persist mod data through `IModCanSave` from DSPModSave. - Use `ModCompatHelper` for external plugin/type/member resolution and preserve legacy public type identities when refactoring reflection targets. Use `DysonSphereReflection` for DSPOptimizations-compatible Dyson sphere fields. +- Use `nameof` for members exposed by the publicized compile-time game assemblies, even when the corresponding methods are private in the original game DLL; use string member names only when the publicized reference truly omits them. - Performance-sensitive Harmony transpilers must include the standard target/fallback header and use `TranspilerGuard` when a matcher can fail; returning original instructions is the fallback. Match named enum members and semantic calls or fields instead of hard-coded enum values or local-variable slots. Validate injected stack operand types and branch destinations, not just successful matching. - `PatchImpl.Enable(true)` must remain fail-soft: log, unpatch, and leave the patch unset if Harmony application fails so config delegate chains remain consistent. - Overlay UI state must converge from actual game state on periodic updates, not depend only on one-shot event or patch callbacks. Treat replacement of a planet transport as a lifecycle boundary and clear its dependent overlays once. Station IDs are reusable indices, and a stable planet ID or factory reference does not imply stable transport ownership. Cloned controls must reset runtime state while retaining source styles; use `UXAssist.UI.Util.GetPreferredWidth` for dynamic text and `ResetButton` for cloned buttons. Preserve the source tip settings when resetting cloned help buttons so the game's native tips work; do not replace them with separate dialogs. Shared button sizing must use anchor-relative child positions so text and icons remain aligned after a button pivot changes. - Logistics station overlays must refresh through the native UI lifecycle, independently of typing guards. Reconcile cached tips against live station/entity identities and recycle local tips when stations are removed. - Planet vein utilization counters belong before resource labels, not beside native icons or highlight controls. Restore original label layout when rows are reused or the feature is disabled. - UI-only options must preserve native progression, statistics, and event delivery. Suppress presentation handlers rather than bypassing authoritative game-state setters. +- Expanded terraform brushes must raise both the input-size limit and the operation-local clamps in `PrepareFlattenPoints` and `PrepareRestorePoints`, with buffers sized before either preparation path runs. - Space-scene rendering suppression must require the native in-game hide-UI state and exclude menu demos and combat cutscenes. A hidden player model alone does not imply hidden scenery; use the same eligibility check for drawing and planet-simulator visibility. - LiveStreamAssist browser overlays must use single-flight polling and discard stale work after connection changes. Compound queries must reject mixed session IDs; cache only positive production indices so newly tracked items remain discoverable. - LiveStreamAssist production reads must schedule the native extra-info calculator for queried factories independently of the statistics UI. Deduplicate and throttle refreshes, let active native batches finish, and clear pending factory indices and deadlines at session boundaries. diff --git a/AssemblyFromGame/Assembly-CSharp.dll b/AssemblyFromGame/Assembly-CSharp.dll index 05c4710..1c0264c 100644 Binary files a/AssemblyFromGame/Assembly-CSharp.dll and b/AssemblyFromGame/Assembly-CSharp.dll differ diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index 9461b63..c46d34d 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -4,6 +4,7 @@ ## Changlog * 1.6.1 + * `Larger area for terraform`: Restore 11x11 through 30x30 foundation and Restore Terrain brushes after DSP 0.10.35.29104. * Fix the title-screen background turning black, even when the UXAssist window is closed. * `Planet vein utilization`: Move vein-group counts to the left of resource names to avoid overlapping the game's new buttons. * `Settings help`: Restore the game's native tips on question-mark buttons. @@ -422,6 +423,7 @@ ## 更新日志 * 1.6.1 + * `范围铺设地基的最大区域扩大`:适配 DSP 0.10.35.29104,恢复 11x11 至 30x30 的铺设地基与恢复地形范围。 * 修复标题画面背景变黑的问题,包括关闭 UXAssist 窗口后背景仍不显示的情况。 * `宇宙视图行星/星系矿脉数量显示`:将矿脉数量移至矿物名称左侧,避免与游戏新版按钮重叠。 * `设置提示`:修复问号按钮的游戏内提示不显示的问题。 diff --git a/UXAssist/Patches/Factory/ArchitectModePatch.cs b/UXAssist/Patches/Factory/ArchitectModePatch.cs index e29150f..ad92635 100644 --- a/UXAssist/Patches/Factory/ArchitectModePatch.cs +++ b/UXAssist/Patches/Factory/ArchitectModePatch.cs @@ -239,6 +239,27 @@ internal static class ArchitectModePatch Array.Resize(ref __instance.cursorIndices, MaxBrushSize * MaxBrushSize); } + // Harmony transpiler: BuildTool_Reform_PreparePoints_Transpiler + // Target: BuildTool_Reform.PrepareFlattenPoints, BuildTool_Reform.PrepareRestorePoints + // Fallback: TranspilerGuard returns original instructions when the operation-local brush limit is not found. + [HarmonyTranspiler] + [HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.PrepareFlattenPoints))] + [HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.PrepareRestorePoints))] + private static IEnumerable BuildTool_Reform_PreparePoints_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(OpCodes.Ldarg_0), + new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(BuildTool_Reform), nameof(BuildTool_Reform.brushSize))), + new CodeMatch(ci => ci.LoadsConstant(BuildTool_Reform.MAX_BRUSH_SIZE)), + new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Math), nameof(Math.Min), [typeof(int), typeof(int)])) + ); + if (matcher.IsInvalid) + return matcher.Finish(instructions, UXAssist.Logger, nameof(BuildTool_Reform_PreparePoints_Transpiler)); + matcher.Advance(2).Set(OpCodes.Ldc_I4, MaxBrushSize); + return matcher.InstructionEnumeration(); + } + // Harmony transpiler: BuildTool_Reform_ExecuteBrushAction_Transpiler // Target: BuildTool_Reform.ExecuteBrushAction // Fallback: TranspilerGuard returns original instructions when the brush limit is not found. diff --git a/UpdateGameDlls.ps1 b/UpdateGameDlls.ps1 index 9fadf80..1b2ec87 100644 --- a/UpdateGameDlls.ps1 +++ b/UpdateGameDlls.ps1 @@ -1,6 +1,6 @@ # UpdateGameDlls.ps1 # Finds the Dyson Sphere Program installation via Steam registry and libraryfolders.vdf, -# then uses assembly-publicizer to refresh AssemblyFromGame/ if the game DLLs are newer. +# then uses assembly-publicizer to refresh AssemblyFromGame/ when the generated references differ. param( [string]$ProjectRoot = $PSScriptRoot @@ -14,6 +14,20 @@ $DSP_DLLS = @('Assembly-CSharp.dll', 'UnityEngine.UI.dll') $MANAGED_SUBPATH = 'DSPGAME_Data\Managed' $OUTPUT_DIR = Join-Path $ProjectRoot 'AssemblyFromGame' +function Get-FileSha256([string]$Path) { + $stream = [IO.File]::OpenRead($Path) + try { + $sha256 = [Security.Cryptography.SHA256]::Create() + try { + return [BitConverter]::ToString($sha256.ComputeHash($stream)).Replace('-', '') + } finally { + $sha256.Dispose() + } + } finally { + $stream.Dispose() + } +} + # --------------------------------------------------------------------------- # 1. Locate Steam installation via registry # --------------------------------------------------------------------------- @@ -130,45 +144,55 @@ if (-not $publicizer) { } # --------------------------------------------------------------------------- -# 5. For each DLL: compare timestamps, publicize if game copy is newer +# 5. Publicize each DLL in staging and compare the generated reference contents # --------------------------------------------------------------------------- $updated = 0 -foreach ($dll in $DSP_DLLS) { - $srcFile = Join-Path $managedDir $dll - $dstFile = Join-Path $OUTPUT_DIR $dll +$stagingDir = Join-Path ([IO.Path]::GetTempPath()) ("DSP_Mods-publicized-" + [guid]::NewGuid().ToString('N')) +New-Item -ItemType Directory -Path $stagingDir | Out-Null +New-Item -ItemType Directory -Path $OUTPUT_DIR -Force | Out-Null - if (-not (Test-Path $srcFile)) { - Write-Warning "UpdateGameDlls: Source DLL not found: $srcFile" - continue - } +try { + foreach ($dll in $DSP_DLLS) { + $srcFile = Join-Path $managedDir $dll + $dstFile = Join-Path $OUTPUT_DIR $dll - $srcTime = (Get-Item $srcFile).LastWriteTimeUtc - $needsUpdate = $true - - if (Test-Path $dstFile) { - $dstTime = (Get-Item $dstFile).LastWriteTimeUtc - if ($srcTime -le $dstTime) { - Write-Host "UpdateGameDlls: $dll is up-to-date (game: $srcTime, local: $dstTime)" - $needsUpdate = $false + if (-not (Test-Path $srcFile)) { + Write-Warning "UpdateGameDlls: Source DLL not found: $srcFile" + continue } - } - if ($needsUpdate) { - Write-Host "UpdateGameDlls: Publicizing $dll (game: $srcTime) ..." - # --overwrite writes directly to / (no -publicized postfix) - & $publicizer $srcFile --strip --overwrite --output $OUTPUT_DIR + $srcTime = (Get-Item $srcFile).LastWriteTimeUtc + Write-Host "UpdateGameDlls: Publicizing $dll for comparison (game: $srcTime) ..." + & $publicizer $srcFile --strip --overwrite --output $stagingDir if ($LASTEXITCODE -ne 0) { Write-Error "UpdateGameDlls: assembly-publicizer failed for $dll (exit code $LASTEXITCODE)" exit 1 } - # Preserve the source timestamp on the output so future comparisons are stable - $outFile = Join-Path $OUTPUT_DIR $dll - if (Test-Path $outFile) { - (Get-Item $outFile).LastWriteTimeUtc = $srcTime + + $candidateFile = Join-Path $stagingDir $dll + if (-not (Test-Path $candidateFile)) { + Write-Error "UpdateGameDlls: Publicized DLL not found: $candidateFile" + exit 1 } + + if (Test-Path $dstFile) { + $candidateHash = Get-FileSha256 $candidateFile + $currentHash = Get-FileSha256 $dstFile + if ($candidateHash -eq $currentHash) { + Write-Host "UpdateGameDlls: $dll is up-to-date." + continue + } + } + + Copy-Item -LiteralPath $candidateFile -Destination $dstFile -Force + (Get-Item $dstFile).LastWriteTimeUtc = $srcTime $updated++ Write-Host "UpdateGameDlls: $dll updated." } +} finally { + if (Test-Path -LiteralPath $stagingDir) { + Remove-Item -LiteralPath $stagingDir -Recurse -Force + } } if ($updated -gt 0) {