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

オープン
#492 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
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時間
マージ済み PR(30日)
56

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Gothic-Unity-Project/Gothic-Unity のほかの issue

Gothic-Unity-Project/Gothic-Unity の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。