diff --git a/DSP_Mods.sln b/DSP_Mods.sln index 7379bb3..ce746d6 100644 --- a/DSP_Mods.sln +++ b/DSP_Mods.sln @@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoolOpt", "PoolOpt\PoolOpt. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UXAssist", "UXAssist\UXAssist.csproj", "{9C048229-6A50-4642-BC5E-02CD39D3869A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserCloak", "UserCloak\UserCloak.csproj", "{096D2E4B-D1CE-424D-9954-C36A23E9E279}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -93,5 +95,9 @@ Global {9C048229-6A50-4642-BC5E-02CD39D3869A}.Debug|Any CPU.Build.0 = Debug|Any CPU {9C048229-6A50-4642-BC5E-02CD39D3869A}.Release|Any CPU.ActiveCfg = Release|Any CPU {9C048229-6A50-4642-BC5E-02CD39D3869A}.Release|Any CPU.Build.0 = Release|Any CPU + {096D2E4B-D1CE-424D-9954-C36A23E9E279}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {096D2E4B-D1CE-424D-9954-C36A23E9E279}.Debug|Any CPU.Build.0 = Debug|Any CPU + {096D2E4B-D1CE-424D-9954-C36A23E9E279}.Release|Any CPU.ActiveCfg = Release|Any CPU + {096D2E4B-D1CE-424D-9954-C36A23E9E279}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/README.md b/README.md index 235773c..5375461 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,11 @@ Performance optimizations for Matrix Labs Optimize memory pools on loading gamesaves 加载游戏存档时优化内存池的使用 +# [UserCloak](UserCloak) + +Cloak(Fake) user account info +隐匿(伪装)用户账号信息 + # [UXAssist](UXAssist) Some functions and patches for better user experience diff --git a/UserCloak/README.md b/UserCloak/README.md new file mode 100644 index 0000000..2717281 --- /dev/null +++ b/UserCloak/README.md @@ -0,0 +1,40 @@ +# UserCloak + +#### Cloak(Fake) user account info +#### 隐匿(伪装)用户账号信息 + +## Changlog +* 1.0.0 + + Initial release + +## Usage +* Works only for Steam version. +* Config entries: + +`[Cloak]` + - `Mode` [Default Value: false]: + - `0`: Disable cloaking. + - `1`: Fake user account info. + - `2`: Completely hide user account info. This also disables Milkyway completely. + - `FakeUserID` [Default Value: random on first launch]: Fake Steam user ID. Works when `Mode` is set to 1. This number is part Z of SteamID as described [here](https://developer.valvesoftware.com/wiki/SteamID). + - `FakeUsername` [Default Value: anonymous]: Fake Steam user name. Works when `Mode` is set to 1. + +## CREDITS +* [Dyson Sphere Program](https://store.steampowered.com/app/1366540): The great game + +## 更新日志 +* 1.0.0 + + 初始版本 + +## 使用说明 +* 仅支持Steam版 +* 设置选项: + +`[Cloak]` + - `Mode` [默认值: false]: + - `0`: 关闭隐匿 + - `1`: 伪装用户账号信息 + - `2`: 完全隐藏用户账号信息,同时完全禁用银河系 + - `FakeUserID` [默认值: 首次启动时随机生成]: 伪装的Steam用户ID,仅在`Mode`设置为1时生效。这个数字是SteamID中的Z部分,详见[这里](https://developer.valvesoftware.com/wiki/SteamID) + - `FakeUsername` [默认值: anonymous]: 伪装的Steam用户名,仅在`Mode`设置为1时生效 + +## 鸣谢 +* [戴森球计划](https://store.steampowered.com/app/1366540): 伟大的游戏 diff --git a/UserCloak/UserCloak.cs b/UserCloak/UserCloak.cs new file mode 100644 index 0000000..004e267 --- /dev/null +++ b/UserCloak/UserCloak.cs @@ -0,0 +1,148 @@ +using System; +using BepInEx; +using BepInEx.Configuration; +using HarmonyLib; +using Steamworks; +using Random = UnityEngine.Random; + +namespace UserCloak; + +[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] +public class UserCloak: BaseUnityPlugin +{ + private static Harmony _patch; + private static ConfigEntry _mode; + private static ConfigEntry _fakeUserId; + private static ConfigEntry _fakeUsername; + + private void Awake() + { + _mode = Config.Bind("General", "Mode", 0, "Cloak Mode:\n" + + " 0: Disable cloaking.\n" + + " 1: Fake user account info.\n" + + " 2: Completely hide user account info. This also disables Milkyway completely.\n"); + _fakeUserId = Config.Bind("General", "FakeUserId", 0, "Fake Steam user ID"); + _fakeUsername = Config.Bind("General", "FakeUsername", "anonymous", "Fake Steam username"); + + if (_mode.Value == 1 && _fakeUserId.Value == 0) + { + _fakeUserId.Value = Random.Range(10000, 2000000000); + } + + if (_mode.Value != 0) + { + _patch ??= Harmony.CreateAndPatchAll(typeof(UserCloak)); + } + } + + private void OnDestroy() + { + _patch?.UnpatchSelf(); + _patch = null; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(SteamManager), nameof(SteamManager.Awake))] + private static bool SteamManager_Awake_Prefix(SteamManager __instance) + { + if (_mode.Value == 0) + return true; + if (SteamManager.s_instance != null) + { + UnityEngine.Object.Destroy(__instance.gameObject); + return false; + } + SteamManager.s_instance = __instance; + if (SteamManager.s_EverInitialized) + { + throw new Exception("Tried to Initialize the SteamAPI twice in one session!"); + } + __instance.m_bInitialized = true; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(STEAMX), nameof(STEAMX.Awake))] + private static bool STEAMX_Awake_Prefix(STEAMX __instance) + { + switch (_mode.Value) + { + case 1: + STEAMX.instance = __instance; + STEAMX.userId = new CSteamID(0x0110000100000001UL | (uint)_fakeUserId.Value); + return false; + case 2: + return false; + } + return true; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(SteamManager), nameof(SteamManager.OnEnable))] + private static bool SteamManager_OnEnable_Prefix(SteamManager __instance) + { + if (_mode.Value == 0) + return true; + if (SteamManager.s_instance == null) + { + SteamManager.s_instance = __instance; + } + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(SteamManager), nameof(SteamManager.Update))] + private static bool SteamManager_Update_Prefix() + { + return _mode.Value == 0; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(PARTNER), nameof(PARTNER.STEAMWORKS), MethodType.Getter)] + private static bool PARTNER_STEAMWORKS_Prefix(ref bool __result) + { + if (_mode.Value != 2) + return true; + __result = false; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(PARTNER), nameof(PARTNER.UserLogin))] + private static bool PARTNER_UserLogin_Prefix() + { + switch (_mode.Value) + { + case 1: + AccountData.me.platform = ESalePlatform.Steam; + AccountData.me.userId = 0x0110000100000001UL | (uint)_fakeUserId.Value; + AccountData.me.detail.userName = _fakeUsername.Value; + PARTNER.logined = true; + return false; + case 2: + return false; + } + return true; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(SteamLeaderboardManager_ClusterGeneration), nameof(SteamLeaderboardManager_ClusterGeneration.Start))] + [HarmonyPatch(typeof(SteamLeaderboardManager_ClusterGeneration), nameof(SteamLeaderboardManager_ClusterGeneration.Update))] + [HarmonyPatch(typeof(SteamLeaderboardManager_ClusterGeneration), nameof(SteamLeaderboardManager_ClusterGeneration.UploadScore))] + [HarmonyPatch(typeof(SteamLeaderboardManager_PowerConsumption), nameof(SteamLeaderboardManager_PowerConsumption.Start))] + [HarmonyPatch(typeof(SteamLeaderboardManager_PowerConsumption), nameof(SteamLeaderboardManager_PowerConsumption.Update))] + [HarmonyPatch(typeof(SteamLeaderboardManager_PowerConsumption), nameof(SteamLeaderboardManager_PowerConsumption.UploadScore))] + [HarmonyPatch(typeof(SteamLeaderboardManager_SolarSail), nameof(SteamLeaderboardManager_SolarSail.Start))] + [HarmonyPatch(typeof(SteamLeaderboardManager_SolarSail), nameof(SteamLeaderboardManager_SolarSail.Update))] + [HarmonyPatch(typeof(SteamLeaderboardManager_SolarSail), nameof(SteamLeaderboardManager_SolarSail.UploadScore))] + [HarmonyPatch(typeof(SteamLeaderboardManager_UniverseMatrix), nameof(SteamLeaderboardManager_UniverseMatrix.Start))] + [HarmonyPatch(typeof(SteamLeaderboardManager_UniverseMatrix), nameof(SteamLeaderboardManager_UniverseMatrix.Update))] + [HarmonyPatch(typeof(SteamLeaderboardManager_UniverseMatrix), nameof(SteamLeaderboardManager_UniverseMatrix.UploadScore))] + [HarmonyPatch(typeof(SteamAchievementManager), nameof(SteamAchievementManager.Start))] + [HarmonyPatch(typeof(SteamAchievementManager), nameof(SteamAchievementManager.Update))] + [HarmonyPatch(typeof(SteamAchievementManager), nameof(SteamAchievementManager.UnlockAchievement))] + private static bool SteamLeaderBoard_functions_Prefix() + { + return _mode.Value == 0; + } +} diff --git a/UserCloak/UserCloak.csproj b/UserCloak/UserCloak.csproj new file mode 100644 index 0000000..6b4bb4b --- /dev/null +++ b/UserCloak/UserCloak.csproj @@ -0,0 +1,29 @@ + + + + net472 + org.soardev.usercloak + DSP MOD - UserCloak + 1.0.0 + true + latest + UserCloak + UserCloak + https://nuget.bepinex.dev/v3/index.json + + + + + + + + + + + + + + + + + diff --git a/UserCloak/package/icon.png b/UserCloak/package/icon.png new file mode 100644 index 0000000..f8e8e84 Binary files /dev/null and b/UserCloak/package/icon.png differ diff --git a/UserCloak/package/manifest.json b/UserCloak/package/manifest.json new file mode 100644 index 0000000..12fbfa3 --- /dev/null +++ b/UserCloak/package/manifest.json @@ -0,0 +1,9 @@ +{ + "name": "UserCloak", + "version_number": "1.0.0", + "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UserCloak", + "description": "Cloak(Fake) user account info / 隐匿(伪装)用户账号信息", + "dependencies": [ + "xiaoye97-BepInEx-5.4.17" + ] +}