本文记录判定点与拦截钩子的实际实现。
限制是会话级的:只需在内存里记录“本次 SPT 运行是否已进入过场景”,并在“开始战局”的入口查询该标记。数据流如下:
进入战局/藏身处 → 置位标记 (SessionGate.MarkEnteredScene)
试图开始战局 → 查询 (SessionGate.ShouldBlockStart) → 阻止或放行
OneShot.Core.SessionGate 为纯逻辑状态机,不依赖游戏程序集,因此可在公共 CI 上直接单测。
Patches/EnterRaidPatch.cs 挂钩 EFT.GameWorld.OnGameStarted()([HarmonyPostfix])。该方法在离线/在线战局加载完成时触发一次。Patches/EnterHideoutPatch.cs 挂钩 EFT.Hideout.HideoutController.HideoutAwake()。藏身处不经过 GameWorld.OnGameStarted,故必须单独挂钩 HideoutController(注意不要与嵌套类 EFT.TarkovApplication.HideoutController 混淆)。SessionGate.MarkEnteredScene();置位幂等:重复进入只保持标记为真。[HarmonyPrepare] + AccessTools.Method 做目标方法存在性检查,缺失时安全跳过、保持游戏原行为。Patches/BlockStartPatch.cs 以 [HarmonyPrefix] 挂钩 EFT.MainMenuShowOperation.ShowScreen(EFT.UI.EMenuType screen, bool turnOn)。当 screen 为 Play(0) 或 Reconnect(12) 且 ShouldBlockStart(PluginConfig.Enabled.Value) 为真时 return false,静默跳过整段界面切换;Hideout(11) 等其它界面一律放行,不弹窗。Patches/PlayButtonStatePatch.cs 以 [HarmonyPostfix] 挂钩 EFT.UI.MenuScreen.Show(Profile, MatchmakerPlayersController, ESessionMode) 与 MenuScreen.OnMatchingTypeUpdate,在它们之后仅置 _playButton.Interactable = false:原生实现会把按钮 alpha 降到 0.3 且禁用点击,不显示 tooltip。非限制态不干预按钮,交由游戏原生逻辑(如组队匹配禁用态)决定。SessionGate.Reset()。ResetRequested 为一次性操作项:勾选后由 PluginConfig 复位为 false 并触发事件,避免界面停留在“已勾选”。===============================================================
This document records the detection points and interception hooks as implemented.
The restriction is session-scoped: keep an in-memory flag for "has a scene been entered this SPT run" and consult it at the raid-start entry. Data flow:
enter raid/hideout → set flag (SessionGate.MarkEnteredScene)
try to start raid → query (SessionGate.ShouldBlockStart) → block or allow
OneShot.Core.SessionGate is a pure-logic state machine with no game-assembly dependency, so it can be unit-tested on public CI.
Patches/EnterRaidPatch.cs hooks EFT.GameWorld.OnGameStarted() ([HarmonyPostfix]), which fires once when an offline/online raid finishes loading.Patches/EnterHideoutPatch.cs hooks EFT.Hideout.HideoutController.HideoutAwake(). The hideout does not go through GameWorld.OnGameStarted, so it must be hooked separately on HideoutController (do not confuse it with the nested EFT.TarkovApplication.HideoutController).SessionGate.MarkEnteredScene() on hit; setting is idempotent.[HarmonyPrepare] + AccessTools.Method and skips safely (keeping vanilla behavior) when the target method is missing.Patches/BlockStartPatch.cs hooks EFT.MainMenuShowOperation.ShowScreen(EFT.UI.EMenuType screen, bool turnOn) via [HarmonyPrefix]. When screen is Play (0) or Reconnect (12) and ShouldBlockStart(PluginConfig.Enabled.Value) is true, it returns false to silently skip the whole screen-switch flow; Hideout (11) and other screens pass through with no popup.Patches/PlayButtonStatePatch.cs hooks EFT.UI.MenuScreen.Show(Profile, MatchmakerPlayersController, ESessionMode) and MenuScreen.OnMatchingTypeUpdate via [HarmonyPostfix], then only sets Interactable = false: the native implementation dims the button to alpha 0.3 and disables clicks, with no tooltip. When not blocked it leaves the button untouched so native logic (e.g. group-match disabling) decides.SessionGate.Reset().ResetRequested is a one-shot action item: on check, PluginConfig resets it to false and raises the event so the UI does not stay on.