| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using EFT;
- using EFT.UI;
- using HarmonyLib;
- namespace OneShot.Patches
- {
- /// <summary>
- /// 拦截“开始战局/重连”:本次会话已进过场景时,静默跳过整段界面切换流程。
- /// Blocks starting a raid / reconnecting: silently skips the whole screen-switch flow
- /// once a scene has been entered this session.
- /// 提示 UI 由另一条 lane 负责,此处不弹窗。
- /// The notification UI is handled by another lane; no popup is shown here.
- /// </summary>
- [HarmonyPatch(typeof(MainMenuShowOperation), nameof(MainMenuShowOperation.ShowScreen))]
- internal static class BlockStartPatch
- {
- /// <summary>
- /// 目标方法存在性检查;缺失时安全降级为不挂钩,保持游戏原行为。
- /// Verifies the target method exists; degrades safely to no-op if it is missing.
- /// </summary>
- [HarmonyPrepare]
- private static bool Prepare()
- {
- return AccessTools.Method(
- typeof(MainMenuShowOperation),
- nameof(MainMenuShowOperation.ShowScreen),
- new[] { typeof(EMenuType), typeof(bool) }) != null;
- }
- /// <summary>
- /// 仅拦截 Play(开始战局)与 Reconnect(重连);绝不拦截 Hideout(藏身处)等其他界面。
- /// Only blocks Play (start raid) and Reconnect; never blocks Hideout or any other screen.
- /// </summary>
- [HarmonyPrefix]
- [HarmonyWrapSafe]
- private static bool Prefix(EMenuType screen)
- {
- // 白名单:只处理开始战局与重连,其余界面一律放行。
- // Allow-list: only handle starting a raid and reconnecting; pass everything else through.
- if (screen != EMenuType.Play && screen != EMenuType.Reconnect)
- {
- return true;
- }
- if (PluginConfig.Enabled == null || !PluginConfig.Enabled.Value)
- {
- return true;
- }
- if (OneShotPlugin.Gate == null || !OneShotPlugin.Gate.ShouldBlockStart(true))
- {
- return true;
- }
- Log.Info("已进过场景,本次会话禁止再开始战局 | A scene was already entered; starting another raid is blocked for this session.");
- return false;
- }
- }
- }
|