diff --git a/AGENTS.md b/AGENTS.md index 457d339..f78f645 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -51,6 +51,7 @@ DSP_Mods/ | Mod | GUID | Description | |-----|------|-------------| +| **LiveStreamAssist** | `org.soardev.livestreamassist` | UXAssist-based live-stream statistics display. The rebindable Ctrl+F8 shortcut starts or stops the feature; starting opens Production Statistics, then alternates with Dyson Sphere at random 15-30-second unscaled-time intervals. Closing the statistics window or ending the game session stops the feature without reopening the window. | | **UXAssist** | `org.soardev.uxassist` | Core QoL mod and shared library. Window resize, profile-based saves, FPS control, factory/logistics/navigation/Dyson Sphere tweaks, UI improvements, config panel UI, and `Common/` + `UI/` widget library shared by other mods. The Factory tab's building-buffer controls include a comparison tip with the original game values. The Logistics tab can push auto-config values to all existing facilities of a type on the current planet (per-setting `Apply` and per-category `Apply All` buttons), and can set both product limits of every Orbital Collector across all loaded factories; logic is in `LogisticsPatch.Apply*`/`ForEach*` and wired in `UIConfigWindow`. Auto-construct uses forward sphere-cast probing, horizontal footprint-based detours, adaptive flight altitude, and stuck recovery while flying to construction ghosts. | | **CheatEnabler** | `org.soardev.cheatenabler` | Cheat pack (depends on UXAssist). Instant build, architect mode, infinite resources, power boosts, Dyson Sphere cheats with a bounded shell-count input (1–99,999), mecha invincibility, and more. | | **LogisticMiner** | — | Makes logistic stations automatically mine ores and water from the current planet. | diff --git a/DSP_Mods.sln b/DSP_Mods.sln index 519146d..d9e43ce 100644 --- a/DSP_Mods.sln +++ b/DSP_Mods.sln @@ -29,6 +29,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaScriptEngine", "LuaScrip EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateGameDlls", "UpdateGameDlls\UpdateGameDlls.csproj", "{6E73B301-7C7A-4EF4-B0FA-4C6B40F96653}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveStreamAssist", "LiveStreamAssist\LiveStreamAssist.csproj", "{0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -195,6 +197,18 @@ Global {6E73B301-7C7A-4EF4-B0FA-4C6B40F96653}.Release|x64.Build.0 = Release|Any CPU {6E73B301-7C7A-4EF4-B0FA-4C6B40F96653}.Release|x86.ActiveCfg = Release|Any CPU {6E73B301-7C7A-4EF4-B0FA-4C6B40F96653}.Release|x86.Build.0 = Release|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Debug|x64.ActiveCfg = Debug|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Debug|x64.Build.0 = Debug|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Debug|x86.ActiveCfg = Debug|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Debug|x86.Build.0 = Debug|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Release|Any CPU.Build.0 = Release|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Release|x64.ActiveCfg = Release|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Release|x64.Build.0 = Release|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Release|x86.ActiveCfg = Release|Any CPU + {0E6D6C44-00CF-4FE9-A475-1D898B4D1DAC}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LiveStreamAssist/LiveStreamAssist.cs b/LiveStreamAssist/LiveStreamAssist.cs new file mode 100644 index 0000000..99509d1 --- /dev/null +++ b/LiveStreamAssist/LiveStreamAssist.cs @@ -0,0 +1,120 @@ +using System.Reflection; +using BepInEx; +using CommonAPI.Systems; +using UnityEngine; +using UXAssist.Common; +using UXAssist.Common.ModFeatures; +using GameLogicProc = UXAssist.Common.GameLogic; + +namespace LiveStreamAssist; + +[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] +[BepInDependency(UXAssist.PluginInfo.PLUGIN_GUID)] +public class LiveStreamAssist : BaseUnityPlugin +{ + public new static readonly BepInEx.Logging.ManualLogSource Logger = + BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME); + + private void Awake() + { + I18N.Init(); + I18N.Add("KEYToggleLiveStreamAssist", "[LSA] Toggle live-stream statistics assist", "[LSA] \u5207\u6362\u76f4\u64ad\u7edf\u8ba1\u8f85\u52a9"); + ModFeatureRegistry.Discover(Assembly.GetExecutingAssembly()); + I18N.Apply(); + } +} + +[ModFeature("LiveStreamAssist", Order = 50)] +internal static class LiveStreamAssistFeature +{ + private const float MinIntervalSeconds = 15f; + private const float MaxIntervalSeconds = 30f; + private static PressKeyBind _toggleKey; + private static bool _enabled; + private static float _nextSwitchAt; + + public static void Init() + { + _toggleKey = KeyBindings.RegisterKeyBinding(new BuiltinKey + { + key = new CombineKey((int)KeyCode.F8, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false), + conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.FLYING | KeyBindConflict.SAILING | + KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.UI | KeyBindConflict.KEYBOARD_KEYBIND, + name = "ToggleLiveStreamAssist", + canOverride = true + }); + } + + public static void Start() + { + GameLogicProc.OnGameEnd += Stop; + } + + public static void Uninit() + { + GameLogicProc.OnGameEnd -= Stop; + Stop(); + } + + public static void OnInputUpdate() + { + if (!_toggleKey.keyValue) return; + + if (_enabled) + { + Stop(); + return; + } + + TryStart(); + } + + public static void OnUpdate() + { + if (!_enabled) return; + + var statWindow = GetStatWindow(); + if (statWindow == null || !statWindow.active) + { + Stop(); + return; + } + + if (Time.unscaledTime < _nextSwitchAt) return; + + var nextTab = statWindow.tabIndex == 1 ? 4 : 1; + statWindow.OnTabButtonClick(nextTab); + ScheduleNextSwitch(); + } + + private static void TryStart() + { + var statWindow = GetStatWindow(); + if (statWindow == null || !GameMain.isRunning) return; + + UIRoot.instance.uiGame.OpenProductionWindow(); + statWindow = GetStatWindow(); + if (statWindow == null || !statWindow.active) return; + + statWindow.OnTabButtonClick(1); + _enabled = true; + ScheduleNextSwitch(); + } + + private static UIStatisticsWindow GetStatWindow() + { + if (UIRoot.instance == null || UIRoot.instance.uiGame == null) return null; + return UIRoot.instance.uiGame.statWindow; + } + + private static void ScheduleNextSwitch() + { + _nextSwitchAt = Time.unscaledTime + Random.Range(MinIntervalSeconds, MaxIntervalSeconds); + } + + private static void Stop() + { + _enabled = false; + _nextSwitchAt = 0f; + } +} diff --git a/LiveStreamAssist/LiveStreamAssist.csproj b/LiveStreamAssist/LiveStreamAssist.csproj new file mode 100644 index 0000000..c69f0b9 --- /dev/null +++ b/LiveStreamAssist/LiveStreamAssist.csproj @@ -0,0 +1,13 @@ + + + + org.soardev.livestreamassist + DSP MOD - LiveStreamAssist + 1.0.0 + LiveStreamAssist + LiveStreamAssist + + + + + diff --git a/LiveStreamAssist/README.md b/LiveStreamAssist/README.md new file mode 100644 index 0000000..f4e81c6 --- /dev/null +++ b/LiveStreamAssist/README.md @@ -0,0 +1,12 @@ +# LiveStreamAssist + +Keeps the Dyson Sphere Program statistics window active during a live stream by switching between the Production Statistics and Dyson Sphere tabs at a random interval. + +## Usage + +- Press Ctrl+F8 to start or stop the assist. The key can be changed in the game's keyboard settings. +- Starting the assist opens the statistics window and selects Production Statistics. +- The mod switches between Production Statistics and Dyson Sphere every 15 to 30 seconds. +- Closing the statistics window stops the assist automatically. + +The mod requires UXAssist. diff --git a/LiveStreamAssist/package/icon.png b/LiveStreamAssist/package/icon.png new file mode 100644 index 0000000..1e293d0 Binary files /dev/null and b/LiveStreamAssist/package/icon.png differ diff --git a/LiveStreamAssist/package/manifest.json b/LiveStreamAssist/package/manifest.json new file mode 100644 index 0000000..dc7b816 --- /dev/null +++ b/LiveStreamAssist/package/manifest.json @@ -0,0 +1,10 @@ +{ + "name": "LiveStreamAssist", + "version_number": "1.0.0", + "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/LiveStreamAssist", + "description": "Keep the statistics window active for live streams", + "dependencies": [ + "xiaoye97-BepInEx-5.4.17", + "soarqin-UXAssist-1.5.9" + ] +} diff --git a/README.md b/README.md index b0895b4..ad99678 100644 --- a/README.md +++ b/README.md @@ -64,3 +64,7 @@ Cloak(Fake) user account info Some functions and patches for better user experience 一些提升用户体验的功能和补丁 + +## [LiveStreamAssist](LiveStreamAssist) + +Keeps the statistics window active for live streams by switching between the Production Statistics and Dyson Sphere tabs every 15 to 30 seconds.