mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
5.2 KiB
5.2 KiB
Agent Guidelines
Rules
- Update
AGENTS.mdafter each task by editing current guidance directly. Keep only project standards and durable architecture references; do not retain investigation evidence, task histories, completed plans, or implementation snapshots. - Write all documentation and code comments in English.
- Inspect the original DSP game DLL, never the stripped publicized copy in
AssemblyFromGame/, when method bodies are required. Locate DSP using the Steam registry andsteamapps/libraryfolders.vdfasUpdateGameDlls.ps1does, then decompile<game_root>/DSPGAME_Data/Managed/Assembly-CSharp.dll. - Resolve in-game terminology from
<game_root>/Locale/:Namescontains keys,1033is English, and2052is Simplified Chinese.
Project
- This repository contains independent BepInEx 5.x C# mods for Dyson Sphere Program. HarmonyLib patches game methods at runtime;
UXAssistis the shared library used directly byCheatEnablerandUniverseGenTweaks. - Projects target
net472ornetstandard2.1with SDK-style.csprojfiles. Compile-time game references live inAssemblyFromGame/. DustbinPreloaderandLabOptPreloaderare Mono.Cecil preloaders; their main mods consume the injected fields without reflection.
Build
Directory.Build.propssupplies common frameworks, BepInEx packages, game references, warning policy, and theUpdateGameDllsdependency.Directory.Build.targetsdefinesZipModandCopyToParentPackage.- Normal validation:
dotnet build <project>/<project>.csproj -c Release --no-restore. - Refresh game references explicitly with
dotnet build UpdateGameDlls/UpdateGameDlls.csproj; the script compares timestamps and usesassembly-publicizer --strip --overwrite. Missing DSP or the publicizer is a warning, not a build failure. - Package main mods with
dotnet build -t:ZipMod -c Release; package preloaders withdotnet build -t:CopyToParentPackage -c Release. The mod.csproj<Version>is the single version source and packaging synchronizespackage/manifest.json. - Treat warnings as errors except the intentional obsolete API warning
0618; do not weaken this policy to hide new warnings.
Architecture
ModFeatureRegistrydiscovers dependent-mod features duringAwake; feature initialization is eager, while UXAssist alone drives the deferred start, input, update, and uninitialization lifecycle. Keep dispatchers internal and idempotent.- Dispatch UXAssist shortcuts from the postfix of
VFInput.OnUpdate, after DSP refreshes modifier and UI state. Keep typing/menu guards and per-frame registry guards; do not poll from an independentUpdate()or logic-tick callback. - Register localization keys through each project registration class and use
.Translate()with keys. Do not add Chinese literals at call sites. - Prefer
UXAssist/Common/GameConstantsfor item, tech, logistics, and Dyson sphere constants instead of inline literals. - Persist mod data through
IModCanSavefrom DSPModSave. - Use
ModCompatHelperfor external plugin/type/member resolution and preserve legacy public type identities when refactoring reflection targets. UseDysonSphereReflectionfor DSPOptimizations-compatible Dyson sphere fields. - Performance-sensitive Harmony transpilers must include the standard target/fallback header and use
TranspilerGuardwhen a matcher can fail; returning original instructions is the fallback. PatchImpl<T>.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. Cloned controls must reset runtime state while retaining source styles; use
UXAssist.UI.Util.GetPreferredWidthfor dynamic text andResetButtonfor cloned buttons.
Automation Architecture
Auto-construct
AutoConstructEnabledcontrols patch activation;AutoConstructButtonEnabledcontrols only button visibility. Never couple them.- Keep planning bounded and allocation-free. Follow native construction eligibility and planet-local surface movement semantics.
- The planner owns only its generated
MoveToorders. Clear an active auto order before resetting planner state on disable or planet changes, without clearing user orders. Recovery detours must return control to the construction route.
Auto-cruise
PlayerPatch.AutoNavigationis the only auto-cruise implementation. Its Harmony patches followAutoCruiseEnabled; use auto-cruise terminology in user-facing text rather than the game's native autopilot terminology.- Use one navigation lifecycle path for target state and reusable obstacle data. Require a resolvable target, yield to
player.navigation.navigating, and reject an active native autopilot before reporting that auto-cruise started. - Preserve native movement and braking conventions; manual warp input takes precedence.
Review Standard
- Fix root causes with minimal focused changes. Do not alter unrelated behavior, add copyright headers, commit changes, or create branches unless requested.
- Before handoff, run the narrowest relevant build or test, then
git diff --check. Mention unrelated pre-existing failures instead of changing them.