{"record":{"id":"3972255abdeee122","repo":"babalae/better-genshin-impact","slug":"error-397225","errorCode":null,"errorMessage":"未找到原粹树脂图标","messagePattern":"未找到原粹树脂图标","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/AutoBoss/AutoBossTask.cs","lineNumber":313,"sourceCode":"    /// 释放输入并打开大地图界面，用于在右上角读取原粹树脂数量。\n    /// </summary>\n    private async Task OpenBigMapForResinCheck()\n    {\n        await new TpTask(_ct).OpenBigMapUi();\n    }\n\n    /// <summary>\n    /// AutoBoss 专用大地图原粹树脂识别：点击右上角树脂图标后，通过全部恢复时间反推剩余树脂。\n    /// </summary>\n    /// <returns>当前剩余原粹树脂。</returns>\n    private async Task<OriginalResinInfo> RecognizeOriginalResinInfoFromBigMap()\n    {\n        using var capture = CaptureToRectArea();\n        using var resinIconSearchRegion = capture.DeriveCrop(ScaleRect(1200, 25, 580, 50));\n        var resinIconRegion = resinIconSearchRegion.Find(LoadRecognitionObject(\"OriginalResinTopIcon\"));\n        if (resinIconRegion.IsEmpty())\n        {\n            throw new InvalidOperationException(\"未找到原粹树脂图标\");\n        }\n\n        var iconLeft = resinIconSearchRegion.X + resinIconRegion.Left;\n        var iconRight = resinIconSearchRegion.X + resinIconRegion.Right;\n        var iconBottom = resinIconSearchRegion.Y + resinIconRegion.Bottom;\n\n        resinIconRegion.Click();\n        await Delay(500, _ct);\n\n        using var clickedCapture = CaptureToRectArea();\n        var resinLimit = RecognizeOriginalResinLimit(clickedCapture, iconRight);\n        var fullRecoveryTime = RecognizeFullRecoveryTime(clickedCapture, iconLeft, iconBottom);\n        var missingResin = (int)Math.Ceiling(fullRecoveryTime.TotalSeconds / OriginalResinRecoveryInterval.TotalSeconds);\n        if (missingResin > resinLimit)\n        {\n            throw new InvalidOperationException($\"计算缺失树脂 {missingResin} 超过树脂上限 {resinLimit}\");\n        }\n","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoBoss/AutoBossTask.cs#L295-L331","documentation":"Thrown by AutoBossTask.RecognizeOriginalResinInfoFromBigMap when the template match for 'OriginalResinTopIcon' returns an empty region inside the cropped search area ScaleRect(1200,25,580,50). The resin icon must be visible in the top-right of the big-map UI for AutoBoss to compute remaining resin from recovery time.","triggerScenarios":"The big-map UI is not actually open (OpenBigMapUi failed silently); the icon's screen position shifted due to resolution/scale mismatch with the hardcoded 1200,25,580,50 rect; the template image is stale (game updated the icon art); the crop region is off-screen at the current resolution.","commonSituations":"Game resolution or UI scale changed so the hardcoded crop no longer covers the icon; game patched the resin icon art; the map did not open in time (race before the capture); the asset template missing from the resources.","solutions":["Confirm the big-map UI is fully loaded before calling (increase Delay after OpenBigMapUi).","Verify the game resolution matches ScaleRect assumptions; adjust or scale the search rect by AssetScale.","Update the 'OriginalResinTopIcon' template asset to match the current game art.","Retry the capture once before failing, since UI animations can momentarily hide the icon."],"exampleFix":"// before\nusing var capture = CaptureToRectArea();\nusing var resinIconSearchRegion = capture.DeriveCrop(ScaleRect(1200, 25, 580, 50));\nvar resinIconRegion = resinIconSearchRegion.Find(LoadRecognitionObject(\"OriginalResinTopIcon\"));\nif (resinIconRegion.IsEmpty()) throw new InvalidOperationException(\"未找到原粹树脂图标\");\n// after - scale rect + one retry\nvar searchRect = ScaleRect(1200, 25, 580, 50);\nRegion resinIconRegion;\nusing (var capture = CaptureToRectArea())\nusing (var region = capture.DeriveCrop(searchRect))\n{\n    resinIconRegion = region.Find(LoadRecognitionObject(\"OriginalResinTopIcon\"));\n    if (resinIconRegion.IsEmpty()) { await Delay(500, _ct); /* re-capture and retry once */ }\n}","handlingStrategy":"retry","validationCode":"static bool IsResinIconLikelyVisible(ImageRegion capture)\n{\n    using var roi = capture.DeriveCrop(ScaleRect(1200, 25, 580, 50));\n    return roi.Find(LoadRecognitionObject(\"OriginalResinTopIcon\")).IsExist();\n}","typeGuard":null,"tryCatchPattern":"for (int i = 0; i < 2; i++)\n{\n    try { return await RecognizeOriginalResinInfoFromBigMap(); }\n    catch (InvalidOperationException ex) when (ex.Message.Contains(\"原粹树脂图标\") && i == 0)\n    { await Delay(500, _ct); }\n}","preventionTips":["Confirm the big-map UI is fully open before capturing.","Scale the search rect by AssetScale to match the resolution.","Keep the 'OriginalResinTopIcon' template current with game art.","Retry once after a short delay since UI animations can hide the icon."],"tags":["game-task","template-matching","autoboss","resolution","recognition"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}