|
|
@@ -1,6 +1,6 @@
|
|
|
# 原理与钩子设计
|
|
|
|
|
|
-> 本文记录判定点与拦截钩子的设计。当前仓库为骨架,钩子尚未实现;实现时以本文为准。
|
|
|
+> 本文记录判定点与拦截钩子的实际实现。
|
|
|
|
|
|
## 总体思路
|
|
|
|
|
|
@@ -15,21 +15,16 @@
|
|
|
|
|
|
## 判定点:进入
|
|
|
|
|
|
-计划钩子点:`EFT.GameWorld.OnGameStarted`。
|
|
|
-
|
|
|
-- 当 `GameWorld` 启动完成,即视为“已进入一次战局”。
|
|
|
-- 藏身处同样经由 `GameWorld` 流程,故一并覆盖。
|
|
|
-- 置位动作幂等:重复进入只保持标记为真。
|
|
|
+- **战斗战局**:`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` 做目标方法存在性检查,缺失时安全跳过、保持游戏原行为。
|
|
|
|
|
|
## 拦截点:开始战局
|
|
|
|
|
|
-计划钩子点:`EFT.MainMenuShowOperation` / `EFT.UI.MenuScreen`。
|
|
|
-
|
|
|
-- 在主菜单开始战局的入口(`MainMenuShowOperation`)拦截:
|
|
|
- 当 `ShouldBlockStart(PluginConfig.Enabled.Value)` 为真时阻止流程继续。
|
|
|
-- 视图层(`EFT.UI.MenuScreen`)可用于展示“已被限制”提示;文案取自 `OneShotText.Get(...)`,按系统区域选择中/英文。
|
|
|
-
|
|
|
-> 具体钩子的目标签名需随 EFT 版本逆向确认;本骨架不实现钩子,只固定 `Patches/` 目录与纯逻辑接口。
|
|
|
+- **流程拦截**:`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.SetDisabledTooltip(...)` 并置 `Interactable = false`:原生实现会把按钮 alpha 降到 0.3 且禁用点击,悬停显示提示。非限制态**不干预**按钮,交由游戏原生逻辑(如组队匹配禁用态)决定。
|
|
|
+- 文案取自 `OneShotText.Get(...)`,按 `LocalizationManager.Instance.Culture` 经 `LocaleSelector.Resolve` 选择中/英文。
|
|
|
|
|
|
## 复位
|
|
|
|
|
|
@@ -45,7 +40,7 @@
|
|
|
|
|
|
# Design: Detection and Hook Points
|
|
|
|
|
|
-> This document records the detection point and interception hooks. The repository is currently a skeleton and the hooks are not implemented yet; implement against this document.
|
|
|
+> This document records the detection points and interception hooks as implemented.
|
|
|
|
|
|
## Approach
|
|
|
|
|
|
@@ -60,21 +55,16 @@ try to start raid → query (SessionGate.ShouldBlockStart) → block or all
|
|
|
|
|
|
## Detection: entering
|
|
|
|
|
|
-Planned hook: `EFT.GameWorld.OnGameStarted`.
|
|
|
-
|
|
|
-- Once `GameWorld` finishes starting, treat it as "a raid has been entered".
|
|
|
-- The hideout goes through the same `GameWorld` flow, so it is covered as well.
|
|
|
-- Setting the flag is idempotent: repeated entries keep it true.
|
|
|
+- **Combat raid**: `Patches/EnterRaidPatch.cs` hooks `EFT.GameWorld.OnGameStarted()` (`[HarmonyPostfix]`), which fires once when an offline/online raid finishes loading.
|
|
|
+- **Hideout**: `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`).
|
|
|
+- Both call `SessionGate.MarkEnteredScene()` on hit; setting is idempotent.
|
|
|
+- Each patch guards with `[HarmonyPrepare]` + `AccessTools.Method` and skips safely (keeping vanilla behavior) when the target method is missing.
|
|
|
|
|
|
## Interception: starting a raid
|
|
|
|
|
|
-Planned hooks: `EFT.MainMenuShowOperation` / `EFT.UI.MenuScreen`.
|
|
|
-
|
|
|
-- Intercept the raid-start entry on the main menu (`MainMenuShowOperation`):
|
|
|
- when `ShouldBlockStart(PluginConfig.Enabled.Value)` is true, stop the flow.
|
|
|
-- The view layer (`EFT.UI.MenuScreen`) can show the "blocked" message; text comes from `OneShotText.Get(...)`, chosen by system locale.
|
|
|
-
|
|
|
-> Exact hook signatures must be verified against the EFT build; this skeleton does not implement hooks and only fixes the `Patches/` directory and the pure-logic interface.
|
|
|
+- **Flow interception**: `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.
|
|
|
+- **View feedback**: `Patches/PlayButtonStatePatch.cs` hooks `EFT.UI.MenuScreen.Show(Profile, MatchmakerPlayersController, ESessionMode)` and `MenuScreen.OnMatchingTypeUpdate` via `[HarmonyPostfix]`, then calls native `_playButton.SetDisabledTooltip(...)` and sets `Interactable = false`: the native implementation dims the button to alpha 0.3, disables clicks, and shows the tooltip on hover. When not blocked it leaves the button untouched so native logic (e.g. group-match disabling) decides.
|
|
|
+- Text comes from `OneShotText.Get(...)`, selected by `LocalizationManager.Instance.Culture` via `LocaleSelector.Resolve`.
|
|
|
|
|
|
## Reset
|
|
|
|