Refactor: NPC perception rules out of AiHandler, split NpcAiService / NpcHelperService

未關閉
#492 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
35/100
Issue 類型
重構
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
csharp, unity
領域
game-dev

研究方向

Start with the design skill and the review findings A3 and A4 from split/09-perceptions; then trace perception handling across AiHandler, NpcAiService, and NpcHelperService. Map the proposed service responsibilities and Reflex registration before implementation. Done means the responsibilities are moved as described with no behavior change; the performance notes are optional.

由索引模型根據 Issue 內容生成。

描述

improvement

Follow-up from the review of split/09-perceptions (architecture-reviewer findings A3 + A4).

Problem

  • AiHandler (adapter, ~720 lines) decides AI rules: loop rate, daily-state check, CallStateEnd, looking away
    (ForgetHeroAfterLookingAway changes AttitudeTemp), PERC_MOVENPC, PERC_ASSESSBODY. None of it is testable
    without a scene, and following one perception means reading AiHandler, NpcAiService and NpcHelperService.
  • NpcAiService (~1,100 lines) and NpcHelperService (~620 lines) each took on a new responsibility: passive
    perception broadcast/delivery, the body search, sight lines through alpha-tested polygons, Wld_DetectItem.

Proposal

  • NpcPerceptionService (new): passive perception broadcast + delivery, ExecutePassivePerception,
    FindClosestSensedBody, and the body of ExecuteActivePerceptions (incl. PERC_MOVENPC, PERC_ASSESSBODY,
    looking away).
  • NpcSightDomain (new, owned by NpcHelperService): CanSee/CanSense, IsSightBlocked, see-through caches.
  • NpcAiService keeps the state lifecycle and also gets CallStateEnd, the loop-rate and daily-state checks.
  • AiHandler keeps only the Unity part: _npcPerceptionService.TickPerceptions(NpcData) and the state calls.
  • Wld_DetectItem and the item distances could move to a Wld_*/item service.

Plan with the design skill first (new service + Reflex registration), then implement. No behaviour change.

Related performance notes from the same review (can be done during the move):

  • FindClosestSensedBody walks the whole NpcCache with a raycast per candidate on every perception tick.
  • Wld_DetectItem walks the whole VobCache per call.
主要語言
C#
星號
33
分支
1
平均合併
1 天 21 小時
30 天內合併 PR
56

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

Gothic-Unity-Project/Gothic-Unity 的其他 Issue

查看 Gothic-Unity-Project/Gothic-Unity 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。